@oxy.so/services 12.8.0 → 12.9.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/client.js +12 -0
- package/lib/commonjs/ui/client.js.map +1 -1
- package/lib/commonjs/ui/hooks/useAccountColor.js +75 -0
- package/lib/commonjs/ui/hooks/useAccountColor.js.map +1 -1
- package/lib/module/ui/client.js +1 -1
- package/lib/module/ui/client.js.map +1 -1
- package/lib/module/ui/hooks/useAccountColor.js +74 -1
- package/lib/module/ui/hooks/useAccountColor.js.map +1 -1
- package/lib/typescript/commonjs/ui/client.d.ts +1 -1
- package/lib/typescript/commonjs/ui/client.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useAccountColor.d.ts +23 -0
- package/lib/typescript/commonjs/ui/hooks/useAccountColor.d.ts.map +1 -1
- package/lib/typescript/module/ui/client.d.ts +1 -1
- package/lib/typescript/module/ui/client.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useAccountColor.d.ts +23 -0
- package/lib/typescript/module/ui/hooks/useAccountColor.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/ui/client.ts +6 -1
- package/src/ui/hooks/useAccountColor.ts +71 -1
|
@@ -117,6 +117,12 @@ Object.defineProperty(exports, "createDeferredProductAnalytics", {
|
|
|
117
117
|
return _productAnalytics.createDeferredProductAnalytics;
|
|
118
118
|
}
|
|
119
119
|
});
|
|
120
|
+
Object.defineProperty(exports, "entitledAccountColors", {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get: function () {
|
|
123
|
+
return _useAccountColor.entitledAccountColors;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
120
126
|
Object.defineProperty(exports, "extractErrorMessage", {
|
|
121
127
|
enumerable: true,
|
|
122
128
|
get: function () {
|
|
@@ -243,6 +249,12 @@ Object.defineProperty(exports, "useAccountColor", {
|
|
|
243
249
|
return _useAccountColor.useAccountColor;
|
|
244
250
|
}
|
|
245
251
|
});
|
|
252
|
+
Object.defineProperty(exports, "useAccountColorSave", {
|
|
253
|
+
enumerable: true,
|
|
254
|
+
get: function () {
|
|
255
|
+
return _useAccountColor.useAccountColorSave;
|
|
256
|
+
}
|
|
257
|
+
});
|
|
246
258
|
Object.defineProperty(exports, "useAppAssertion", {
|
|
247
259
|
enumerable: true,
|
|
248
260
|
get: function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["require","_OxyProvider","_interopRequireDefault","_OxySignInButton","_OxyAuthPrompt","_LogoIcon","_LogoText","_FollowButton","_FollowTargetButton","_followLabels","_ProfileButton","_PeableButton","_OxyPayButton","_OxyContext","_useAuth","_useAccountColor","_AppAssertionContext","_productAnalytics","_useFollow","_useFollowTarget","_useSupervision","_useAccountQueries","_useStorage","_useOxyEvent","_useAccountMutations","_useFileDownloadUrl","_useMutationStatus","_useOnlineStatus","_useDisplayCurrency","_useDisplayPrice","_DisplayCurrencySelector","_followRules","_queryKeys","_userCache","_authStore","_errorHandlers","e","__esModule","default"],"sourceRoot":"../../../src","sources":["ui/client.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["require","_OxyProvider","_interopRequireDefault","_OxySignInButton","_OxyAuthPrompt","_LogoIcon","_LogoText","_FollowButton","_FollowTargetButton","_followLabels","_ProfileButton","_PeableButton","_OxyPayButton","_OxyContext","_useAuth","_useAccountColor","_AppAssertionContext","_productAnalytics","_useFollow","_useFollowTarget","_useSupervision","_useAccountQueries","_useStorage","_useOxyEvent","_useAccountMutations","_useFileDownloadUrl","_useMutationStatus","_useOnlineStatus","_useDisplayCurrency","_useDisplayPrice","_DisplayCurrencySelector","_followRules","_queryKeys","_userCache","_authStore","_errorHandlers","e","__esModule","default"],"sourceRoot":"../../../src","sources":["ui/client.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AA,GAAAxB,OAAA;AAKA,IAAAyB,mBAAA,GAAAzB,OAAA;AACA,IAAA0B,kBAAA,GAAA1B,OAAA;AAEA,IAAA2B,gBAAA,GAAA3B,OAAA;AACA,IAAA4B,mBAAA,GAAA5B,OAAA;AACA,IAAA6B,gBAAA,GAAA7B,OAAA;AACA,IAAA8B,wBAAA,GAAA9B,OAAA;AAOA,IAAA+B,YAAA,GAAA/B,OAAA;AAQA,IAAAgC,UAAA,GAAAhC,OAAA;AAaA,IAAAiC,UAAA,GAAAjC,OAAA;AAcA,IAAAkC,UAAA,GAAAlC,OAAA;AAGA,IAAAmC,cAAA,GAAAnC,OAAA;AAK+B,SAAAE,uBAAAkC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
|
|
@@ -3,11 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.entitledAccountColors = entitledAccountColors;
|
|
6
7
|
exports.resolveAccountColor = resolveAccountColor;
|
|
7
8
|
exports.useAccountColor = useAccountColor;
|
|
9
|
+
exports.useAccountColorSave = useAccountColorSave;
|
|
8
10
|
var _react = require("react");
|
|
9
11
|
var _theme = require("@oxy.so/bloom/theme");
|
|
12
|
+
var _client = require("@oxy.so/contracts/client");
|
|
10
13
|
var _useAuth = require("./useAuth.js");
|
|
14
|
+
var _useAccountMutations = require("./mutations/useAccountMutations.js");
|
|
11
15
|
/**
|
|
12
16
|
* useAccountColor
|
|
13
17
|
*
|
|
@@ -53,4 +57,75 @@ function useAccountColor({
|
|
|
53
57
|
setColorPreset(accountColor);
|
|
54
58
|
}, [isAuthenticated, accountColor, allowed, colorPreset, setColorPreset]);
|
|
55
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* The presets this account may choose, from the contract's own gate table: a
|
|
62
|
+
* free preset, the one named after the account's handle (`oxy`, `faircoin`), and
|
|
63
|
+
* `mono` while the account holds the benefit that grants it. The API enforces
|
|
64
|
+
* the same rule when it stores the value; this only keeps a picker from offering
|
|
65
|
+
* what it would refuse.
|
|
66
|
+
*/
|
|
67
|
+
function entitledAccountColors(user, now = Date.now()) {
|
|
68
|
+
const handle = user?.username?.trim().toLowerCase();
|
|
69
|
+
const grant = user?.personalization?.mentionMono;
|
|
70
|
+
const expires = grant?.expiresAt === null ? Infinity : Date.parse(grant?.expiresAt ?? '');
|
|
71
|
+
const hasMono = grant?.allowed === true && expires > now;
|
|
72
|
+
const supported = new Set(_client.USER_PROFILE_COLOR_PRESETS);
|
|
73
|
+
return _client.USER_PROFILE_COLORS.filter(({
|
|
74
|
+
name,
|
|
75
|
+
gate
|
|
76
|
+
}) => {
|
|
77
|
+
if (!supported.has(name) || !isAppColorName(name)) return false;
|
|
78
|
+
if (gate === null) return true;
|
|
79
|
+
if (gate === 'handle') return name === handle;
|
|
80
|
+
return name === 'mono' && hasMono;
|
|
81
|
+
}).map(({
|
|
82
|
+
name
|
|
83
|
+
}) => name);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Choose the account's colour: one `updateMe` writes `color` and the portable
|
|
88
|
+
* `themePreference.colorPreset` together (the mode already on the account is
|
|
89
|
+
* kept), the Bloom theme follows at once, and the session user is updated
|
|
90
|
+
* optimistically so `useAccountColor` agrees with it. `colors` is what the
|
|
91
|
+
* picker should list.
|
|
92
|
+
*/
|
|
93
|
+
function useAccountColorSave() {
|
|
94
|
+
const {
|
|
95
|
+
user
|
|
96
|
+
} = (0, _useAuth.useAuth)();
|
|
97
|
+
const {
|
|
98
|
+
mode,
|
|
99
|
+
colorPreset,
|
|
100
|
+
setColorPreset
|
|
101
|
+
} = (0, _theme.useBloomTheme)();
|
|
102
|
+
const {
|
|
103
|
+
mutateAsync,
|
|
104
|
+
isPending
|
|
105
|
+
} = (0, _useAccountMutations.useUpdateProfile)();
|
|
106
|
+
const colors = (0, _react.useMemo)(() => entitledAccountColors(user), [user]);
|
|
107
|
+
const saveColor = (0, _react.useCallback)(async name => {
|
|
108
|
+
if (!colors.includes(name)) throw new Error('Color is not available for this account');
|
|
109
|
+
const previous = colorPreset;
|
|
110
|
+
setColorPreset(name);
|
|
111
|
+
try {
|
|
112
|
+
await mutateAsync({
|
|
113
|
+
color: name,
|
|
114
|
+
themePreference: {
|
|
115
|
+
mode: user?.themePreference?.mode ?? (mode === 'light' || mode === 'dark' ? mode : 'system'),
|
|
116
|
+
colorPreset: name
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
} catch (error) {
|
|
120
|
+
setColorPreset(previous);
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
}, [colors, colorPreset, setColorPreset, mutateAsync, user, mode]);
|
|
124
|
+
return {
|
|
125
|
+
colors,
|
|
126
|
+
value: colorPreset,
|
|
127
|
+
saveColor,
|
|
128
|
+
saving: isPending
|
|
129
|
+
};
|
|
130
|
+
}
|
|
56
131
|
//# sourceMappingURL=useAccountColor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_theme","_useAuth","isAppColorName","value","Object","prototype","hasOwnProperty","call","APP_COLOR_PRESETS","resolveAccountColor","user","stored","color","themePreference","colorPreset","useAccountColor","canUse","isAuthenticated","useAuth","setColorPreset","useBloomTheme","accountColor","allowed","useEffect"],"sourceRoot":"../../../../src","sources":["ui/hooks/useAccountColor.ts"],"mappings":"
|
|
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;IAAEJ,WAAW;IAAEK;EAAe,CAAC,GAAG,IAAAC,oBAAa,EAAC,CAAC;EACvD,MAAMC,YAAY,GAAGZ,mBAAmB,CAACC,IAAI,CAAC;EAC9C,MAAMY,OAAO,GAAGD,YAAY,KAAK,IAAI,KAAKL,MAAM,GAAGK,YAAY,CAAC,IAAI,IAAI,CAAC;EAEzE,IAAAE,gBAAS,EAAC,MAAM;IACd,IAAI,CAACN,eAAe,IAAI,CAACI,YAAY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ui/client.js
CHANGED
|
@@ -37,7 +37,7 @@ export { useOxy, useOptionalOxy, OxyProviderMissingError } from "./context/OxyCo
|
|
|
37
37
|
|
|
38
38
|
// Hooks
|
|
39
39
|
export { useAuth } from "./hooks/useAuth.js";
|
|
40
|
-
export { useAccountColor, resolveAccountColor } from "./hooks/useAccountColor.js";
|
|
40
|
+
export { useAccountColor, useAccountColorSave, resolveAccountColor, entitledAccountColors } from "./hooks/useAccountColor.js";
|
|
41
41
|
// This app's Oxy-signed assertion of which app it is (ADR 0045), for an SDK
|
|
42
42
|
// that attaches it to its own requests without pulling in the account screens.
|
|
43
43
|
export { useAppAssertion, AppAssertionProviderMissingError } from "./appAssertion/AppAssertionContext.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["default","OxyProvider","OxySignInButton","OxyAuthPrompt","LogoIcon","LogoText","FollowButton","FollowTargetButton","useFollowErrorMessage","ProfileButton","PeableButton","OxyPayButton","useOxy","useOptionalOxy","OxyProviderMissingError","useAuth","useAccountColor","resolveAccountColor","useAppAssertion","AppAssertionProviderMissingError","createDeferredProductAnalytics","useFollow","useFollowerCounts","useSeedFollowStatuses","useFollowTarget","useSupervision","supervisionQueryKeys","useUserProfile","useUserProfiles","useCurrentUser","useUserById","useUserByUsername","useStorage","useOxyEvent","useUpdateProfile","useUploadAvatar","useUploadFile","useFileDownloadUrl","useMutationStatus","useOnlineStatus","useDisplayCurrency","useDisplayPrice","DisplayCurrencySelector","buildFollowMenuItems","resolveFollowPrimaryAction","FOLLOW_ACTION_LEAVES_ACTIVE","queryKeys","invalidateAccountQueries","invalidateUserQueries","invalidateSessionQueries","invalidateDeviceQueries","invalidatePrivacyQueries","invalidateSecurityQueries","invalidateStorageQueries","invalidatePaymentsQueries","invalidateConnectedAppsQueries","invalidateAuthMethodsQueries","upsertCachedUser","upsertCachedUsers","CLEARABLE_USER_FIELDS","clearedFieldsFromProfileUpdate","clearedFieldsFromAccountUpdate","useAuthStore","handleAuthError","isInvalidSessionError","isTimeoutOrNetworkError","extractErrorMessage"],"sourceRoot":"../../../src","sources":["ui/client.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,OAAO,wBAAqB;;AAE5B;AACA,SAASA,OAAO,IAAIC,WAAW,QAAQ,6BAA0B;AACjE,SAASD,OAAO,IAAIE,eAAe,QAAQ,iCAA8B;AACzE,SAASF,OAAO,IAAIG,aAAa,QAAQ,+BAA4B;AAErE,SAASC,QAAQ,QAAQ,+BAA4B;AACrD,SAASC,QAAQ,QAAQ,+BAA4B;AACrD,SAASL,OAAO,IAAIM,YAAY,QAAQ,8BAA2B;AAMnE,SAASC,kBAAkB,QAAQ,oCAAiC;AAGpE,SAASC,qBAAqB,QAAQ,8BAA2B;AAEjE,SAASR,OAAO,IAAIS,aAAa,QAAQ,+BAA4B;AAErE,SAAST,OAAO,IAAIU,YAAY,QAAQ,8BAA2B;AAEnE;AACA,SAASV,OAAO,IAAIW,YAAY,QAAQ,8BAA2B;AACnE;;AAGA;AACA,SAASC,MAAM,EAAEC,cAAc,EAAEC,uBAAuB,QAAQ,yBAAsB;;AAEtF;AACA,SAASC,OAAO,QAAQ,oBAAiB;AACzC,
|
|
1
|
+
{"version":3,"names":["default","OxyProvider","OxySignInButton","OxyAuthPrompt","LogoIcon","LogoText","FollowButton","FollowTargetButton","useFollowErrorMessage","ProfileButton","PeableButton","OxyPayButton","useOxy","useOptionalOxy","OxyProviderMissingError","useAuth","useAccountColor","useAccountColorSave","resolveAccountColor","entitledAccountColors","useAppAssertion","AppAssertionProviderMissingError","createDeferredProductAnalytics","useFollow","useFollowerCounts","useSeedFollowStatuses","useFollowTarget","useSupervision","supervisionQueryKeys","useUserProfile","useUserProfiles","useCurrentUser","useUserById","useUserByUsername","useStorage","useOxyEvent","useUpdateProfile","useUploadAvatar","useUploadFile","useFileDownloadUrl","useMutationStatus","useOnlineStatus","useDisplayCurrency","useDisplayPrice","DisplayCurrencySelector","buildFollowMenuItems","resolveFollowPrimaryAction","FOLLOW_ACTION_LEAVES_ACTIVE","queryKeys","invalidateAccountQueries","invalidateUserQueries","invalidateSessionQueries","invalidateDeviceQueries","invalidatePrivacyQueries","invalidateSecurityQueries","invalidateStorageQueries","invalidatePaymentsQueries","invalidateConnectedAppsQueries","invalidateAuthMethodsQueries","upsertCachedUser","upsertCachedUsers","CLEARABLE_USER_FIELDS","clearedFieldsFromProfileUpdate","clearedFieldsFromAccountUpdate","useAuthStore","handleAuthError","isInvalidSessionError","isTimeoutOrNetworkError","extractErrorMessage"],"sourceRoot":"../../../src","sources":["ui/client.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,OAAO,wBAAqB;;AAE5B;AACA,SAASA,OAAO,IAAIC,WAAW,QAAQ,6BAA0B;AACjE,SAASD,OAAO,IAAIE,eAAe,QAAQ,iCAA8B;AACzE,SAASF,OAAO,IAAIG,aAAa,QAAQ,+BAA4B;AAErE,SAASC,QAAQ,QAAQ,+BAA4B;AACrD,SAASC,QAAQ,QAAQ,+BAA4B;AACrD,SAASL,OAAO,IAAIM,YAAY,QAAQ,8BAA2B;AAMnE,SAASC,kBAAkB,QAAQ,oCAAiC;AAGpE,SAASC,qBAAqB,QAAQ,8BAA2B;AAEjE,SAASR,OAAO,IAAIS,aAAa,QAAQ,+BAA4B;AAErE,SAAST,OAAO,IAAIU,YAAY,QAAQ,8BAA2B;AAEnE;AACA,SAASV,OAAO,IAAIW,YAAY,QAAQ,8BAA2B;AACnE;;AAGA;AACA,SAASC,MAAM,EAAEC,cAAc,EAAEC,uBAAuB,QAAQ,yBAAsB;;AAEtF;AACA,SAASC,OAAO,QAAQ,oBAAiB;AACzC,SACEC,eAAe,EACfC,mBAAmB,EACnBC,mBAAmB,EACnBC,qBAAqB,QAChB,4BAAyB;AAChC;AACA;AACA,SACEC,eAAe,EACfC,gCAAgC,QAC3B,uCAAoC;AAI3C,SAASC,8BAA8B,QAAQ,iCAA8B;AAE7E,SAASC,SAAS,EAAEC,iBAAiB,EAAEC,qBAAqB,QAAQ,sBAAmB;AACvF,SAASC,eAAe,QAAQ,4BAAyB;AACzD,SAASC,cAAc,EAAEC,oBAAoB,QAAQ,mCAAgC;AAErF,SACEC,cAAc,EACdC,eAAe,EACfC,cAAc,EACdC,WAAW,EACXC,iBAAiB,QACZ,sCAAmC;AAC1C,SAASC,UAAU,QAAQ,uBAAoB;AAC/C;AACA;AACA,SAASC,WAAW,QAAQ,wBAAqB;AACjD;AACA;AACA;AACA;AACA,SACEC,gBAAgB,EAChBC,eAAe,EACfC,aAAa,QACR,0CAAuC;AAC9C,SAASC,kBAAkB,QAAQ,+BAA4B;AAC/D,SAASC,iBAAiB,QAAQ,8BAA2B;AAE7D,SAASC,eAAe,QAAQ,4BAAyB;AACzD,SAASC,kBAAkB,QAAQ,+BAA4B;AAC/D,SAASC,eAAe,QAAQ,4BAAyB;AACzD,SAASC,uBAAuB,QAAQ,yCAAsC;AAG9E;AACA;;AAEA;AACA,SACEC,oBAAoB,EACpBC,0BAA0B,EAC1BC,2BAA2B,QACtB,6BAA0B;AAGjC;AACA,SACEC,SAAS,EACTC,wBAAwB,EACxBC,qBAAqB,EACrBC,wBAAwB,EACxBC,uBAAuB,EACvBC,wBAAwB,EACxBC,yBAAyB,EACzBC,wBAAwB,EACxBC,yBAAyB,EACzBC,8BAA8B,EAC9BC,4BAA4B,QACvB,8BAA2B;AAClC,SACEC,gBAAgB,EAChBC,iBAAiB,EACjBC,qBAAqB,EACrBC,8BAA8B,EAC9BC,8BAA8B,QACzB,8BAA2B;AAOlC;AACA,SAASC,YAAY,QAAQ,uBAAoB;;AAEjD;AACA,SACEC,eAAe,EACfC,qBAAqB,EACrBC,uBAAuB,EACvBC,mBAAmB,QACd,0BAAuB","ignoreList":[]}
|
|
@@ -18,9 +18,11 @@
|
|
|
18
18
|
* default instead of a colour the viewer is not entitled to.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
import { useEffect } from 'react';
|
|
21
|
+
import { useCallback, useEffect, useMemo } from 'react';
|
|
22
22
|
import { APP_COLOR_PRESETS, useBloomTheme } from '@oxy.so/bloom/theme';
|
|
23
|
+
import { USER_PROFILE_COLORS, USER_PROFILE_COLOR_PRESETS } from '@oxy.so/contracts/client';
|
|
23
24
|
import { useAuth } from "./useAuth.js";
|
|
25
|
+
import { useUpdateProfile } from "./mutations/useAccountMutations.js";
|
|
24
26
|
function isAppColorName(value) {
|
|
25
27
|
return typeof value === 'string' && Object.prototype.hasOwnProperty.call(APP_COLOR_PRESETS, value);
|
|
26
28
|
}
|
|
@@ -48,4 +50,75 @@ export function useAccountColor({
|
|
|
48
50
|
setColorPreset(accountColor);
|
|
49
51
|
}, [isAuthenticated, accountColor, allowed, colorPreset, setColorPreset]);
|
|
50
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* The presets this account may choose, from the contract's own gate table: a
|
|
55
|
+
* free preset, the one named after the account's handle (`oxy`, `faircoin`), and
|
|
56
|
+
* `mono` while the account holds the benefit that grants it. The API enforces
|
|
57
|
+
* the same rule when it stores the value; this only keeps a picker from offering
|
|
58
|
+
* what it would refuse.
|
|
59
|
+
*/
|
|
60
|
+
export function entitledAccountColors(user, now = Date.now()) {
|
|
61
|
+
const handle = user?.username?.trim().toLowerCase();
|
|
62
|
+
const grant = user?.personalization?.mentionMono;
|
|
63
|
+
const expires = grant?.expiresAt === null ? Infinity : Date.parse(grant?.expiresAt ?? '');
|
|
64
|
+
const hasMono = grant?.allowed === true && expires > now;
|
|
65
|
+
const supported = new Set(USER_PROFILE_COLOR_PRESETS);
|
|
66
|
+
return USER_PROFILE_COLORS.filter(({
|
|
67
|
+
name,
|
|
68
|
+
gate
|
|
69
|
+
}) => {
|
|
70
|
+
if (!supported.has(name) || !isAppColorName(name)) return false;
|
|
71
|
+
if (gate === null) return true;
|
|
72
|
+
if (gate === 'handle') return name === handle;
|
|
73
|
+
return name === 'mono' && hasMono;
|
|
74
|
+
}).map(({
|
|
75
|
+
name
|
|
76
|
+
}) => name);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Choose the account's colour: one `updateMe` writes `color` and the portable
|
|
81
|
+
* `themePreference.colorPreset` together (the mode already on the account is
|
|
82
|
+
* kept), the Bloom theme follows at once, and the session user is updated
|
|
83
|
+
* optimistically so `useAccountColor` agrees with it. `colors` is what the
|
|
84
|
+
* picker should list.
|
|
85
|
+
*/
|
|
86
|
+
export function useAccountColorSave() {
|
|
87
|
+
const {
|
|
88
|
+
user
|
|
89
|
+
} = useAuth();
|
|
90
|
+
const {
|
|
91
|
+
mode,
|
|
92
|
+
colorPreset,
|
|
93
|
+
setColorPreset
|
|
94
|
+
} = useBloomTheme();
|
|
95
|
+
const {
|
|
96
|
+
mutateAsync,
|
|
97
|
+
isPending
|
|
98
|
+
} = useUpdateProfile();
|
|
99
|
+
const colors = useMemo(() => entitledAccountColors(user), [user]);
|
|
100
|
+
const saveColor = useCallback(async name => {
|
|
101
|
+
if (!colors.includes(name)) throw new Error('Color is not available for this account');
|
|
102
|
+
const previous = colorPreset;
|
|
103
|
+
setColorPreset(name);
|
|
104
|
+
try {
|
|
105
|
+
await mutateAsync({
|
|
106
|
+
color: name,
|
|
107
|
+
themePreference: {
|
|
108
|
+
mode: user?.themePreference?.mode ?? (mode === 'light' || mode === 'dark' ? mode : 'system'),
|
|
109
|
+
colorPreset: name
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
} catch (error) {
|
|
113
|
+
setColorPreset(previous);
|
|
114
|
+
throw error;
|
|
115
|
+
}
|
|
116
|
+
}, [colors, colorPreset, setColorPreset, mutateAsync, user, mode]);
|
|
117
|
+
return {
|
|
118
|
+
colors,
|
|
119
|
+
value: colorPreset,
|
|
120
|
+
saveColor,
|
|
121
|
+
saving: isPending
|
|
122
|
+
};
|
|
123
|
+
}
|
|
51
124
|
//# sourceMappingURL=useAccountColor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","APP_COLOR_PRESETS","useBloomTheme","useAuth","isAppColorName","value","Object","prototype","hasOwnProperty","call","resolveAccountColor","user","stored","color","themePreference","colorPreset","useAccountColor","canUse","isAuthenticated","setColorPreset","accountColor","allowed"],"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,SAAS,QAAQ,OAAO;
|
|
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,CAAC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K,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":[]}
|
|
@@ -35,7 +35,7 @@ export { default as OxyPayButton } from './components/OxyPayButton';
|
|
|
35
35
|
export type { OxyPayButtonProps } from './components/OxyPayButton';
|
|
36
36
|
export { useOxy, useOptionalOxy, OxyProviderMissingError } from './context/OxyContext';
|
|
37
37
|
export { useAuth } from './hooks/useAuth';
|
|
38
|
-
export { useAccountColor, resolveAccountColor } from './hooks/useAccountColor';
|
|
38
|
+
export { useAccountColor, useAccountColorSave, resolveAccountColor, entitledAccountColors, } from './hooks/useAccountColor';
|
|
39
39
|
export { useAppAssertion, AppAssertionProviderMissingError, } from './appAssertion/AppAssertionContext';
|
|
40
40
|
export type { UseAppAssertionResult } from './appAssertion/AppAssertionContext';
|
|
41
41
|
export type { AppAssertionSnapshot, AppAssertionStatus } from './appAssertion/appAssertionManager';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","s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AAsB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -22,4 +22,27 @@ export declare function resolveAccountColor(user: Pick<User, 'color' | 'themePre
|
|
|
22
22
|
export declare function useAccountColor({ canUse, }?: {
|
|
23
23
|
canUse?: (name: AppColorName) => boolean;
|
|
24
24
|
}): void;
|
|
25
|
+
type EntitlementSubject = Pick<User, 'username' | 'personalization'> | null | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* The presets this account may choose, from the contract's own gate table: a
|
|
28
|
+
* free preset, the one named after the account's handle (`oxy`, `faircoin`), and
|
|
29
|
+
* `mono` while the account holds the benefit that grants it. The API enforces
|
|
30
|
+
* the same rule when it stores the value; this only keeps a picker from offering
|
|
31
|
+
* what it would refuse.
|
|
32
|
+
*/
|
|
33
|
+
export declare function entitledAccountColors(user: EntitlementSubject, now?: number): readonly AppColorName[];
|
|
34
|
+
/**
|
|
35
|
+
* Choose the account's colour: one `updateMe` writes `color` and the portable
|
|
36
|
+
* `themePreference.colorPreset` together (the mode already on the account is
|
|
37
|
+
* kept), the Bloom theme follows at once, and the session user is updated
|
|
38
|
+
* optimistically so `useAccountColor` agrees with it. `colors` is what the
|
|
39
|
+
* picker should list.
|
|
40
|
+
*/
|
|
41
|
+
export declare function useAccountColorSave(): {
|
|
42
|
+
colors: readonly AppColorName[];
|
|
43
|
+
value: AppColorName;
|
|
44
|
+
saveColor: (name: AppColorName) => Promise<void>;
|
|
45
|
+
saving: boolean;
|
|
46
|
+
};
|
|
47
|
+
export {};
|
|
25
48
|
//# sourceMappingURL=useAccountColor.d.ts.map
|
|
@@ -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;
|
|
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,CAUZ;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,IAAI;IACrC,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,CA4BA"}
|
|
@@ -35,7 +35,7 @@ export { default as OxyPayButton } from './components/OxyPayButton.js';
|
|
|
35
35
|
export type { OxyPayButtonProps } from './components/OxyPayButton.js';
|
|
36
36
|
export { useOxy, useOptionalOxy, OxyProviderMissingError } from './context/OxyContext.js';
|
|
37
37
|
export { useAuth } from './hooks/useAuth.js';
|
|
38
|
-
export { useAccountColor, resolveAccountColor } from './hooks/useAccountColor.js';
|
|
38
|
+
export { useAccountColor, useAccountColorSave, resolveAccountColor, entitledAccountColors, } from './hooks/useAccountColor.js';
|
|
39
39
|
export { useAppAssertion, AppAssertionProviderMissingError, } from './appAssertion/AppAssertionContext.js';
|
|
40
40
|
export type { UseAppAssertionResult } from './appAssertion/AppAssertionContext.js';
|
|
41
41
|
export type { AppAssertionSnapshot, AppAssertionStatus } from './appAssertion/appAssertionManager.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/ui/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,wBAAqB,CAAC;AAG7B,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,6BAA0B,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,iCAA8B,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,+BAA4B,CAAC;AACtE,YAAY,EAAE,kBAAkB,EAAE,MAAM,+BAA4B,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA4B,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA4B,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,8BAA2B,CAAC;AACpE,YAAY,EACV,iBAAiB,EACjB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,8BAA2B,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAiC,CAAC;AACrE,YAAY,EAAE,uBAAuB,EAAE,MAAM,oCAAiC,CAAC;AAC/E,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,8BAA2B,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA2B,CAAC;AAClE,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAsB,CAAC;AAC5D,OAAO,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C;AACnC,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,8BAA8B,EAC9B,8BAA8B,GAC/B,MAAM,8BAA2B,CAAC;AACnC,YAAY,EACV,aAAa,EACb,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,8BAA2B,CAAC;AAGnC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAoB,CAAC;AAGlD,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,0BAAuB,CAAC;AAC/B,YAAY,EAAE,sBAAsB,EAAE,MAAM,0BAAuB,CAAC"}
|
|
@@ -22,4 +22,27 @@ export declare function resolveAccountColor(user: Pick<User, 'color' | 'themePre
|
|
|
22
22
|
export declare function useAccountColor({ canUse, }?: {
|
|
23
23
|
canUse?: (name: AppColorName) => boolean;
|
|
24
24
|
}): void;
|
|
25
|
+
type EntitlementSubject = Pick<User, 'username' | 'personalization'> | null | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* The presets this account may choose, from the contract's own gate table: a
|
|
28
|
+
* free preset, the one named after the account's handle (`oxy`, `faircoin`), and
|
|
29
|
+
* `mono` while the account holds the benefit that grants it. The API enforces
|
|
30
|
+
* the same rule when it stores the value; this only keeps a picker from offering
|
|
31
|
+
* what it would refuse.
|
|
32
|
+
*/
|
|
33
|
+
export declare function entitledAccountColors(user: EntitlementSubject, now?: number): readonly AppColorName[];
|
|
34
|
+
/**
|
|
35
|
+
* Choose the account's colour: one `updateMe` writes `color` and the portable
|
|
36
|
+
* `themePreference.colorPreset` together (the mode already on the account is
|
|
37
|
+
* kept), the Bloom theme follows at once, and the session user is updated
|
|
38
|
+
* optimistically so `useAccountColor` agrees with it. `colors` is what the
|
|
39
|
+
* picker should list.
|
|
40
|
+
*/
|
|
41
|
+
export declare function useAccountColorSave(): {
|
|
42
|
+
colors: readonly AppColorName[];
|
|
43
|
+
value: AppColorName;
|
|
44
|
+
saveColor: (name: AppColorName) => Promise<void>;
|
|
45
|
+
saving: boolean;
|
|
46
|
+
};
|
|
47
|
+
export {};
|
|
25
48
|
//# sourceMappingURL=useAccountColor.d.ts.map
|
|
@@ -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;
|
|
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,CAUZ;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,IAAI;IACrC,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,CA4BA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxy.so/services",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.9.0",
|
|
4
4
|
"description": "OxyHQ Expo/React Native SDK — UI components, screens, and native features",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
"prepublishOnly": "node ../../scripts/assert-bun-publish.mjs && bun run typescript && bun run test && bun run build"
|
|
152
152
|
},
|
|
153
153
|
"dependencies": {
|
|
154
|
-
"@oxy.so/contracts": "^5.
|
|
154
|
+
"@oxy.so/contracts": "^5.6.0",
|
|
155
155
|
"color": "^5.0.3",
|
|
156
156
|
"@peable.to/sdk": "0.4.1"
|
|
157
157
|
},
|
|
@@ -160,7 +160,7 @@
|
|
|
160
160
|
"@commitlint/config-conventional": "^21.2.0",
|
|
161
161
|
"@expo/app-integrity": "~58.0.2",
|
|
162
162
|
"@expo/vector-icons": "^15.0.3",
|
|
163
|
-
"@oxy.so/core": "6.11.
|
|
163
|
+
"@oxy.so/core": "6.11.1",
|
|
164
164
|
"@react-native-async-storage/async-storage": "^2.0.0",
|
|
165
165
|
"@react-native-community/netinfo": "^12.0.1",
|
|
166
166
|
"@react-native/babel-preset": "^0.88.0",
|
package/src/ui/client.ts
CHANGED
|
@@ -47,7 +47,12 @@ export { useOxy, useOptionalOxy, OxyProviderMissingError } from './context/OxyCo
|
|
|
47
47
|
|
|
48
48
|
// Hooks
|
|
49
49
|
export { useAuth } from './hooks/useAuth';
|
|
50
|
-
export {
|
|
50
|
+
export {
|
|
51
|
+
useAccountColor,
|
|
52
|
+
useAccountColorSave,
|
|
53
|
+
resolveAccountColor,
|
|
54
|
+
entitledAccountColors,
|
|
55
|
+
} from './hooks/useAccountColor';
|
|
51
56
|
// This app's Oxy-signed assertion of which app it is (ADR 0045), for an SDK
|
|
52
57
|
// that attaches it to its own requests without pulling in the account screens.
|
|
53
58
|
export {
|
|
@@ -16,10 +16,12 @@
|
|
|
16
16
|
* default instead of a colour the viewer is not entitled to.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import { useEffect } from 'react';
|
|
19
|
+
import { useCallback, useEffect, useMemo } from 'react';
|
|
20
20
|
import type { User } from '@oxy.so/core';
|
|
21
21
|
import { APP_COLOR_PRESETS, useBloomTheme, type AppColorName } from '@oxy.so/bloom/theme';
|
|
22
|
+
import { USER_PROFILE_COLORS, USER_PROFILE_COLOR_PRESETS } from '@oxy.so/contracts/client';
|
|
22
23
|
import { useAuth } from './useAuth';
|
|
24
|
+
import { useUpdateProfile } from './mutations/useAccountMutations';
|
|
23
25
|
|
|
24
26
|
function isAppColorName(value: unknown): value is AppColorName {
|
|
25
27
|
return (
|
|
@@ -50,3 +52,71 @@ export function useAccountColor({
|
|
|
50
52
|
setColorPreset(accountColor);
|
|
51
53
|
}, [isAuthenticated, accountColor, allowed, colorPreset, setColorPreset]);
|
|
52
54
|
}
|
|
55
|
+
|
|
56
|
+
type EntitlementSubject = Pick<User, 'username' | 'personalization'> | null | undefined;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The presets this account may choose, from the contract's own gate table: a
|
|
60
|
+
* free preset, the one named after the account's handle (`oxy`, `faircoin`), and
|
|
61
|
+
* `mono` while the account holds the benefit that grants it. The API enforces
|
|
62
|
+
* the same rule when it stores the value; this only keeps a picker from offering
|
|
63
|
+
* what it would refuse.
|
|
64
|
+
*/
|
|
65
|
+
export function entitledAccountColors(
|
|
66
|
+
user: EntitlementSubject,
|
|
67
|
+
now: number = Date.now(),
|
|
68
|
+
): readonly AppColorName[] {
|
|
69
|
+
const handle = user?.username?.trim().toLowerCase();
|
|
70
|
+
const grant = user?.personalization?.mentionMono;
|
|
71
|
+
const expires = grant?.expiresAt === null ? Infinity : Date.parse(grant?.expiresAt ?? '');
|
|
72
|
+
const hasMono = grant?.allowed === true && expires > now;
|
|
73
|
+
const supported = new Set<string>(USER_PROFILE_COLOR_PRESETS);
|
|
74
|
+
return USER_PROFILE_COLORS.filter(({ name, gate }) => {
|
|
75
|
+
if (!supported.has(name) || !isAppColorName(name)) return false;
|
|
76
|
+
if (gate === null) return true;
|
|
77
|
+
if (gate === 'handle') return name === handle;
|
|
78
|
+
return name === 'mono' && hasMono;
|
|
79
|
+
}).map(({ name }) => name as AppColorName);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Choose the account's colour: one `updateMe` writes `color` and the portable
|
|
84
|
+
* `themePreference.colorPreset` together (the mode already on the account is
|
|
85
|
+
* kept), the Bloom theme follows at once, and the session user is updated
|
|
86
|
+
* optimistically so `useAccountColor` agrees with it. `colors` is what the
|
|
87
|
+
* picker should list.
|
|
88
|
+
*/
|
|
89
|
+
export function useAccountColorSave(): {
|
|
90
|
+
colors: readonly AppColorName[];
|
|
91
|
+
value: AppColorName;
|
|
92
|
+
saveColor: (name: AppColorName) => Promise<void>;
|
|
93
|
+
saving: boolean;
|
|
94
|
+
} {
|
|
95
|
+
const { user } = useAuth();
|
|
96
|
+
const { mode, colorPreset, setColorPreset } = useBloomTheme();
|
|
97
|
+
const { mutateAsync, isPending } = useUpdateProfile();
|
|
98
|
+
const colors = useMemo(() => entitledAccountColors(user), [user]);
|
|
99
|
+
const saveColor = useCallback(
|
|
100
|
+
async (name: AppColorName) => {
|
|
101
|
+
if (!colors.includes(name)) throw new Error('Color is not available for this account');
|
|
102
|
+
const previous = colorPreset;
|
|
103
|
+
setColorPreset(name);
|
|
104
|
+
try {
|
|
105
|
+
await mutateAsync({
|
|
106
|
+
color: name,
|
|
107
|
+
themePreference: {
|
|
108
|
+
mode:
|
|
109
|
+
user?.themePreference?.mode ??
|
|
110
|
+
(mode === 'light' || mode === 'dark' ? mode : 'system'),
|
|
111
|
+
colorPreset: name,
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
} catch (error) {
|
|
115
|
+
setColorPreset(previous);
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
[colors, colorPreset, setColorPreset, mutateAsync, user, mode],
|
|
120
|
+
);
|
|
121
|
+
return { colors, value: colorPreset, saveColor, saving: isPending };
|
|
122
|
+
}
|