@exodus/ui-config 3.11.0 → 3.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/atoms/index.js +7 -15
- package/atoms/local.js +16 -0
- package/atoms/syncable.js +45 -0
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [3.12.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/ui-config@3.12.0...@exodus/ui-config@3.12.1) (2024-09-27)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **ui-config:** store syncable configs in storage ([#9581](https://github.com/ExodusMovement/exodus-hydra/issues/9581)) ([73b97d3](https://github.com/ExodusMovement/exodus-hydra/commit/73b97d392975b250aef35801f6acc658b72404ec))
|
|
11
|
+
|
|
12
|
+
## [3.12.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/ui-config@3.11.0...@exodus/ui-config@3.12.0) (2024-09-27)
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
- **ui-config:** add syncable configs support ([#9543](https://github.com/ExodusMovement/exodus-hydra/issues/9543)) ([31e5d61](https://github.com/ExodusMovement/exodus-hydra/commit/31e5d61bb64279d3caf4d9045d87afd23234e345))
|
|
17
|
+
|
|
6
18
|
## [3.11.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/ui-config@3.10.2...@exodus/ui-config@3.11.0) (2024-09-20)
|
|
7
19
|
|
|
8
20
|
### Features
|
package/atoms/index.js
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import createSyncableUiConfigAtom from './syncable.js'
|
|
2
|
+
import createLocalUiConfigAtom from './local.js'
|
|
2
3
|
|
|
3
4
|
const createUiConfigAtomDefinitions = ({ configValues }) => {
|
|
4
|
-
return configValues.map((
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
createStorageAtomFactory({ storage })({ key: id, isSoleWriter: true, defaultValue }),
|
|
10
|
-
dependencies: ['storage'],
|
|
11
|
-
public: true,
|
|
12
|
-
},
|
|
13
|
-
aliases: [
|
|
14
|
-
{ implementationId: encrypted ? 'storage' : 'unsafeStorage', interfaceId: 'storage' },
|
|
15
|
-
],
|
|
16
|
-
storage: { namespace: 'uiConfig' },
|
|
17
|
-
}))
|
|
5
|
+
return configValues.map((configValue) =>
|
|
6
|
+
configValue.syncable
|
|
7
|
+
? createSyncableUiConfigAtom(configValue)
|
|
8
|
+
: createLocalUiConfigAtom(configValue)
|
|
9
|
+
)
|
|
18
10
|
}
|
|
19
11
|
|
|
20
12
|
export default createUiConfigAtomDefinitions
|
package/atoms/local.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createStorageAtomFactory } from '@exodus/atoms'
|
|
2
|
+
|
|
3
|
+
const createLocalUiConfigAtom = ({ id, atomId, encrypted, defaultValue }) => ({
|
|
4
|
+
definition: {
|
|
5
|
+
id: atomId,
|
|
6
|
+
type: 'atom',
|
|
7
|
+
factory: ({ storage }) =>
|
|
8
|
+
createStorageAtomFactory({ storage })({ key: id, isSoleWriter: true, defaultValue }),
|
|
9
|
+
dependencies: ['storage'],
|
|
10
|
+
public: true,
|
|
11
|
+
},
|
|
12
|
+
aliases: [{ implementationId: encrypted ? 'storage' : 'unsafeStorage', interfaceId: 'storage' }],
|
|
13
|
+
storage: { namespace: 'uiConfig' },
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
export default createLocalUiConfigAtom
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/* eslint-disable @exodus/hydra/no-eternal-subscription */
|
|
2
|
+
|
|
3
|
+
import lodash from 'lodash'
|
|
4
|
+
import { createFusionAtom } from '@exodus/fusion-atoms'
|
|
5
|
+
import { createStorageAtomFactory } from '@exodus/atoms'
|
|
6
|
+
|
|
7
|
+
const { isEqual } = lodash
|
|
8
|
+
|
|
9
|
+
const createSyncableUiConfigAtom = ({ id, atomId, encrypted, defaultValue }) => {
|
|
10
|
+
const factory = ({ fusion, storage }) => {
|
|
11
|
+
const path = encrypted ? `private.${id}` : id
|
|
12
|
+
|
|
13
|
+
const localAtom = createStorageAtomFactory({ storage })({ key: id, isSoleWriter: true })
|
|
14
|
+
const fusionAtom = createFusionAtom({ fusion, path })
|
|
15
|
+
|
|
16
|
+
// Sync value up to fusion
|
|
17
|
+
localAtom.observe((value) => {
|
|
18
|
+
if (value === undefined) return // Avoid syncing down missing fusion values
|
|
19
|
+
fusionAtom.set((prevValue) => (isEqual(value, prevValue) ? prevValue : value))
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
// Sync value down from fusion
|
|
23
|
+
fusionAtom.observe((value) => {
|
|
24
|
+
if (value === undefined) return // Avoid syncing down missing fusion values
|
|
25
|
+
localAtom.set((prevValue) => (isEqual(value, prevValue) ? prevValue : value))
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
return localAtom
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
definition: {
|
|
33
|
+
id: atomId,
|
|
34
|
+
type: 'atom',
|
|
35
|
+
factory,
|
|
36
|
+
dependencies: ['fusion', 'storage'],
|
|
37
|
+
},
|
|
38
|
+
storage: { namespace: 'uiConfig' },
|
|
39
|
+
aliases: [
|
|
40
|
+
{ implementationId: encrypted ? 'storage' : 'unsafeStorage', interfaceId: 'storage' },
|
|
41
|
+
],
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default createSyncableUiConfigAtom
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/ui-config",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.12.1",
|
|
4
4
|
"description": "Helper for storing various UI-specific settings/config.",
|
|
5
5
|
"author": "Exodus Movement, Inc.",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -34,11 +34,12 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@exodus/atoms": "^8.1.1",
|
|
36
36
|
"@exodus/formatting": "^8.0.0",
|
|
37
|
+
"@exodus/fusion-atoms": "^1.2.0",
|
|
37
38
|
"lodash": "^4.17.21"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"@exodus/redux-dependency-injection": "^4.0.3",
|
|
41
42
|
"redux": "^4.2.1"
|
|
42
43
|
},
|
|
43
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "749dabfbfbc35953de731b88bea180e95edc1e06"
|
|
44
45
|
}
|