@oxy.so/services 14.1.2 → 14.2.0
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/lib/commonjs/ui/hooks/useAccountColor.js +16 -8
- package/lib/commonjs/ui/hooks/useAccountColor.js.map +1 -1
- package/lib/module/ui/hooks/useAccountColor.js +16 -8
- package/lib/module/ui/hooks/useAccountColor.js.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useAccountColor.d.ts +6 -4
- package/lib/typescript/commonjs/ui/hooks/useAccountColor.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useAccountColor.d.ts +6 -4
- package/lib/typescript/module/ui/hooks/useAccountColor.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ui/hooks/useAccountColor.ts +21 -8
|
@@ -47,15 +47,21 @@ function useAccountColor({
|
|
|
47
47
|
user
|
|
48
48
|
} = (0, _useAuth.useAuth)();
|
|
49
49
|
const {
|
|
50
|
-
colorPreset,
|
|
51
50
|
setColorPreset
|
|
52
51
|
} = (0, _theme.useBloomTheme)();
|
|
53
52
|
const accountColor = resolveAccountColor(user);
|
|
54
53
|
const allowed = accountColor !== null && (canUse?.(accountColor) ?? true);
|
|
54
|
+
|
|
55
|
+
// Follow the ACCOUNT, never fight the theme: this applies when the account's
|
|
56
|
+
// colour (or the app's permission to wear it) changes, exactly like the mode
|
|
57
|
+
// sync in `useAccountTheme`. Re-running on every local preset change would
|
|
58
|
+
// pull a colour just chosen back to the stored one while its save is still in
|
|
59
|
+
// flight, so the root theme (and every surface painted from it, such as an
|
|
60
|
+
// open settings modal) showed the old colour after a pick.
|
|
55
61
|
(0, _react.useEffect)(() => {
|
|
56
|
-
if (!isAuthenticated || !accountColor || !allowed
|
|
62
|
+
if (!isAuthenticated || !accountColor || !allowed) return;
|
|
57
63
|
setColorPreset(accountColor);
|
|
58
|
-
}, [isAuthenticated, accountColor, allowed,
|
|
64
|
+
}, [isAuthenticated, accountColor, allowed, setColorPreset]);
|
|
59
65
|
}
|
|
60
66
|
/**
|
|
61
67
|
* The presets this account may choose, from the contract's own gate table: a
|
|
@@ -86,11 +92,13 @@ function entitledAccountColors(user, now = Date.now()) {
|
|
|
86
92
|
/**
|
|
87
93
|
* Choose the account's colour: one `updateMe` writes `color` and the portable
|
|
88
94
|
* `themePreference.colorPreset` together (the mode already on the account is
|
|
89
|
-
* kept), the Bloom theme follows at once
|
|
90
|
-
*
|
|
91
|
-
*
|
|
95
|
+
* kept), the Bloom theme follows at once and goes back if the write fails.
|
|
96
|
+
* `colors` is what the picker should list; an app with a stricter rule of its
|
|
97
|
+
* own passes the same `canUse` it gives `useAccountColor`.
|
|
92
98
|
*/
|
|
93
|
-
function useAccountColorSave(
|
|
99
|
+
function useAccountColorSave({
|
|
100
|
+
canUse
|
|
101
|
+
} = {}) {
|
|
94
102
|
const {
|
|
95
103
|
user
|
|
96
104
|
} = (0, _useAuth.useAuth)();
|
|
@@ -103,7 +111,7 @@ function useAccountColorSave() {
|
|
|
103
111
|
mutateAsync,
|
|
104
112
|
isPending
|
|
105
113
|
} = (0, _useAccountMutations.useUpdateProfile)();
|
|
106
|
-
const colors = (0, _react.useMemo)(() => entitledAccountColors(user), [user]);
|
|
114
|
+
const colors = (0, _react.useMemo)(() => entitledAccountColors(user).filter(name => canUse?.(name) ?? true), [user, canUse]);
|
|
107
115
|
const saveColor = (0, _react.useCallback)(async name => {
|
|
108
116
|
if (!colors.includes(name)) throw new Error('Color is not available for this account');
|
|
109
117
|
const previous = colorPreset;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_theme","_client","_useAuth","_useAccountMutations","isAppColorName","value","Object","prototype","hasOwnProperty","call","APP_COLOR_PRESETS","resolveAccountColor","user","stored","color","themePreference","colorPreset","useAccountColor","canUse","isAuthenticated","useAuth","setColorPreset","useBloomTheme","accountColor","allowed","useEffect","entitledAccountColors","now","Date","handle","username","trim","toLowerCase","grant","personalization","mentionMono","expires","expiresAt","Infinity","parse","hasMono","supported","Set","USER_PROFILE_COLOR_PRESETS","USER_PROFILE_COLORS","filter","name","gate","has","map","useAccountColorSave","mode","mutateAsync","isPending","useUpdateProfile","colors","useMemo","saveColor","useCallback","includes","Error","previous","error","saving"],"sourceRoot":"../../../../src","sources":["ui/hooks/useAccountColor.ts"],"mappings":";;;;;;;;;AAkBA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,oBAAA,GAAAJ,OAAA;AAvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,SAASK,cAAcA,CAACC,KAAc,EAAyB;EAC7D,OACE,OAAOA,KAAK,KAAK,QAAQ,IAAIC,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACC,wBAAiB,EAAEL,KAAK,CAAC;AAE/F;;AAEA;AACO,SAASM,mBAAmBA,CACjCC,IAAgE,EAC3C;EACrB,MAAMC,MAAM,GAAGD,IAAI,EAAEE,KAAK,IAAIF,IAAI,EAAEG,eAAe,EAAEC,WAAW;EAChE,OAAOZ,cAAc,CAACS,MAAM,CAAC,GAAGA,MAAM,GAAG,IAAI;AAC/C;AAEO,SAASI,eAAeA,CAAC;EAC9BC;AAGF,CAAC,GAAG,CAAC,CAAC,EAAQ;EACZ,MAAM;IAAEC,eAAe;IAAEP;EAAK,CAAC,GAAG,IAAAQ,gBAAO,EAAC,CAAC;EAC3C,MAAM;
|
|
1
|
+
{"version":3,"names":["_react","require","_theme","_client","_useAuth","_useAccountMutations","isAppColorName","value","Object","prototype","hasOwnProperty","call","APP_COLOR_PRESETS","resolveAccountColor","user","stored","color","themePreference","colorPreset","useAccountColor","canUse","isAuthenticated","useAuth","setColorPreset","useBloomTheme","accountColor","allowed","useEffect","entitledAccountColors","now","Date","handle","username","trim","toLowerCase","grant","personalization","mentionMono","expires","expiresAt","Infinity","parse","hasMono","supported","Set","USER_PROFILE_COLOR_PRESETS","USER_PROFILE_COLORS","filter","name","gate","has","map","useAccountColorSave","mode","mutateAsync","isPending","useUpdateProfile","colors","useMemo","saveColor","useCallback","includes","Error","previous","error","saving"],"sourceRoot":"../../../../src","sources":["ui/hooks/useAccountColor.ts"],"mappings":";;;;;;;;;AAkBA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,oBAAA,GAAAJ,OAAA;AAvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,SAASK,cAAcA,CAACC,KAAc,EAAyB;EAC7D,OACE,OAAOA,KAAK,KAAK,QAAQ,IAAIC,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACC,wBAAiB,EAAEL,KAAK,CAAC;AAE/F;;AAEA;AACO,SAASM,mBAAmBA,CACjCC,IAAgE,EAC3C;EACrB,MAAMC,MAAM,GAAGD,IAAI,EAAEE,KAAK,IAAIF,IAAI,EAAEG,eAAe,EAAEC,WAAW;EAChE,OAAOZ,cAAc,CAACS,MAAM,CAAC,GAAGA,MAAM,GAAG,IAAI;AAC/C;AAEO,SAASI,eAAeA,CAAC;EAC9BC;AAGF,CAAC,GAAG,CAAC,CAAC,EAAQ;EACZ,MAAM;IAAEC,eAAe;IAAEP;EAAK,CAAC,GAAG,IAAAQ,gBAAO,EAAC,CAAC;EAC3C,MAAM;IAAEC;EAAe,CAAC,GAAG,IAAAC,oBAAa,EAAC,CAAC;EAC1C,MAAMC,YAAY,GAAGZ,mBAAmB,CAACC,IAAI,CAAC;EAC9C,MAAMY,OAAO,GAAGD,YAAY,KAAK,IAAI,KAAKL,MAAM,GAAGK,YAAY,CAAC,IAAI,IAAI,CAAC;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EAAEK,cAAc,EAAE+B,WAAW,EAAExC,IAAI,EAAEuC,IAAI,CAC/D,CAAC;EACD,OAAO;IAAEI,MAAM;IAAElD,KAAK,EAAEW,WAAW;IAAEyC,SAAS;IAAEM,MAAM,EAAEV;EAAU,CAAC;AACrE","ignoreList":[]}
|
|
@@ -40,15 +40,21 @@ export function useAccountColor({
|
|
|
40
40
|
user
|
|
41
41
|
} = useAuth();
|
|
42
42
|
const {
|
|
43
|
-
colorPreset,
|
|
44
43
|
setColorPreset
|
|
45
44
|
} = useBloomTheme();
|
|
46
45
|
const accountColor = resolveAccountColor(user);
|
|
47
46
|
const allowed = accountColor !== null && (canUse?.(accountColor) ?? true);
|
|
47
|
+
|
|
48
|
+
// Follow the ACCOUNT, never fight the theme: this applies when the account's
|
|
49
|
+
// colour (or the app's permission to wear it) changes, exactly like the mode
|
|
50
|
+
// sync in `useAccountTheme`. Re-running on every local preset change would
|
|
51
|
+
// pull a colour just chosen back to the stored one while its save is still in
|
|
52
|
+
// flight, so the root theme (and every surface painted from it, such as an
|
|
53
|
+
// open settings modal) showed the old colour after a pick.
|
|
48
54
|
useEffect(() => {
|
|
49
|
-
if (!isAuthenticated || !accountColor || !allowed
|
|
55
|
+
if (!isAuthenticated || !accountColor || !allowed) return;
|
|
50
56
|
setColorPreset(accountColor);
|
|
51
|
-
}, [isAuthenticated, accountColor, allowed,
|
|
57
|
+
}, [isAuthenticated, accountColor, allowed, setColorPreset]);
|
|
52
58
|
}
|
|
53
59
|
/**
|
|
54
60
|
* The presets this account may choose, from the contract's own gate table: a
|
|
@@ -79,11 +85,13 @@ export function entitledAccountColors(user, now = Date.now()) {
|
|
|
79
85
|
/**
|
|
80
86
|
* Choose the account's colour: one `updateMe` writes `color` and the portable
|
|
81
87
|
* `themePreference.colorPreset` together (the mode already on the account is
|
|
82
|
-
* kept), the Bloom theme follows at once
|
|
83
|
-
*
|
|
84
|
-
*
|
|
88
|
+
* kept), the Bloom theme follows at once and goes back if the write fails.
|
|
89
|
+
* `colors` is what the picker should list; an app with a stricter rule of its
|
|
90
|
+
* own passes the same `canUse` it gives `useAccountColor`.
|
|
85
91
|
*/
|
|
86
|
-
export function useAccountColorSave(
|
|
92
|
+
export function useAccountColorSave({
|
|
93
|
+
canUse
|
|
94
|
+
} = {}) {
|
|
87
95
|
const {
|
|
88
96
|
user
|
|
89
97
|
} = useAuth();
|
|
@@ -96,7 +104,7 @@ export function useAccountColorSave() {
|
|
|
96
104
|
mutateAsync,
|
|
97
105
|
isPending
|
|
98
106
|
} = useUpdateProfile();
|
|
99
|
-
const colors = useMemo(() => entitledAccountColors(user), [user]);
|
|
107
|
+
const colors = useMemo(() => entitledAccountColors(user).filter(name => canUse?.(name) ?? true), [user, canUse]);
|
|
100
108
|
const saveColor = useCallback(async name => {
|
|
101
109
|
if (!colors.includes(name)) throw new Error('Color is not available for this account');
|
|
102
110
|
const previous = colorPreset;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useCallback","useEffect","useMemo","APP_COLOR_PRESETS","useBloomTheme","USER_PROFILE_COLORS","USER_PROFILE_COLOR_PRESETS","useAuth","useUpdateProfile","isAppColorName","value","Object","prototype","hasOwnProperty","call","resolveAccountColor","user","stored","color","themePreference","colorPreset","useAccountColor","canUse","isAuthenticated","setColorPreset","accountColor","allowed","entitledAccountColors","now","Date","handle","username","trim","toLowerCase","grant","personalization","mentionMono","expires","expiresAt","Infinity","parse","hasMono","supported","Set","filter","name","gate","has","map","useAccountColorSave","mode","mutateAsync","isPending","colors","saveColor","includes","Error","previous","error","saving"],"sourceRoot":"../../../../src","sources":["ui/hooks/useAccountColor.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,WAAW,EAAEC,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAEvD,SAASC,iBAAiB,EAAEC,aAAa,QAA2B,qBAAqB;AACzF,SAASC,mBAAmB,EAAEC,0BAA0B,QAAQ,0BAA0B;AAC1F,SAASC,OAAO,QAAQ,cAAW;AACnC,SAASC,gBAAgB,QAAQ,oCAAiC;AAElE,SAASC,cAAcA,CAACC,KAAc,EAAyB;EAC7D,OACE,OAAOA,KAAK,KAAK,QAAQ,IAAIC,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACX,iBAAiB,EAAEO,KAAK,CAAC;AAE/F;;AAEA;AACA,OAAO,SAASK,mBAAmBA,CACjCC,IAAgE,EAC3C;EACrB,MAAMC,MAAM,GAAGD,IAAI,EAAEE,KAAK,IAAIF,IAAI,EAAEG,eAAe,EAAEC,WAAW;EAChE,OAAOX,cAAc,CAACQ,MAAM,CAAC,GAAGA,MAAM,GAAG,IAAI;AAC/C;AAEA,OAAO,SAASI,eAAeA,CAAC;EAC9BC;AAGF,CAAC,GAAG,CAAC,CAAC,EAAQ;EACZ,MAAM;IAAEC,eAAe;IAAEP;EAAK,CAAC,GAAGT,OAAO,CAAC,CAAC;EAC3C,MAAM;
|
|
1
|
+
{"version":3,"names":["useCallback","useEffect","useMemo","APP_COLOR_PRESETS","useBloomTheme","USER_PROFILE_COLORS","USER_PROFILE_COLOR_PRESETS","useAuth","useUpdateProfile","isAppColorName","value","Object","prototype","hasOwnProperty","call","resolveAccountColor","user","stored","color","themePreference","colorPreset","useAccountColor","canUse","isAuthenticated","setColorPreset","accountColor","allowed","entitledAccountColors","now","Date","handle","username","trim","toLowerCase","grant","personalization","mentionMono","expires","expiresAt","Infinity","parse","hasMono","supported","Set","filter","name","gate","has","map","useAccountColorSave","mode","mutateAsync","isPending","colors","saveColor","includes","Error","previous","error","saving"],"sourceRoot":"../../../../src","sources":["ui/hooks/useAccountColor.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,WAAW,EAAEC,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAEvD,S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U,CAAC,GAAG5C,gBAAgB,CAAC,CAAC;EACrD,MAAM6C,MAAM,GAAGnD,OAAO,CACpB,MAAMyB,qBAAqB,CAACX,IAAI,CAAC,CAAC4B,MAAM,CAAEC,IAAI,IAAKvB,MAAM,GAAGuB,IAAI,CAAC,IAAI,IAAI,CAAC,EAC1E,CAAC7B,IAAI,EAAEM,MAAM,CACf,CAAC;EACD,MAAMgC,SAAS,GAAGtD,WAAW,CAC3B,MAAO6C,IAAkB,IAAK;IAC5B,IAAI,CAACQ,MAAM,CAACE,QAAQ,CAACV,IAAI,CAAC,EAAE,MAAM,IAAIW,KAAK,CAAC,yCAAyC,CAAC;IACtF,MAAMC,QAAQ,GAAGrC,WAAW;IAC5BI,cAAc,CAACqB,IAAI,CAAC;IACpB,IAAI;MACF,MAAMM,WAAW,CAAC;QAChBjC,KAAK,EAAE2B,IAAI;QACX1B,eAAe,EAAE;UACf+B,IAAI,EACFlC,IAAI,EAAEG,eAAe,EAAE+B,IAAI,KAC1BA,IAAI,KAAK,OAAO,IAAIA,IAAI,KAAK,MAAM,GAAGA,IAAI,GAAG,QAAQ,CAAC;UACzD9B,WAAW,EAAEyB;QACf;MACF,CAAC,CAAC;IACJ,CAAC,CAAC,OAAOa,KAAK,EAAE;MACdlC,cAAc,CAACiC,QAAQ,CAAC;MACxB,MAAMC,KAAK;IACb;EACF,CAAC,EACD,CAACL,MAAM,EAAEjC,WAAW,EAAEI,cAAc,EAAE2B,WAAW,EAAEnC,IAAI,EAAEkC,IAAI,CAC/D,CAAC;EACD,OAAO;IAAEG,MAAM;IAAE3C,KAAK,EAAEU,WAAW;IAAEkC,SAAS;IAAEK,MAAM,EAAEP;EAAU,CAAC;AACrE","ignoreList":[]}
|
|
@@ -34,11 +34,13 @@ export declare function entitledAccountColors(user: EntitlementSubject, now?: nu
|
|
|
34
34
|
/**
|
|
35
35
|
* Choose the account's colour: one `updateMe` writes `color` and the portable
|
|
36
36
|
* `themePreference.colorPreset` together (the mode already on the account is
|
|
37
|
-
* kept), the Bloom theme follows at once
|
|
38
|
-
*
|
|
39
|
-
*
|
|
37
|
+
* kept), the Bloom theme follows at once and goes back if the write fails.
|
|
38
|
+
* `colors` is what the picker should list; an app with a stricter rule of its
|
|
39
|
+
* own passes the same `canUse` it gives `useAccountColor`.
|
|
40
40
|
*/
|
|
41
|
-
export declare function useAccountColorSave(
|
|
41
|
+
export declare function useAccountColorSave({ canUse, }?: {
|
|
42
|
+
canUse?: (name: AppColorName) => boolean;
|
|
43
|
+
}): {
|
|
42
44
|
colors: readonly AppColorName[];
|
|
43
45
|
value: AppColorName;
|
|
44
46
|
saveColor: (name: AppColorName) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAccountColor.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/useAccountColor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAW1F,2EAA2E;AAC3E,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,iBAAiB,CAAC,GAAG,IAAI,GAAG,SAAS,GAC/D,YAAY,GAAG,IAAI,CAGrB;AAED,wBAAgB,eAAe,CAAC,EAC9B,MAAM,GACP,GAAE;IACD,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC;CACrC,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"useAccountColor.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/useAccountColor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAW1F,2EAA2E;AAC3E,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,iBAAiB,CAAC,GAAG,IAAI,GAAG,SAAS,GAC/D,YAAY,GAAG,IAAI,CAGrB;AAED,wBAAgB,eAAe,CAAC,EAC9B,MAAM,GACP,GAAE;IACD,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC;CACrC,GAAG,IAAI,CAgBZ;AAED,KAAK,kBAAkB,GAAG,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,iBAAiB,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;AAExF;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,kBAAkB,EACxB,GAAG,GAAE,MAAmB,GACvB,SAAS,YAAY,EAAE,CAYzB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,MAAM,GACP,GAAE;IACD,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC;CACrC,GAAG;IACP,MAAM,EAAE,SAAS,YAAY,EAAE,CAAC;IAChC,KAAK,EAAE,YAAY,CAAC;IACpB,SAAS,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,MAAM,EAAE,OAAO,CAAC;CACjB,CA+BA"}
|
|
@@ -34,11 +34,13 @@ export declare function entitledAccountColors(user: EntitlementSubject, now?: nu
|
|
|
34
34
|
/**
|
|
35
35
|
* Choose the account's colour: one `updateMe` writes `color` and the portable
|
|
36
36
|
* `themePreference.colorPreset` together (the mode already on the account is
|
|
37
|
-
* kept), the Bloom theme follows at once
|
|
38
|
-
*
|
|
39
|
-
*
|
|
37
|
+
* kept), the Bloom theme follows at once and goes back if the write fails.
|
|
38
|
+
* `colors` is what the picker should list; an app with a stricter rule of its
|
|
39
|
+
* own passes the same `canUse` it gives `useAccountColor`.
|
|
40
40
|
*/
|
|
41
|
-
export declare function useAccountColorSave(
|
|
41
|
+
export declare function useAccountColorSave({ canUse, }?: {
|
|
42
|
+
canUse?: (name: AppColorName) => boolean;
|
|
43
|
+
}): {
|
|
42
44
|
colors: readonly AppColorName[];
|
|
43
45
|
value: AppColorName;
|
|
44
46
|
saveColor: (name: AppColorName) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAccountColor.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/useAccountColor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAW1F,2EAA2E;AAC3E,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,iBAAiB,CAAC,GAAG,IAAI,GAAG,SAAS,GAC/D,YAAY,GAAG,IAAI,CAGrB;AAED,wBAAgB,eAAe,CAAC,EAC9B,MAAM,GACP,GAAE;IACD,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC;CACrC,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"useAccountColor.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/useAccountColor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAW1F,2EAA2E;AAC3E,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,iBAAiB,CAAC,GAAG,IAAI,GAAG,SAAS,GAC/D,YAAY,GAAG,IAAI,CAGrB;AAED,wBAAgB,eAAe,CAAC,EAC9B,MAAM,GACP,GAAE;IACD,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC;CACrC,GAAG,IAAI,CAgBZ;AAED,KAAK,kBAAkB,GAAG,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,iBAAiB,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;AAExF;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,kBAAkB,EACxB,GAAG,GAAE,MAAmB,GACvB,SAAS,YAAY,EAAE,CAYzB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,MAAM,GACP,GAAE;IACD,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC;CACrC,GAAG;IACP,MAAM,EAAE,SAAS,YAAY,EAAE,CAAC;IAChC,KAAK,EAAE,YAAY,CAAC;IACpB,SAAS,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,MAAM,EAAE,OAAO,CAAC;CACjB,CA+BA"}
|
package/package.json
CHANGED
|
@@ -43,14 +43,20 @@ export function useAccountColor({
|
|
|
43
43
|
canUse?: (name: AppColorName) => boolean;
|
|
44
44
|
} = {}): void {
|
|
45
45
|
const { isAuthenticated, user } = useAuth();
|
|
46
|
-
const {
|
|
46
|
+
const { setColorPreset } = useBloomTheme();
|
|
47
47
|
const accountColor = resolveAccountColor(user);
|
|
48
48
|
const allowed = accountColor !== null && (canUse?.(accountColor) ?? true);
|
|
49
49
|
|
|
50
|
+
// Follow the ACCOUNT, never fight the theme: this applies when the account's
|
|
51
|
+
// colour (or the app's permission to wear it) changes, exactly like the mode
|
|
52
|
+
// sync in `useAccountTheme`. Re-running on every local preset change would
|
|
53
|
+
// pull a colour just chosen back to the stored one while its save is still in
|
|
54
|
+
// flight, so the root theme (and every surface painted from it, such as an
|
|
55
|
+
// open settings modal) showed the old colour after a pick.
|
|
50
56
|
useEffect(() => {
|
|
51
|
-
if (!isAuthenticated || !accountColor || !allowed
|
|
57
|
+
if (!isAuthenticated || !accountColor || !allowed) return;
|
|
52
58
|
setColorPreset(accountColor);
|
|
53
|
-
}, [isAuthenticated, accountColor, allowed,
|
|
59
|
+
}, [isAuthenticated, accountColor, allowed, setColorPreset]);
|
|
54
60
|
}
|
|
55
61
|
|
|
56
62
|
type EntitlementSubject = Pick<User, 'username' | 'personalization'> | null | undefined;
|
|
@@ -82,11 +88,15 @@ export function entitledAccountColors(
|
|
|
82
88
|
/**
|
|
83
89
|
* Choose the account's colour: one `updateMe` writes `color` and the portable
|
|
84
90
|
* `themePreference.colorPreset` together (the mode already on the account is
|
|
85
|
-
* kept), the Bloom theme follows at once
|
|
86
|
-
*
|
|
87
|
-
*
|
|
91
|
+
* kept), the Bloom theme follows at once and goes back if the write fails.
|
|
92
|
+
* `colors` is what the picker should list; an app with a stricter rule of its
|
|
93
|
+
* own passes the same `canUse` it gives `useAccountColor`.
|
|
88
94
|
*/
|
|
89
|
-
export function useAccountColorSave(
|
|
95
|
+
export function useAccountColorSave({
|
|
96
|
+
canUse,
|
|
97
|
+
}: {
|
|
98
|
+
canUse?: (name: AppColorName) => boolean;
|
|
99
|
+
} = {}): {
|
|
90
100
|
colors: readonly AppColorName[];
|
|
91
101
|
value: AppColorName;
|
|
92
102
|
saveColor: (name: AppColorName) => Promise<void>;
|
|
@@ -95,7 +105,10 @@ export function useAccountColorSave(): {
|
|
|
95
105
|
const { user } = useAuth();
|
|
96
106
|
const { mode, colorPreset, setColorPreset } = useBloomTheme();
|
|
97
107
|
const { mutateAsync, isPending } = useUpdateProfile();
|
|
98
|
-
const colors = useMemo(
|
|
108
|
+
const colors = useMemo(
|
|
109
|
+
() => entitledAccountColors(user).filter((name) => canUse?.(name) ?? true),
|
|
110
|
+
[user, canUse],
|
|
111
|
+
);
|
|
99
112
|
const saveColor = useCallback(
|
|
100
113
|
async (name: AppColorName) => {
|
|
101
114
|
if (!colors.includes(name)) throw new Error('Color is not available for this account');
|