@oxyhq/services 5.18.2 → 5.18.4
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/core/mixins/index.js +36 -13
- package/lib/commonjs/core/mixins/index.js.map +1 -1
- package/lib/commonjs/index.js +16 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ui/client.js +177 -0
- package/lib/commonjs/ui/client.js.map +1 -0
- package/lib/commonjs/ui/components/WebOxyProvider.js +98 -0
- package/lib/commonjs/ui/components/WebOxyProvider.js.map +1 -0
- package/lib/commonjs/ui/components/profile/EditFieldModal.js +412 -0
- package/lib/commonjs/ui/components/profile/EditFieldModal.js.map +1 -0
- package/lib/commonjs/ui/context/OxyContext.js +63 -1
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/hooks/useAuth.js +115 -0
- package/lib/commonjs/ui/hooks/useAuth.js.map +1 -0
- package/lib/commonjs/ui/hooks/useSettingToggle.js +7 -1
- package/lib/commonjs/ui/hooks/useSettingToggle.js.map +1 -1
- package/lib/commonjs/ui/hooks/useWebSSO.js +75 -0
- package/lib/commonjs/ui/hooks/useWebSSO.js.map +1 -0
- package/lib/commonjs/ui/index.js +17 -2
- package/lib/commonjs/ui/index.js.map +1 -1
- package/lib/commonjs/ui/screens/PrivacySettingsScreen.js +59 -65
- package/lib/commonjs/ui/screens/PrivacySettingsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/SearchSettingsScreen.js +38 -58
- package/lib/commonjs/ui/screens/SearchSettingsScreen.js.map +1 -1
- package/lib/commonjs/ui/server.js +105 -0
- package/lib/commonjs/ui/server.js.map +1 -0
- package/lib/commonjs/ui/utils/iconNames.js +133 -0
- package/lib/commonjs/ui/utils/iconNames.js.map +1 -0
- package/lib/commonjs/ui/utils/sessionHelpers.js +7 -0
- package/lib/commonjs/ui/utils/sessionHelpers.js.map +1 -1
- package/lib/commonjs/utils/requestUtils.js +4 -3
- package/lib/commonjs/utils/requestUtils.js.map +1 -1
- package/lib/module/core/mixins/index.js +36 -13
- package/lib/module/core/mixins/index.js.map +1 -1
- package/lib/module/index.js +5 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/ui/client.js +48 -0
- package/lib/module/ui/client.js.map +1 -0
- package/lib/module/ui/components/WebOxyProvider.js +94 -0
- package/lib/module/ui/components/WebOxyProvider.js.map +1 -0
- package/lib/module/ui/components/profile/EditFieldModal.js +406 -0
- package/lib/module/ui/components/profile/EditFieldModal.js.map +1 -0
- package/lib/module/ui/context/OxyContext.js +63 -1
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/hooks/useAuth.js +106 -0
- package/lib/module/ui/hooks/useAuth.js.map +1 -0
- package/lib/module/ui/hooks/useSettingToggle.js +7 -1
- package/lib/module/ui/hooks/useSettingToggle.js.map +1 -1
- package/lib/module/ui/hooks/useWebSSO.js +71 -0
- package/lib/module/ui/hooks/useWebSSO.js.map +1 -0
- package/lib/module/ui/index.js +17 -3
- package/lib/module/ui/index.js.map +1 -1
- package/lib/module/ui/screens/PrivacySettingsScreen.js +59 -65
- package/lib/module/ui/screens/PrivacySettingsScreen.js.map +1 -1
- package/lib/module/ui/screens/SearchSettingsScreen.js +39 -59
- package/lib/module/ui/screens/SearchSettingsScreen.js.map +1 -1
- package/lib/module/ui/server.js +65 -0
- package/lib/module/ui/server.js.map +1 -0
- package/lib/module/ui/utils/iconNames.js +124 -0
- package/lib/module/ui/utils/iconNames.js.map +1 -0
- package/lib/module/ui/utils/sessionHelpers.js +7 -0
- package/lib/module/ui/utils/sessionHelpers.js.map +1 -1
- package/lib/module/utils/requestUtils.js +4 -2
- package/lib/module/utils/requestUtils.js.map +1 -1
- package/lib/typescript/commonjs/core/mixins/index.d.ts +18 -1115
- package/lib/typescript/commonjs/core/mixins/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +3 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/client.d.ts +34 -0
- package/lib/typescript/commonjs/ui/client.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/WebOxyProvider.d.ts +44 -0
- package/lib/typescript/commonjs/ui/components/WebOxyProvider.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/profile/EditFieldModal.d.ts +110 -0
- package/lib/typescript/commonjs/ui/components/profile/EditFieldModal.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/context/OxyContext.d.ts +3 -0
- package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts +3 -3
- package/lib/typescript/commonjs/ui/hooks/queries/useAccountQueries.d.ts +6 -10
- package/lib/typescript/commonjs/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/queries/useSecurityQueries.d.ts +1 -1
- package/lib/typescript/commonjs/ui/hooks/queries/useSecurityQueries.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/queries/useServicesQueries.d.ts +3 -5
- package/lib/typescript/commonjs/ui/hooks/queries/useServicesQueries.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useAssets.d.ts +1 -1
- package/lib/typescript/commonjs/ui/hooks/useAuth.d.ts +69 -0
- package/lib/typescript/commonjs/ui/hooks/useAuth.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/hooks/useSettingToggle.d.ts +4 -2
- package/lib/typescript/commonjs/ui/hooks/useSettingToggle.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useWebSSO.d.ts +34 -0
- package/lib/typescript/commonjs/ui/hooks/useWebSSO.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/index.d.ts +2 -2
- package/lib/typescript/commonjs/ui/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/PrivacySettingsScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/SearchSettingsScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/server.d.ts +43 -0
- package/lib/typescript/commonjs/ui/server.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/utils/iconNames.d.ts +112 -0
- package/lib/typescript/commonjs/ui/utils/iconNames.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/utils/sessionHelpers.d.ts +8 -3
- package/lib/typescript/commonjs/ui/utils/sessionHelpers.d.ts.map +1 -1
- package/lib/typescript/commonjs/utils/requestUtils.d.ts +3 -1
- package/lib/typescript/commonjs/utils/requestUtils.d.ts.map +1 -1
- package/lib/typescript/module/core/mixins/index.d.ts +18 -1115
- package/lib/typescript/module/core/mixins/index.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +3 -0
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/ui/client.d.ts +34 -0
- package/lib/typescript/module/ui/client.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/WebOxyProvider.d.ts +44 -0
- package/lib/typescript/module/ui/components/WebOxyProvider.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/profile/EditFieldModal.d.ts +110 -0
- package/lib/typescript/module/ui/components/profile/EditFieldModal.d.ts.map +1 -0
- package/lib/typescript/module/ui/context/OxyContext.d.ts +3 -0
- package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts +3 -3
- package/lib/typescript/module/ui/hooks/queries/useAccountQueries.d.ts +6 -10
- package/lib/typescript/module/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/queries/useSecurityQueries.d.ts +1 -1
- package/lib/typescript/module/ui/hooks/queries/useSecurityQueries.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/queries/useServicesQueries.d.ts +3 -5
- package/lib/typescript/module/ui/hooks/queries/useServicesQueries.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useAssets.d.ts +1 -1
- package/lib/typescript/module/ui/hooks/useAuth.d.ts +69 -0
- package/lib/typescript/module/ui/hooks/useAuth.d.ts.map +1 -0
- package/lib/typescript/module/ui/hooks/useSettingToggle.d.ts +4 -2
- package/lib/typescript/module/ui/hooks/useSettingToggle.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useWebSSO.d.ts +34 -0
- package/lib/typescript/module/ui/hooks/useWebSSO.d.ts.map +1 -0
- package/lib/typescript/module/ui/index.d.ts +2 -2
- package/lib/typescript/module/ui/index.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/PrivacySettingsScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/SearchSettingsScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/server.d.ts +43 -0
- package/lib/typescript/module/ui/server.d.ts.map +1 -0
- package/lib/typescript/module/ui/utils/iconNames.d.ts +112 -0
- package/lib/typescript/module/ui/utils/iconNames.d.ts.map +1 -0
- package/lib/typescript/module/ui/utils/sessionHelpers.d.ts +8 -3
- package/lib/typescript/module/ui/utils/sessionHelpers.d.ts.map +1 -1
- package/lib/typescript/module/utils/requestUtils.d.ts +3 -1
- package/lib/typescript/module/utils/requestUtils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/mixins/index.ts +57 -43
- package/src/index.ts +6 -1
- package/src/ui/client.ts +56 -0
- package/src/ui/components/WebOxyProvider.tsx +109 -0
- package/src/ui/components/profile/EditFieldModal.tsx +465 -0
- package/src/ui/context/OxyContext.tsx +69 -0
- package/src/ui/hooks/useAuth.ts +159 -0
- package/src/ui/hooks/useSettingToggle.ts +7 -3
- package/src/ui/hooks/useWebSSO.ts +93 -0
- package/src/ui/index.ts +17 -2
- package/src/ui/screens/PrivacySettingsScreen.tsx +54 -63
- package/src/ui/screens/SearchSettingsScreen.tsx +42 -64
- package/src/ui/server.ts +70 -0
- package/src/ui/utils/iconNames.ts +136 -0
- package/src/ui/utils/sessionHelpers.ts +10 -3
- package/src/utils/requestUtils.ts +10 -7
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useAuth = useAuth;
|
|
7
|
+
Object.defineProperty(exports, "useOxy", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _OxyContext.useOxy;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
var _react = require("react");
|
|
14
|
+
var _OxyContext = require("../context/OxyContext.js");
|
|
15
|
+
/**
|
|
16
|
+
* Unified Auth Hook
|
|
17
|
+
*
|
|
18
|
+
* Provides a clean, standard interface for authentication across all platforms.
|
|
19
|
+
* This is the recommended way to access auth state in Oxy apps.
|
|
20
|
+
*
|
|
21
|
+
* Usage:
|
|
22
|
+
* ```tsx
|
|
23
|
+
* import { useAuth } from '@oxyhq/services';
|
|
24
|
+
*
|
|
25
|
+
* function MyComponent() {
|
|
26
|
+
* const { user, isAuthenticated, isLoading, signIn, signOut } = useAuth();
|
|
27
|
+
*
|
|
28
|
+
* if (isLoading) return <Loading />;
|
|
29
|
+
* if (!isAuthenticated) return <SignInButton onClick={() => signIn()} />;
|
|
30
|
+
* return <Welcome user={user} />;
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Unified auth hook for all Oxy apps
|
|
37
|
+
*
|
|
38
|
+
* Features:
|
|
39
|
+
* - Zero config: Just wrap with OxyProvider and use
|
|
40
|
+
* - Cross-platform: Same API on native and web
|
|
41
|
+
* - Auto SSO: Web apps automatically check for cross-domain sessions
|
|
42
|
+
* - Type-safe: Full TypeScript support
|
|
43
|
+
*/
|
|
44
|
+
function useAuth() {
|
|
45
|
+
const {
|
|
46
|
+
user,
|
|
47
|
+
isAuthenticated,
|
|
48
|
+
isLoading,
|
|
49
|
+
isTokenReady,
|
|
50
|
+
error,
|
|
51
|
+
signIn: oxySignIn,
|
|
52
|
+
logout,
|
|
53
|
+
logoutAll,
|
|
54
|
+
refreshSessions,
|
|
55
|
+
oxyServices,
|
|
56
|
+
hasIdentity,
|
|
57
|
+
getPublicKey,
|
|
58
|
+
showBottomSheet
|
|
59
|
+
} = (0, _OxyContext.useOxy)();
|
|
60
|
+
const signIn = (0, _react.useCallback)(async publicKey => {
|
|
61
|
+
// If public key provided, use it directly
|
|
62
|
+
if (publicKey) {
|
|
63
|
+
return oxySignIn(publicKey);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Try to get existing identity
|
|
67
|
+
const hasExisting = await hasIdentity();
|
|
68
|
+
if (hasExisting) {
|
|
69
|
+
const existingKey = await getPublicKey();
|
|
70
|
+
if (existingKey) {
|
|
71
|
+
return oxySignIn(existingKey);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// No identity - show auth UI
|
|
76
|
+
// On native: shows bottom sheet for identity creation
|
|
77
|
+
// On web: could trigger popup auth
|
|
78
|
+
showBottomSheet?.('OxyAuth');
|
|
79
|
+
|
|
80
|
+
// Return a promise that resolves when auth completes
|
|
81
|
+
// This is a simplified version - real implementation would
|
|
82
|
+
// wait for the auth flow to complete
|
|
83
|
+
return new Promise((resolve, reject) => {
|
|
84
|
+
// For now, just reject - the bottom sheet handles the flow
|
|
85
|
+
reject(new Error('Please complete sign-in in the auth sheet'));
|
|
86
|
+
});
|
|
87
|
+
}, [oxySignIn, hasIdentity, getPublicKey, showBottomSheet]);
|
|
88
|
+
const signOut = (0, _react.useCallback)(async () => {
|
|
89
|
+
await logout();
|
|
90
|
+
}, [logout]);
|
|
91
|
+
const signOutAll = (0, _react.useCallback)(async () => {
|
|
92
|
+
await logoutAll();
|
|
93
|
+
}, [logoutAll]);
|
|
94
|
+
const refresh = (0, _react.useCallback)(async () => {
|
|
95
|
+
await refreshSessions();
|
|
96
|
+
}, [refreshSessions]);
|
|
97
|
+
return {
|
|
98
|
+
// State
|
|
99
|
+
user,
|
|
100
|
+
isAuthenticated,
|
|
101
|
+
isLoading,
|
|
102
|
+
isReady: isTokenReady,
|
|
103
|
+
error,
|
|
104
|
+
// Actions
|
|
105
|
+
signIn,
|
|
106
|
+
signOut,
|
|
107
|
+
signOutAll,
|
|
108
|
+
refresh,
|
|
109
|
+
// Advanced
|
|
110
|
+
oxyServices
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Re-export useOxy for backward compatibility and advanced usage
|
|
115
|
+
//# sourceMappingURL=useAuth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_OxyContext","useAuth","user","isAuthenticated","isLoading","isTokenReady","error","signIn","oxySignIn","logout","logoutAll","refreshSessions","oxyServices","hasIdentity","getPublicKey","showBottomSheet","useOxy","useCallback","publicKey","hasExisting","existingKey","Promise","resolve","reject","Error","signOut","signOutAll","refresh","isReady"],"sourceRoot":"../../../../src","sources":["ui/hooks/useAuth.ts"],"mappings":";;;;;;;;;;;;AAoBA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AArBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAoDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,OAAOA,CAAA,EAAkB;EACvC,MAAM;IACJC,IAAI;IACJC,eAAe;IACfC,SAAS;IACTC,YAAY;IACZC,KAAK;IACLC,MAAM,EAAEC,SAAS;IACjBC,MAAM;IACNC,SAAS;IACTC,eAAe;IACfC,WAAW;IACXC,WAAW;IACXC,YAAY;IACZC;EACF,CAAC,GAAG,IAAAC,kBAAM,EAAC,CAAC;EAEZ,MAAMT,MAAM,GAAG,IAAAU,kBAAW,EAAC,MAAOC,SAAkB,IAAoB;IACtE;IACA,IAAIA,SAAS,EAAE;MACb,OAAOV,SAAS,CAACU,SAAS,CAAC;IAC7B;;IAEA;IACA,MAAMC,WAAW,GAAG,MAAMN,WAAW,CAAC,CAAC;IAEvC,IAAIM,WAAW,EAAE;MACf,MAAMC,WAAW,GAAG,MAAMN,YAAY,CAAC,CAAC;MACxC,IAAIM,WAAW,EAAE;QACf,OAAOZ,SAAS,CAACY,WAAW,CAAC;MAC/B;IACF;;IAEA;IACA;IACA;IACAL,eAAe,GAAG,SAAS,CAAC;;IAE5B;IACA;IACA;IACA,OAAO,IAAIM,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;MACtC;MACAA,MAAM,CAAC,IAAIC,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAChE,CAAC,CAAC;EACJ,CAAC,EAAE,CAAChB,SAAS,EAAEK,WAAW,EAAEC,YAAY,EAAEC,eAAe,CAAC,CAAC;EAE3D,MAAMU,OAAO,GAAG,IAAAR,kBAAW,EAAC,YAA2B;IACrD,MAAMR,MAAM,CAAC,CAAC;EAChB,CAAC,EAAE,CAACA,MAAM,CAAC,CAAC;EAEZ,MAAMiB,UAAU,GAAG,IAAAT,kBAAW,EAAC,YAA2B;IACxD,MAAMP,SAAS,CAAC,CAAC;EACnB,CAAC,EAAE,CAACA,SAAS,CAAC,CAAC;EAEf,MAAMiB,OAAO,GAAG,IAAAV,kBAAW,EAAC,YAA2B;IACrD,MAAMN,eAAe,CAAC,CAAC;EACzB,CAAC,EAAE,CAACA,eAAe,CAAC,CAAC;EAErB,OAAO;IACL;IACAT,IAAI;IACJC,eAAe;IACfC,SAAS;IACTwB,OAAO,EAAEvB,YAAY;IACrBC,KAAK;IAEL;IACAC,MAAM;IACNkB,OAAO;IACPC,UAAU;IACVC,OAAO;IAEP;IACAf;EACF,CAAC;AACH;;AAEA","ignoreList":[]}
|
|
@@ -115,11 +115,17 @@ function useSettingToggles(options) {
|
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
}, [values, onSave, errorMessage, revertOnError]);
|
|
118
|
+
const setValuesExternal = (0, _react.useCallback)(newValues => {
|
|
119
|
+
setValues(prev => ({
|
|
120
|
+
...prev,
|
|
121
|
+
...newValues
|
|
122
|
+
}));
|
|
123
|
+
}, []);
|
|
118
124
|
return {
|
|
119
125
|
values,
|
|
120
126
|
savingKeys,
|
|
121
127
|
toggle,
|
|
122
|
-
setValues
|
|
128
|
+
setValues: setValuesExternal
|
|
123
129
|
};
|
|
124
130
|
}
|
|
125
131
|
var _default = exports.default = useSettingToggle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_sonner","useSettingToggle","options","initialValue","onSave","successMessage","errorMessage","revertOnError","showSuccessToast","value","setValue","useState","isSaving","setIsSaving","useEffect","toggle","useCallback","previousValue","newValue","toast","success","err","error","message","useSettingToggles","initialValues","values","setValues","savingKeys","setSavingKeys","Set","key","prev","add","next","delete","_default","exports","default"],"sourceRoot":"../../../../src","sources":["ui/hooks/useSettingToggle.ts"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AA4BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,gBAAgBA,CAACC,OAAgC,EAA0B;EACvF,MAAM;IACFC,YAAY;IACZC,MAAM;IACNC,cAAc;IACdC,YAAY,GAAG,wBAAwB;IACvCC,aAAa,GAAG,IAAI;IACpBC,gBAAgB,GAAG;EACvB,CAAC,GAAGN,OAAO;EAEX,MAAM,CAACO,KAAK,EAAEC,QAAQ,CAAC,GAAG,IAAAC,eAAQ,EAACR,YAAY,CAAC;EAChD,MAAM,CAACS,QAAQ,EAAEC,WAAW,CAAC,GAAG,IAAAF,eAAQ,EAAC,KAAK,CAAC;;EAE/C;EACA,IAAAG,gBAAS,EAAC,MAAM;IACZJ,QAAQ,CAACP,YAAY,CAAC;EAC1B,CAAC,EAAE,CAACA,YAAY,CAAC,CAAC;EAElB,MAAMY,MAAM,GAAG,IAAAC,kBAAW,EAAC,YAAY;IACnC,MAAMC,aAAa,GAAGR,KAAK;IAC3B,MAAMS,QAAQ,GAAG,CAACT,KAAK;;IAEvB;IACAC,QAAQ,CAACQ,QAAQ,CAAC;IAClBL,WAAW,CAAC,IAAI,CAAC;IAEjB,IAAI;MACA,MAAMT,MAAM,CAACc,QAAQ,CAAC;MAEtB,IAAIV,gBAAgB,IAAIH,cAAc,EAAE;QACpCc,aAAK,CAACC,OAAO,CAACf,cAAc,CAAC;MACjC;IACJ,CAAC,CAAC,OAAOgB,GAAQ,EAAE;MACf;MACA,IAAId,aAAa,EAAE;QACfG,QAAQ,CAACO,aAAa,CAAC;MAC3B;MAEAE,aAAK,CAACG,KAAK,CAAChB,YAAY,IAAIe,GAAG,EAAEE,OAAO,IAAI,mBAAmB,CAAC;IACpE,CAAC,SAAS;MACNV,WAAW,CAAC,KAAK,CAAC;IACtB;EACJ,CAAC,EAAE,CAACJ,KAAK,EAAEL,MAAM,EAAEC,cAAc,EAAEC,YAAY,EAAEC,aAAa,EAAEC,gBAAgB,CAAC,CAAC;EAElF,OAAO;IAAEC,KAAK;IAAEG,QAAQ;IAAEG,MAAM;IAAEL;EAAS,CAAC;AAChD;;AAEA;AACA;AACA;AACA;AACO,SAASc,iBAAiBA,
|
|
1
|
+
{"version":3,"names":["_react","require","_sonner","useSettingToggle","options","initialValue","onSave","successMessage","errorMessage","revertOnError","showSuccessToast","value","setValue","useState","isSaving","setIsSaving","useEffect","toggle","useCallback","previousValue","newValue","toast","success","err","error","message","useSettingToggles","initialValues","values","setValues","savingKeys","setSavingKeys","Set","key","prev","add","next","delete","setValuesExternal","newValues","_default","exports","default"],"sourceRoot":"../../../../src","sources":["ui/hooks/useSettingToggle.ts"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AA4BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,gBAAgBA,CAACC,OAAgC,EAA0B;EACvF,MAAM;IACFC,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AAS;MACNM,aAAa,CAACG,IAAI,IAAI;QAClB,MAAME,IAAI,GAAG,IAAIJ,GAAG,CAACE,IAAI,CAAC;QAC1BE,IAAI,CAACC,MAAM,CAACJ,GAAG,CAAC;QAChB,OAAOG,IAAI;MACf,CAAC,CAAC;IACN;EACJ,CAAC,EAAE,CAACR,MAAM,EAAEtB,MAAM,EAAEE,YAAY,EAAEC,aAAa,CAAC,CAAC;EAEjD,MAAM6B,iBAAiB,GAAG,IAAApB,kBAAW,EAAEqB,SAAqB,IAAK;IAC7DV,SAAS,CAACK,IAAI,KAAK;MAAE,GAAGA,IAAI;MAAE,GAAGK;IAAU,CAAC,CAAC,CAAC;EAClD,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IAAEX,MAAM;IAAEE,UAAU;IAAEb,MAAM;IAAEY,SAAS,EAAES;EAAkB,CAAC;AACvE;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcvC,gBAAgB","ignoreList":[]}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isWebBrowser = isWebBrowser;
|
|
7
|
+
exports.useWebSSO = useWebSSO;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
/**
|
|
10
|
+
* Web SSO Hook
|
|
11
|
+
*
|
|
12
|
+
* Automatically handles cross-domain SSO for web apps.
|
|
13
|
+
* Uses the OxyServices.silentSignIn() method which loads a hidden iframe
|
|
14
|
+
* to check for existing session at auth.oxy.so.
|
|
15
|
+
*
|
|
16
|
+
* This is called automatically by OxyContext on web platforms.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Check if we're running in a web browser environment (not React Native)
|
|
21
|
+
*/
|
|
22
|
+
function isWebBrowser() {
|
|
23
|
+
// Check for browser globals and that we have a real DOM (React Native has window but not documentElement)
|
|
24
|
+
return typeof window !== 'undefined' && typeof document !== 'undefined' && typeof document.documentElement !== 'undefined';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Hook for automatic web SSO
|
|
29
|
+
*
|
|
30
|
+
* Automatically checks for existing cross-domain session on mount.
|
|
31
|
+
* Only runs on web platforms. Uses OxyServices.silentSignIn() internally.
|
|
32
|
+
*/
|
|
33
|
+
function useWebSSO({
|
|
34
|
+
oxyServices,
|
|
35
|
+
onSessionFound,
|
|
36
|
+
onError,
|
|
37
|
+
enabled = true
|
|
38
|
+
}) {
|
|
39
|
+
const isCheckingRef = (0, _react.useRef)(false);
|
|
40
|
+
const hasCheckedRef = (0, _react.useRef)(false);
|
|
41
|
+
const checkSSO = (0, _react.useCallback)(async () => {
|
|
42
|
+
if (!isWebBrowser() || isCheckingRef.current) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
isCheckingRef.current = true;
|
|
46
|
+
try {
|
|
47
|
+
// Use the existing silentSignIn method from OxyServices
|
|
48
|
+
// which handles iframe creation, postMessage, and token storage
|
|
49
|
+
const session = await oxyServices.silentSignIn?.();
|
|
50
|
+
if (session) {
|
|
51
|
+
await onSessionFound(session);
|
|
52
|
+
}
|
|
53
|
+
return session;
|
|
54
|
+
} catch (error) {
|
|
55
|
+
onError?.(error instanceof Error ? error : new Error(String(error)));
|
|
56
|
+
return null;
|
|
57
|
+
} finally {
|
|
58
|
+
isCheckingRef.current = false;
|
|
59
|
+
}
|
|
60
|
+
}, [oxyServices, onSessionFound, onError]);
|
|
61
|
+
|
|
62
|
+
// Auto-check SSO on mount (web only)
|
|
63
|
+
(0, _react.useEffect)(() => {
|
|
64
|
+
if (!enabled || !isWebBrowser() || hasCheckedRef.current) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
hasCheckedRef.current = true;
|
|
68
|
+
checkSSO();
|
|
69
|
+
}, [enabled, checkSSO]);
|
|
70
|
+
return {
|
|
71
|
+
checkSSO,
|
|
72
|
+
isChecking: isCheckingRef.current
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=useWebSSO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","isWebBrowser","window","document","documentElement","useWebSSO","oxyServices","onSessionFound","onError","enabled","isCheckingRef","useRef","hasCheckedRef","checkSSO","useCallback","current","session","silentSignIn","error","Error","String","useEffect","isChecking"],"sourceRoot":"../../../../src","sources":["ui/hooks/useWebSSO.ts"],"mappings":";;;;;;;AAUA,IAAAA,MAAA,GAAAC,OAAA;AAVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkBA;AACA;AACA;AACA,SAASC,YAAYA,CAAA,EAAY;EAC/B;EACA,OAAO,OAAOC,MAAM,KAAK,WAAW,IAC7B,OAAOC,QAAQ,KAAK,WAAW,IAC/B,OAAOA,QAAQ,CAACC,eAAe,KAAK,WAAW;AACxD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,SAASA,CAAC;EACxBC,WAAW;EACXC,cAAc;EACdC,OAAO;EACPC,OAAO,GAAG;AACM,CAAC,EAAmB;EACpC,MAAMC,aAAa,GAAG,IAAAC,aAAM,EAAC,KAAK,CAAC;EACnC,MAAMC,aAAa,GAAG,IAAAD,aAAM,EAAC,KAAK,CAAC;EAEnC,MAAME,QAAQ,GAAG,IAAAC,kBAAW,EAAC,YAAkD;IAC7E,IAAI,CAACb,YAAY,CAAC,CAAC,IAAIS,aAAa,CAACK,OAAO,EAAE;MAC5C,OAAO,IAAI;IACb;IAEAL,aAAa,CAACK,OAAO,GAAG,IAAI;IAE5B,IAAI;MACF;MACA;MACA,MAAMC,OAAO,GAAG,MAAOV,WAAW,CAASW,YAAY,GAAG,CAAC;MAE3D,IAAID,OAAO,EAAE;QACX,MAAMT,cAAc,CAACS,OAAO,CAAC;MAC/B;MAEA,OAAOA,OAAO;IAChB,CAAC,CAAC,OAAOE,KAAK,EAAE;MACdV,OAAO,GAAGU,KAAK,YAAYC,KAAK,GAAGD,KAAK,GAAG,IAAIC,KAAK,CAACC,MAAM,CAACF,KAAK,CAAC,CAAC,CAAC;MACpE,OAAO,IAAI;IACb,CAAC,SAAS;MACRR,aAAa,CAACK,OAAO,GAAG,KAAK;IAC/B;EACF,CAAC,EAAE,CAACT,WAAW,EAAEC,cAAc,EAAEC,OAAO,CAAC,CAAC;;EAE1C;EACA,IAAAa,gBAAS,EAAC,MAAM;IACd,IAAI,CAACZ,OAAO,IAAI,CAACR,YAAY,CAAC,CAAC,IAAIW,aAAa,CAACG,OAAO,EAAE;MACxD;IACF;IAEAH,aAAa,CAACG,OAAO,GAAG,IAAI;IAC5BF,QAAQ,CAAC,CAAC;EACZ,CAAC,EAAE,CAACJ,OAAO,EAAEI,QAAQ,CAAC,CAAC;EAEvB,OAAO;IACLA,QAAQ;IACRS,UAAU,EAAEZ,aAAa,CAACK;EAC5B,CAAC;AACH","ignoreList":[]}
|
package/lib/commonjs/ui/index.js
CHANGED
|
@@ -36,16 +36,28 @@ Object.defineProperty(exports, "isTimeoutOrNetworkError", {
|
|
|
36
36
|
return _errorHandlers.isTimeoutOrNetworkError;
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
|
-
exports.useStorage = exports.useOxy = exports.useFollow = exports.useAuthStore = exports.useAccountStore = exports.toast = exports.setupFonts = void 0;
|
|
39
|
+
exports.useStorage = exports.useOxy = exports.useFollow = exports.useAuthStore = exports.useAuth = exports.useAccountStore = exports.toast = exports.setupFonts = void 0;
|
|
40
40
|
var _isFrontend = _interopRequireDefault(require("./isFrontend.js"));
|
|
41
41
|
var _index = require("../core/index.js");
|
|
42
42
|
var _errorHandlers = require("./utils/errorHandlers.js");
|
|
43
43
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
44
44
|
/**
|
|
45
45
|
* UI Component exports - Frontend Only (with backend-safe fallbacks)
|
|
46
|
-
*
|
|
46
|
+
*
|
|
47
47
|
* This module exports all React/React Native UI components and hooks.
|
|
48
48
|
* In backend, all exports are no-ops or empty objects.
|
|
49
|
+
*
|
|
50
|
+
* NOTE: This entry point uses runtime detection which prevents tree-shaking.
|
|
51
|
+
* For better bundle optimization, use:
|
|
52
|
+
* - '@oxyhq/services/ui/client' for client bundles (tree-shakeable)
|
|
53
|
+
* - '@oxyhq/services/ui/server' for SSR environments (all noops)
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* // Client bundle (tree-shakeable)
|
|
57
|
+
* import { OxyProvider, useOxy } from '@oxyhq/services/ui/client';
|
|
58
|
+
*
|
|
59
|
+
* // SSR (noops)
|
|
60
|
+
* import { OxyProvider, useOxy } from '@oxyhq/services/ui/server';
|
|
49
61
|
*/
|
|
50
62
|
|
|
51
63
|
// UI exports
|
|
@@ -59,6 +71,7 @@ let OxyProvider = exports.OxyProvider = void 0,
|
|
|
59
71
|
setupFonts = exports.setupFonts = void 0,
|
|
60
72
|
OxyIcon = exports.OxyIcon = void 0,
|
|
61
73
|
useOxy = exports.useOxy = void 0,
|
|
74
|
+
useAuth = exports.useAuth = void 0,
|
|
62
75
|
useFollow = exports.useFollow = void 0,
|
|
63
76
|
ProfileScreen = exports.ProfileScreen = void 0,
|
|
64
77
|
useAuthStore = exports.useAuthStore = void 0,
|
|
@@ -78,6 +91,7 @@ if (_isFrontend.default) {
|
|
|
78
91
|
exports.setupFonts = setupFonts = require('./components/FontLoader').setupFonts;
|
|
79
92
|
exports.OxyIcon = OxyIcon = require('./components/icon').OxyIcon;
|
|
80
93
|
exports.useOxy = useOxy = require('./context/OxyContext').useOxy;
|
|
94
|
+
exports.useAuth = useAuth = require('./hooks/useAuth').useAuth;
|
|
81
95
|
exports.useFollow = useFollow = require('./hooks').useFollow;
|
|
82
96
|
exports.ProfileScreen = ProfileScreen = require('./screens/ProfileScreen').default;
|
|
83
97
|
exports.useAuthStore = useAuthStore = require('./stores/authStore').useAuthStore;
|
|
@@ -104,6 +118,7 @@ if (_isFrontend.default) {
|
|
|
104
118
|
exports.setupFonts = setupFonts = () => {};
|
|
105
119
|
exports.OxyIcon = OxyIcon = noopComponent;
|
|
106
120
|
exports.useOxy = useOxy = noopHook;
|
|
121
|
+
exports.useAuth = useAuth = noopHook;
|
|
107
122
|
exports.useFollow = useFollow = noopHook;
|
|
108
123
|
exports.ProfileScreen = ProfileScreen = noopComponent;
|
|
109
124
|
exports.useAuthStore = useAuthStore = noopHook;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_isFrontend","_interopRequireDefault","require","_index","_errorHandlers","e","__esModule","default","OxyProvider","exports","OxySignInButton","OxyLogo","Avatar","FollowButton","OxyPayButton","FontLoader","setupFonts","OxyIcon","useOxy","useFollow","ProfileScreen","useAuthStore","useAccountStore","fontFamilies","fontStyles","toast","useStorage","isFrontend","noopComponent","noopHook","noopStorageResult","storage","isReady"],"sourceRoot":"../../../src","sources":["ui/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"names":["_isFrontend","_interopRequireDefault","require","_index","_errorHandlers","e","__esModule","default","OxyProvider","exports","OxySignInButton","OxyLogo","Avatar","FollowButton","OxyPayButton","FontLoader","setupFonts","OxyIcon","useOxy","useAuth","useFollow","ProfileScreen","useAuthStore","useAccountStore","fontFamilies","fontStyles","toast","useStorage","isFrontend","noopComponent","noopHook","noopStorageResult","storage","isReady"],"sourceRoot":"../../../src","sources":["ui/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AA2EA,IAAAC,MAAA,GAAAD,OAAA;AAIA,IAAAE,cAAA,GAAAF,OAAA;AAK+B,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAtG/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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hB,OAAA,CAAAiB,KAAA,GAAAA,KAAK,GAAGA,CAAA,KAAM,CAAC,CAAC;EAChBjB,OAAA,CAAAkB,UAAA,GAAAA,UAAU,GAAGA,CAAA,KAAMI,iBAAiB;AACtC;;AAwBA;;AAIA;;AASA","ignoreList":[]}
|
|
@@ -10,16 +10,37 @@ var _sonner = require("../../lib/sonner.js");
|
|
|
10
10
|
var _index = require("../components/index.js");
|
|
11
11
|
var _useI18n = require("../hooks/useI18n.js");
|
|
12
12
|
var _useThemeStyles = require("../hooks/useThemeStyles.js");
|
|
13
|
+
var _useSettingToggle = require("../hooks/useSettingToggle.js");
|
|
13
14
|
var _themeUtils = require("../utils/themeUtils.js");
|
|
14
15
|
var _OxyContext = require("../context/OxyContext.js");
|
|
15
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
17
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
18
|
+
const DEFAULT_PRIVACY_SETTINGS = {
|
|
19
|
+
isPrivateAccount: false,
|
|
20
|
+
hideOnlineStatus: false,
|
|
21
|
+
hideLastSeen: false,
|
|
22
|
+
profileVisibility: true,
|
|
23
|
+
loginAlerts: true,
|
|
24
|
+
blockScreenshots: false,
|
|
25
|
+
login: true,
|
|
26
|
+
biometricLogin: false,
|
|
27
|
+
showActivity: true,
|
|
28
|
+
allowTagging: true,
|
|
29
|
+
allowMentions: true,
|
|
30
|
+
hideReadReceipts: false,
|
|
31
|
+
allowDirectMessages: true,
|
|
32
|
+
dataSharing: true,
|
|
33
|
+
locationSharing: false,
|
|
34
|
+
analyticsSharing: true,
|
|
35
|
+
sensitiveContent: false,
|
|
36
|
+
autoFilter: true,
|
|
37
|
+
muteKeywords: false
|
|
38
|
+
};
|
|
17
39
|
const PrivacySettingsScreen = ({
|
|
18
40
|
onClose,
|
|
19
41
|
theme,
|
|
20
42
|
goBack
|
|
21
43
|
}) => {
|
|
22
|
-
// Use useOxy() hook for OxyContext values
|
|
23
44
|
const {
|
|
24
45
|
oxyServices,
|
|
25
46
|
user
|
|
@@ -27,34 +48,30 @@ const PrivacySettingsScreen = ({
|
|
|
27
48
|
const {
|
|
28
49
|
t
|
|
29
50
|
} = (0, _useI18n.useI18n)();
|
|
30
|
-
const [settings, setSettings] = (0, _react.useState)({
|
|
31
|
-
isPrivateAccount: false,
|
|
32
|
-
hideOnlineStatus: false,
|
|
33
|
-
hideLastSeen: false,
|
|
34
|
-
profileVisibility: true,
|
|
35
|
-
loginAlerts: true,
|
|
36
|
-
blockScreenshots: false,
|
|
37
|
-
login: true,
|
|
38
|
-
biometricLogin: false,
|
|
39
|
-
showActivity: true,
|
|
40
|
-
allowTagging: true,
|
|
41
|
-
allowMentions: true,
|
|
42
|
-
hideReadReceipts: false,
|
|
43
|
-
allowDirectMessages: true,
|
|
44
|
-
dataSharing: true,
|
|
45
|
-
locationSharing: false,
|
|
46
|
-
analyticsSharing: true,
|
|
47
|
-
sensitiveContent: false,
|
|
48
|
-
autoFilter: true,
|
|
49
|
-
muteKeywords: false
|
|
50
|
-
});
|
|
51
51
|
const [isLoading, setIsLoading] = (0, _react.useState)(true);
|
|
52
|
-
const [isSaving, setIsSaving] = (0, _react.useState)(false);
|
|
53
52
|
const [blockedUsers, setBlockedUsers] = (0, _react.useState)([]);
|
|
54
53
|
const [restrictedUsers, setRestrictedUsers] = (0, _react.useState)([]);
|
|
55
54
|
const [isLoadingUsers, setIsLoadingUsers] = (0, _react.useState)(false);
|
|
56
55
|
|
|
57
|
-
//
|
|
56
|
+
// Use the existing useSettingToggles hook for toggle management
|
|
57
|
+
const {
|
|
58
|
+
values: settings,
|
|
59
|
+
toggle,
|
|
60
|
+
savingKeys,
|
|
61
|
+
setValues
|
|
62
|
+
} = (0, _useSettingToggle.useSettingToggles)({
|
|
63
|
+
initialValues: DEFAULT_PRIVACY_SETTINGS,
|
|
64
|
+
onSave: async (key, value) => {
|
|
65
|
+
if (!user?.id || !oxyServices) return;
|
|
66
|
+
await oxyServices.updatePrivacySettings({
|
|
67
|
+
[key]: value
|
|
68
|
+
}, user.id);
|
|
69
|
+
},
|
|
70
|
+
errorMessage: t('privacySettings.updateError') || 'Failed to update privacy setting'
|
|
71
|
+
});
|
|
72
|
+
const isSaving = savingKeys.size > 0;
|
|
73
|
+
|
|
74
|
+
// Load settings
|
|
58
75
|
(0, _react.useEffect)(() => {
|
|
59
76
|
const loadSettings = async () => {
|
|
60
77
|
try {
|
|
@@ -62,7 +79,7 @@ const PrivacySettingsScreen = ({
|
|
|
62
79
|
if (user?.id && oxyServices) {
|
|
63
80
|
const privacySettings = await oxyServices.getPrivacySettings(user.id);
|
|
64
81
|
if (privacySettings) {
|
|
65
|
-
|
|
82
|
+
setValues(privacySettings);
|
|
66
83
|
}
|
|
67
84
|
}
|
|
68
85
|
} catch (error) {
|
|
@@ -73,7 +90,7 @@ const PrivacySettingsScreen = ({
|
|
|
73
90
|
}
|
|
74
91
|
};
|
|
75
92
|
loadSettings();
|
|
76
|
-
}, [user?.id, oxyServices, t]);
|
|
93
|
+
}, [user?.id, oxyServices, t, setValues]);
|
|
77
94
|
|
|
78
95
|
// Load blocked and restricted users
|
|
79
96
|
(0, _react.useEffect)(() => {
|
|
@@ -92,29 +109,6 @@ const PrivacySettingsScreen = ({
|
|
|
92
109
|
};
|
|
93
110
|
loadUsers();
|
|
94
111
|
}, [oxyServices]);
|
|
95
|
-
const updateSetting = (0, _react.useCallback)(async (key, value) => {
|
|
96
|
-
try {
|
|
97
|
-
setIsSaving(true);
|
|
98
|
-
const newSettings = {
|
|
99
|
-
...settings,
|
|
100
|
-
[key]: value
|
|
101
|
-
};
|
|
102
|
-
setSettings(newSettings);
|
|
103
|
-
if (user?.id && oxyServices) {
|
|
104
|
-
await oxyServices.updatePrivacySettings({
|
|
105
|
-
[key]: value
|
|
106
|
-
}, user.id);
|
|
107
|
-
_sonner.toast.success(t('privacySettings.updated') || 'Privacy settings updated');
|
|
108
|
-
}
|
|
109
|
-
} catch (error) {
|
|
110
|
-
console.error(`Failed to update ${key}:`, error);
|
|
111
|
-
_sonner.toast.error(t('privacySettings.updateError') || 'Failed to update privacy setting');
|
|
112
|
-
// Revert on error
|
|
113
|
-
setSettings(settings);
|
|
114
|
-
} finally {
|
|
115
|
-
setIsSaving(false);
|
|
116
|
-
}
|
|
117
|
-
}, [settings, user?.id, oxyServices, t]);
|
|
118
112
|
const handleUnblock = (0, _react.useCallback)(async userId => {
|
|
119
113
|
if (!oxyServices) return;
|
|
120
114
|
try {
|
|
@@ -274,7 +268,7 @@ const PrivacySettingsScreen = ({
|
|
|
274
268
|
title: t('privacySettings.isPrivateAccount') || 'Private Account',
|
|
275
269
|
description: t('privacySettings.isPrivateAccountDesc') || 'Only approved followers can see your posts',
|
|
276
270
|
value: settings.isPrivateAccount,
|
|
277
|
-
onValueChange:
|
|
271
|
+
onValueChange: () => toggle('isPrivateAccount'),
|
|
278
272
|
disabled: isSaving,
|
|
279
273
|
textColor: themeStyles.textColor,
|
|
280
274
|
mutedTextColor: themeStyles.mutedTextColor,
|
|
@@ -283,7 +277,7 @@ const PrivacySettingsScreen = ({
|
|
|
283
277
|
title: t('privacySettings.profileVisibility') || 'Profile Visibility',
|
|
284
278
|
description: t('privacySettings.profileVisibilityDesc') || 'Control who can view your profile',
|
|
285
279
|
value: settings.profileVisibility,
|
|
286
|
-
onValueChange:
|
|
280
|
+
onValueChange: () => toggle('profileVisibility'),
|
|
287
281
|
disabled: isSaving,
|
|
288
282
|
textColor: themeStyles.textColor,
|
|
289
283
|
mutedTextColor: themeStyles.mutedTextColor,
|
|
@@ -292,7 +286,7 @@ const PrivacySettingsScreen = ({
|
|
|
292
286
|
title: t('privacySettings.hideOnlineStatus') || 'Hide Online Status',
|
|
293
287
|
description: t('privacySettings.hideOnlineStatusDesc') || 'Don\'t show when you\'re online',
|
|
294
288
|
value: settings.hideOnlineStatus,
|
|
295
|
-
onValueChange:
|
|
289
|
+
onValueChange: () => toggle('hideOnlineStatus'),
|
|
296
290
|
disabled: isSaving,
|
|
297
291
|
textColor: themeStyles.textColor,
|
|
298
292
|
mutedTextColor: themeStyles.mutedTextColor,
|
|
@@ -301,7 +295,7 @@ const PrivacySettingsScreen = ({
|
|
|
301
295
|
title: t('privacySettings.hideLastSeen') || 'Hide Last Seen',
|
|
302
296
|
description: t('privacySettings.hideLastSeenDesc') || 'Don\'t show when you were last active',
|
|
303
297
|
value: settings.hideLastSeen,
|
|
304
|
-
onValueChange:
|
|
298
|
+
onValueChange: () => toggle('hideLastSeen'),
|
|
305
299
|
disabled: isSaving,
|
|
306
300
|
textColor: themeStyles.textColor,
|
|
307
301
|
mutedTextColor: themeStyles.mutedTextColor,
|
|
@@ -313,7 +307,7 @@ const PrivacySettingsScreen = ({
|
|
|
313
307
|
title: t('privacySettings.allowTagging') || 'Allow Tagging',
|
|
314
308
|
description: t('privacySettings.allowTaggingDesc') || 'Let others tag you in posts',
|
|
315
309
|
value: settings.allowTagging,
|
|
316
|
-
onValueChange:
|
|
310
|
+
onValueChange: () => toggle('allowTagging'),
|
|
317
311
|
disabled: isSaving,
|
|
318
312
|
textColor: themeStyles.textColor,
|
|
319
313
|
mutedTextColor: themeStyles.mutedTextColor,
|
|
@@ -322,7 +316,7 @@ const PrivacySettingsScreen = ({
|
|
|
322
316
|
title: t('privacySettings.allowMentions') || 'Allow Mentions',
|
|
323
317
|
description: t('privacySettings.allowMentionsDesc') || 'Let others mention you',
|
|
324
318
|
value: settings.allowMentions,
|
|
325
|
-
onValueChange:
|
|
319
|
+
onValueChange: () => toggle('allowMentions'),
|
|
326
320
|
disabled: isSaving,
|
|
327
321
|
textColor: themeStyles.textColor,
|
|
328
322
|
mutedTextColor: themeStyles.mutedTextColor,
|
|
@@ -331,7 +325,7 @@ const PrivacySettingsScreen = ({
|
|
|
331
325
|
title: t('privacySettings.allowDirectMessages') || 'Allow Direct Messages',
|
|
332
326
|
description: t('privacySettings.allowDirectMessagesDesc') || 'Let others send you direct messages',
|
|
333
327
|
value: settings.allowDirectMessages,
|
|
334
|
-
onValueChange:
|
|
328
|
+
onValueChange: () => toggle('allowDirectMessages'),
|
|
335
329
|
disabled: isSaving,
|
|
336
330
|
textColor: themeStyles.textColor,
|
|
337
331
|
mutedTextColor: themeStyles.mutedTextColor,
|
|
@@ -340,7 +334,7 @@ const PrivacySettingsScreen = ({
|
|
|
340
334
|
title: t('privacySettings.hideReadReceipts') || 'Hide Read Receipts',
|
|
341
335
|
description: t('privacySettings.hideReadReceiptsDesc') || 'Don\'t show read receipts in messages',
|
|
342
336
|
value: settings.hideReadReceipts,
|
|
343
|
-
onValueChange:
|
|
337
|
+
onValueChange: () => toggle('hideReadReceipts'),
|
|
344
338
|
disabled: isSaving,
|
|
345
339
|
textColor: themeStyles.textColor,
|
|
346
340
|
mutedTextColor: themeStyles.mutedTextColor,
|
|
@@ -352,7 +346,7 @@ const PrivacySettingsScreen = ({
|
|
|
352
346
|
title: t('privacySettings.showActivity') || 'Show Activity Status',
|
|
353
347
|
description: t('privacySettings.showActivityDesc') || 'Display your activity on your profile',
|
|
354
348
|
value: settings.showActivity,
|
|
355
|
-
onValueChange:
|
|
349
|
+
onValueChange: () => toggle('showActivity'),
|
|
356
350
|
disabled: isSaving,
|
|
357
351
|
textColor: themeStyles.textColor,
|
|
358
352
|
mutedTextColor: themeStyles.mutedTextColor,
|
|
@@ -361,7 +355,7 @@ const PrivacySettingsScreen = ({
|
|
|
361
355
|
title: t('privacySettings.dataSharing') || 'Data Sharing',
|
|
362
356
|
description: t('privacySettings.dataSharingDesc') || 'Allow sharing data for personalization',
|
|
363
357
|
value: settings.dataSharing,
|
|
364
|
-
onValueChange:
|
|
358
|
+
onValueChange: () => toggle('dataSharing'),
|
|
365
359
|
disabled: isSaving,
|
|
366
360
|
textColor: themeStyles.textColor,
|
|
367
361
|
mutedTextColor: themeStyles.mutedTextColor,
|
|
@@ -370,7 +364,7 @@ const PrivacySettingsScreen = ({
|
|
|
370
364
|
title: t('privacySettings.locationSharing') || 'Location Sharing',
|
|
371
365
|
description: t('privacySettings.locationSharingDesc') || 'Share your location',
|
|
372
366
|
value: settings.locationSharing,
|
|
373
|
-
onValueChange:
|
|
367
|
+
onValueChange: () => toggle('locationSharing'),
|
|
374
368
|
disabled: isSaving,
|
|
375
369
|
textColor: themeStyles.textColor,
|
|
376
370
|
mutedTextColor: themeStyles.mutedTextColor,
|
|
@@ -379,7 +373,7 @@ const PrivacySettingsScreen = ({
|
|
|
379
373
|
title: t('privacySettings.analyticsSharing') || 'Analytics Sharing',
|
|
380
374
|
description: t('privacySettings.analyticsSharingDesc') || 'Allow analytics data collection',
|
|
381
375
|
value: settings.analyticsSharing,
|
|
382
|
-
onValueChange:
|
|
376
|
+
onValueChange: () => toggle('analyticsSharing'),
|
|
383
377
|
disabled: isSaving,
|
|
384
378
|
textColor: themeStyles.textColor,
|
|
385
379
|
mutedTextColor: themeStyles.mutedTextColor,
|
|
@@ -391,7 +385,7 @@ const PrivacySettingsScreen = ({
|
|
|
391
385
|
title: t('privacySettings.sensitiveContent') || 'Show Sensitive Content',
|
|
392
386
|
description: t('privacySettings.sensitiveContentDesc') || 'Allow sensitive or explicit content',
|
|
393
387
|
value: settings.sensitiveContent,
|
|
394
|
-
onValueChange:
|
|
388
|
+
onValueChange: () => toggle('sensitiveContent'),
|
|
395
389
|
disabled: isSaving,
|
|
396
390
|
textColor: themeStyles.textColor,
|
|
397
391
|
mutedTextColor: themeStyles.mutedTextColor,
|
|
@@ -400,7 +394,7 @@ const PrivacySettingsScreen = ({
|
|
|
400
394
|
title: t('privacySettings.autoFilter') || 'Auto Filter',
|
|
401
395
|
description: t('privacySettings.autoFilterDesc') || 'Automatically filter inappropriate content',
|
|
402
396
|
value: settings.autoFilter,
|
|
403
|
-
onValueChange:
|
|
397
|
+
onValueChange: () => toggle('autoFilter'),
|
|
404
398
|
disabled: isSaving,
|
|
405
399
|
textColor: themeStyles.textColor,
|
|
406
400
|
mutedTextColor: themeStyles.mutedTextColor,
|
|
@@ -409,7 +403,7 @@ const PrivacySettingsScreen = ({
|
|
|
409
403
|
title: t('privacySettings.muteKeywords') || 'Mute Keywords',
|
|
410
404
|
description: t('privacySettings.muteKeywordsDesc') || 'Hide posts containing muted keywords',
|
|
411
405
|
value: settings.muteKeywords,
|
|
412
|
-
onValueChange:
|
|
406
|
+
onValueChange: () => toggle('muteKeywords'),
|
|
413
407
|
disabled: isSaving,
|
|
414
408
|
textColor: themeStyles.textColor,
|
|
415
409
|
mutedTextColor: themeStyles.mutedTextColor,
|
|
@@ -418,7 +412,7 @@ const PrivacySettingsScreen = ({
|
|
|
418
412
|
title: t('privacySettings.blockScreenshots') || 'Block Screenshots',
|
|
419
413
|
description: t('privacySettings.blockScreenshotsDesc') || 'Prevent screenshots of your content',
|
|
420
414
|
value: settings.blockScreenshots,
|
|
421
|
-
onValueChange:
|
|
415
|
+
onValueChange: () => toggle('blockScreenshots'),
|
|
422
416
|
disabled: isSaving,
|
|
423
417
|
textColor: themeStyles.textColor,
|
|
424
418
|
mutedTextColor: themeStyles.mutedTextColor,
|