Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
cc97d551
Commit
cc97d551
authored
2 years ago
by
Loïc Correnson
Browse files
Options
Downloads
Patches
Plain Diff
[dome] more types in dome/data
parent
6ca982de
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ivette/src/dome/renderer/data/settings.ts
+16
-18
16 additions, 18 deletions
ivette/src/dome/renderer/data/settings.ts
with
16 additions
and
18 deletions
ivette/src/dome/renderer/data/settings.ts
+
16
−
18
View file @
cc97d551
...
@@ -20,8 +20,6 @@
...
@@ -20,8 +20,6 @@
/* */
/* */
/* ************************************************************************ */
/* ************************************************************************ */
/* eslint-disable @typescript-eslint/explicit-function-return-type */
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
// --- States
// --- States
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
...
@@ -207,7 +205,7 @@ class Driver {
...
@@ -207,7 +205,7 @@ class Driver {
// --- Initial Data
// --- Initial Data
sync
(
data
:
store
)
{
sync
(
data
:
store
)
:
void
{
this
.
commit
.
cancel
();
this
.
commit
.
cancel
();
this
.
store
.
clear
();
this
.
store
.
clear
();
this
.
diffs
.
clear
();
this
.
diffs
.
clear
();
...
@@ -224,7 +222,7 @@ class Driver {
...
@@ -224,7 +222,7 @@ class Driver {
// --- Save Data
// --- Save Data
save
(
key
:
string
|
undefined
,
data
:
JSON
.
json
)
{
save
(
key
:
string
|
undefined
,
data
:
JSON
.
json
)
:
void
{
if
(
key
===
undefined
)
return
;
if
(
key
===
undefined
)
return
;
if
(
data
===
undefined
)
{
if
(
data
===
undefined
)
{
this
.
store
.
delete
(
key
);
this
.
store
.
delete
(
key
);
...
@@ -255,7 +253,7 @@ function useSettings<A>(
...
@@ -255,7 +253,7 @@ function useSettings<A>(
// Foreign Settings Update
// Foreign Settings Update
React
.
useEffect
(()
=>
{
React
.
useEffect
(()
=>
{
const
event
=
D
.
evt
;
const
event
=
D
.
evt
;
const
onUpdate
=
()
=>
{
const
onUpdate
=
()
:
void
=>
{
const
fromSettings
=
JSON
.
jCatch
(
S
.
decoder
,
undefined
)(
D
.
load
(
K
));
const
fromSettings
=
JSON
.
jCatch
(
S
.
decoder
,
undefined
)(
D
.
load
(
K
));
if
(
fromSettings
!==
undefined
)
if
(
fromSettings
!==
undefined
)
setValue
(
fromSettings
);
setValue
(
fromSettings
);
...
@@ -307,7 +305,7 @@ export function getWindowSettings<A>(
...
@@ -307,7 +305,7 @@ export function getWindowSettings<A>(
export
function
setWindowSettings
(
export
function
setWindowSettings
(
key
:
string
|
undefined
,
key
:
string
|
undefined
,
value
:
JSON
.
json
,
value
:
JSON
.
json
,
)
{
)
:
void
{
if
(
key
)
WindowSettingsDriver
.
save
(
key
,
value
);
if
(
key
)
WindowSettingsDriver
.
save
(
key
,
value
);
}
}
...
@@ -320,7 +318,7 @@ export function useWindowSettings<A>(
...
@@ -320,7 +318,7 @@ export function useWindowSettings<A>(
key
:
string
|
undefined
,
key
:
string
|
undefined
,
decoder
:
JSON
.
Loose
<
A
&
JSON
.
json
>
,
decoder
:
JSON
.
Loose
<
A
&
JSON
.
json
>
,
defaultValue
:
A
&
JSON
.
json
,
defaultValue
:
A
&
JSON
.
json
,
)
{
)
:
State
<
A
&
JSON
.
json
>
{
return
useSettings
({
return
useSettings
({
decoder
,
decoder
,
encoder
:
JSON
.
identity
,
encoder
:
JSON
.
identity
,
...
@@ -334,7 +332,7 @@ export function useWindowSettingsData<A>(
...
@@ -334,7 +332,7 @@ export function useWindowSettingsData<A>(
decoder
:
JSON
.
Loose
<
A
>
,
decoder
:
JSON
.
Loose
<
A
>
,
encoder
:
JSON
.
Encoder
<
A
>
,
encoder
:
JSON
.
Encoder
<
A
>
,
defaultValue
:
A
,
defaultValue
:
A
,
)
{
)
:
State
<
A
>
{
return
useSettings
({
return
useSettings
({
decoder
,
decoder
,
encoder
,
encoder
,
...
@@ -343,7 +341,7 @@ export function useWindowSettingsData<A>(
...
@@ -343,7 +341,7 @@ export function useWindowSettingsData<A>(
}
}
/** Call the callback function on window settings events. */
/** Call the callback function on window settings events. */
export
function
useWindowSettingsEvent
(
callback
:
()
=>
void
)
{
export
function
useWindowSettingsEvent
(
callback
:
()
=>
void
)
:
void
{
React
.
useEffect
(()
=>
{
React
.
useEffect
(()
=>
{
const
{
evt
}
=
WindowSettingsDriver
;
const
{
evt
}
=
WindowSettingsDriver
;
SysEmitter
.
on
(
evt
,
callback
);
SysEmitter
.
on
(
evt
,
callback
);
...
@@ -352,13 +350,13 @@ export function useWindowSettingsEvent(callback: () => void) {
...
@@ -352,13 +350,13 @@ export function useWindowSettingsEvent(callback: () => void) {
}
}
/** @ignore DEPRECATED */
/** @ignore DEPRECATED */
export
function
onWindowSettings
(
callback
:
()
=>
void
)
{
export
function
onWindowSettings
(
callback
:
()
=>
void
)
:
void
{
const
{
evt
}
=
WindowSettingsDriver
;
const
{
evt
}
=
WindowSettingsDriver
;
SysEmitter
.
on
(
evt
,
callback
);
SysEmitter
.
on
(
evt
,
callback
);
}
}
/** @ignore DEPRECATED */
/** @ignore DEPRECATED */
export
function
offWindowSettings
(
callback
:
()
=>
void
)
{
export
function
offWindowSettings
(
callback
:
()
=>
void
)
:
void
{
const
{
evt
}
=
WindowSettingsDriver
;
const
{
evt
}
=
WindowSettingsDriver
;
SysEmitter
.
off
(
evt
,
callback
);
SysEmitter
.
off
(
evt
,
callback
);
}
}
...
@@ -396,7 +394,7 @@ export function getLocalStorage<A>(
...
@@ -396,7 +394,7 @@ export function getLocalStorage<A>(
export
function
setLocalStorage
(
export
function
setLocalStorage
(
key
:
string
|
undefined
,
key
:
string
|
undefined
,
value
:
JSON
.
json
,
value
:
JSON
.
json
,
)
{
)
:
void
{
if
(
key
)
LocalStorageDriver
.
save
(
key
,
value
);
if
(
key
)
LocalStorageDriver
.
save
(
key
,
value
);
}
}
...
@@ -404,7 +402,7 @@ export function useLocalStorage<A>(
...
@@ -404,7 +402,7 @@ export function useLocalStorage<A>(
key
:
string
|
undefined
,
key
:
string
|
undefined
,
decoder
:
JSON
.
Loose
<
A
&
JSON
.
json
>
,
decoder
:
JSON
.
Loose
<
A
&
JSON
.
json
>
,
defaultValue
:
A
&
JSON
.
json
,
defaultValue
:
A
&
JSON
.
json
,
)
{
)
:
State
<
A
&
JSON
.
json
>
{
return
useSettings
<
A
&
JSON
.
json
>
({
return
useSettings
<
A
&
JSON
.
json
>
({
decoder
,
decoder
,
encoder
:
JSON
.
identity
,
encoder
:
JSON
.
identity
,
...
@@ -418,7 +416,7 @@ export function useLocalStorageData<A>(
...
@@ -418,7 +416,7 @@ export function useLocalStorageData<A>(
decoder
:
JSON
.
Loose
<
A
>
,
decoder
:
JSON
.
Loose
<
A
>
,
encoder
:
JSON
.
Encoder
<
A
>
,
encoder
:
JSON
.
Encoder
<
A
>
,
defaultValue
:
A
,
defaultValue
:
A
,
)
{
)
:
State
<
A
>
{
return
useSettings
({
return
useSettings
({
decoder
,
decoder
,
encoder
,
encoder
,
...
@@ -427,7 +425,7 @@ export function useLocalStorageData<A>(
...
@@ -427,7 +425,7 @@ export function useLocalStorageData<A>(
}
}
/** Call the callback function on window settings events. */
/** Call the callback function on window settings events. */
export
function
useLocalStorageEvent
(
callback
:
()
=>
void
)
{
export
function
useLocalStorageEvent
(
callback
:
()
=>
void
)
:
void
{
React
.
useEffect
(()
=>
{
React
.
useEffect
(()
=>
{
const
{
evt
}
=
LocalStorageDriver
;
const
{
evt
}
=
LocalStorageDriver
;
SysEmitter
.
on
(
evt
,
callback
);
SysEmitter
.
on
(
evt
,
callback
);
...
@@ -451,12 +449,12 @@ const GlobalSettingsDriver = new Driver({
...
@@ -451,12 +449,12 @@ const GlobalSettingsDriver = new Driver({
back in the global user settings. The global user settings file is located in
back in the global user settings. The global user settings file is located in
the usual place for the application with respect to the underlying system.
the usual place for the application with respect to the underlying system.
*/
*/
export
function
useGlobalSettings
<
A
>
(
S
:
GlobalSettings
<
A
>
)
{
export
function
useGlobalSettings
<
A
>
(
S
:
GlobalSettings
<
A
>
)
:
State
<
A
>
{
return
useSettings
(
S
,
GlobalSettingsDriver
,
S
.
name
);
return
useSettings
(
S
,
GlobalSettingsDriver
,
S
.
name
);
}
}
/** Call the callback function on global settings events. */
/** Call the callback function on global settings events. */
export
function
useGlobalSettingsEvent
(
callback
:
()
=>
void
)
{
export
function
useGlobalSettingsEvent
(
callback
:
()
=>
void
)
:
void
{
React
.
useEffect
(()
=>
{
React
.
useEffect
(()
=>
{
const
{
evt
}
=
GlobalSettingsDriver
;
const
{
evt
}
=
GlobalSettingsDriver
;
SysEmitter
.
on
(
evt
,
callback
);
SysEmitter
.
on
(
evt
,
callback
);
...
@@ -475,7 +473,7 @@ export const window = WindowSettingsDriver.evt;
...
@@ -475,7 +473,7 @@ export const window = WindowSettingsDriver.evt;
export
const
global
=
GlobalSettingsDriver
.
evt
;
export
const
global
=
GlobalSettingsDriver
.
evt
;
/* @ internal */
/* @ internal */
export
function
synchronize
()
{
export
function
synchronize
()
:
void
{
const
data
=
ipcRenderer
.
sendSync
(
'
dome.ipc.settings.sync
'
);
const
data
=
ipcRenderer
.
sendSync
(
'
dome.ipc.settings.sync
'
);
const
storage
:
store
=
data
.
storage
??
{};
const
storage
:
store
=
data
.
storage
??
{};
const
globals
:
store
=
data
.
globals
??
{};
const
globals
:
store
=
data
.
globals
??
{};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment