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
3ac66785
Commit
3ac66785
authored
4 years ago
by
Loïc Correnson
Browse files
Options
Downloads
Patches
Plain Diff
[dome] fix settings lifecycle
parent
a0b6b3cc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ivette/src/dome/src/renderer/data/settings.ts
+10
-29
10 additions, 29 deletions
ivette/src/dome/src/renderer/data/settings.ts
ivette/src/dome/src/renderer/layout/splitters.js
+1
-1
1 addition, 1 deletion
ivette/src/dome/src/renderer/layout/splitters.js
with
11 additions
and
30 deletions
ivette/src/dome/src/renderer/data/settings.ts
+
10
−
29
View file @
3ac66785
...
@@ -12,7 +12,7 @@ import React from 'react';
...
@@ -12,7 +12,7 @@ import React from 'react';
import
{
ipcRenderer
}
from
'
electron
'
;
import
{
ipcRenderer
}
from
'
electron
'
;
import
{
debounce
}
from
'
lodash
'
;
import
{
debounce
}
from
'
lodash
'
;
import
isEqual
from
'
react-fast-compare
'
;
import
isEqual
from
'
react-fast-compare
'
;
import
{
DEVEL
,
emitter
as
SysEmitter
}
from
'
dome/misc/system
'
;
import
{
emitter
as
SysEmitter
}
from
'
dome/misc/system
'
;
import
*
as
JSON
from
'
./json
'
;
import
*
as
JSON
from
'
./json
'
;
import
type
{
State
}
from
'
./states
'
;
import
type
{
State
}
from
'
./states
'
;
...
@@ -115,6 +115,7 @@ export class GObject<A extends JSON.json> extends GlobalSettings<A> {
...
@@ -115,6 +115,7 @@ export class GObject<A extends JSON.json> extends GlobalSettings<A> {
// --- Generic Settings (private)
// --- Generic Settings (private)
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
type
store
=
{
[
key
:
string
]:
JSON
.
json
};
type
patch
=
{
key
:
string
;
value
:
JSON
.
json
};
type
patch
=
{
key
:
string
;
value
:
JSON
.
json
};
type
driver
=
{
evt
:
string
;
ipc
:
string
;
broadcast
:
boolean
};
type
driver
=
{
evt
:
string
;
ipc
:
string
;
broadcast
:
boolean
};
...
@@ -177,14 +178,12 @@ class Driver {
...
@@ -177,14 +178,12 @@ class Driver {
// --- Initial Data
// --- Initial Data
sync
(
data
:
patch
[]
)
{
sync
(
data
:
store
)
{
this
.
fire
.
cancel
();
this
.
fire
.
cancel
();
this
.
store
.
clear
();
this
.
store
.
clear
();
this
.
diffs
.
clear
();
this
.
diffs
.
clear
();
const
m
=
this
.
store
;
const
m
=
this
.
store
;
data
.
forEach
(({
key
,
value
})
=>
{
Object
.
keys
(
data
).
forEach
((
k
)
=>
{
m
.
set
(
k
,
data
[
k
]);
});
m
.
set
(
key
,
value
);
});
SysEmitter
.
emit
(
this
.
evt
);
SysEmitter
.
emit
(
this
.
evt
);
}
}
...
@@ -215,25 +214,11 @@ class Driver {
...
@@ -215,25 +214,11 @@ class Driver {
// --- Generic Settings Hook
// --- Generic Settings Hook
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
const
keys
=
new
Set
<
string
>
();
function
useSettings
<
A
>
(
function
useSettings
<
A
>
(
S
:
Settings
<
A
>
,
S
:
Settings
<
A
>
,
D
:
Driver
,
D
:
Driver
,
K
?:
string
,
K
?:
string
,
):
State
<
A
>
{
):
State
<
A
>
{
// Check for unique key
React
.
useEffect
(()
=>
{
if
(
K
)
{
if
(
keys
.
has
(
K
)
&&
DEVEL
)
console
.
error
(
'
[Dome.settings] Duplicate key
'
,
K
);
else
{
keys
.
add
(
K
);
return
()
=>
{
keys
.
delete
(
K
);
};
}
}
return
undefined
;
});
// Load value
// Load value
const
loader
=
()
=>
(
const
loader
=
()
=>
(
JSON
.
jCatch
(
S
.
decoder
,
S
.
defaultValue
)(
D
.
load
(
K
))
JSON
.
jCatch
(
S
.
decoder
,
S
.
defaultValue
)(
D
.
load
(
K
))
...
@@ -354,7 +339,7 @@ export function offWindowSettings(callback: () => void) {
...
@@ -354,7 +339,7 @@ export function offWindowSettings(callback: () => void) {
const
GlobalSettingsDriver
=
new
Driver
({
const
GlobalSettingsDriver
=
new
Driver
({
evt
:
'
dome.settings.global
'
,
evt
:
'
dome.settings.global
'
,
ipc
:
'
dome.ipc.settings.
window
'
,
ipc
:
'
dome.ipc.settings.
global
'
,
broadcast
:
true
,
broadcast
:
true
,
});
});
...
@@ -388,15 +373,11 @@ export const global = GlobalSettingsDriver.evt;
...
@@ -388,15 +373,11 @@ export const global = GlobalSettingsDriver.evt;
/* @ internal */
/* @ internal */
export
function
synchronize
()
{
export
function
synchronize
()
{
ipcRenderer
.
sendSync
(
const
data
=
ipcRenderer
.
sendSync
(
'
dome.ipc.settings.sync
'
);
'
dome.ipc.settings.sync
'
,
const
globals
:
store
=
data
.
store
??
{};
(
_event
:
string
,
data
:
any
)
=>
{
GlobalSettingsDriver
.
sync
(
globals
);
const
globals
:
patch
[]
=
data
.
globals
??
[];
const
settings
:
store
=
data
.
settings
??
{};
GlobalSettingsDriver
.
sync
(
globals
);
WindowSettingsDriver
.
sync
(
settings
);
const
settings
:
patch
[]
=
data
.
settings
??
[];
WindowSettingsDriver
.
sync
(
settings
);
},
);
}
}
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
This diff is collapsed.
Click to expand it.
ivette/src/dome/src/renderer/layout/splitters.js
+
1
−
1
View file @
3ac66785
...
@@ -197,7 +197,7 @@ export class Splitter extends React.Component {
...
@@ -197,7 +197,7 @@ export class Splitter extends React.Component {
}
}
handleReload
()
{
handleReload
()
{
if
(
this
.
refs
.
container
&&
this
.
refs
.
splitter
)
{
if
(
this
.
refs
&&
this
.
refs
.
container
&&
this
.
refs
.
splitter
)
{
const
container
=
this
.
refs
.
container
.
getBoundingClientRect
()
;
const
container
=
this
.
refs
.
container
.
getBoundingClientRect
()
;
const
dimension
=
this
.
lr
?
container
.
width
:
container
.
height
;
const
dimension
=
this
.
lr
?
container
.
width
:
container
.
height
;
this
.
range
=
dimension
-
this
.
margin
;
this
.
range
=
dimension
-
this
.
margin
;
...
...
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