@oxyhq/services 24.0.0 → 24.0.2
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/android/src/main/java/so/oxy/session/OxyBackgroundSessionModule.kt +42 -27
- package/android/src/main/java/so/oxy/session/OxyBackgroundSessionStore.kt +11 -2
- package/lib/commonjs/ui/screens/ProfileScreen.js +15 -4
- package/lib/commonjs/ui/screens/ProfileScreen.js.map +1 -1
- package/lib/commonjs/ui/session/backgroundSession.js +37 -12
- package/lib/commonjs/ui/session/backgroundSession.js.map +1 -1
- package/lib/commonjs/ui/session/useBackgroundSessionSync.js +4 -5
- package/lib/commonjs/ui/session/useBackgroundSessionSync.js.map +1 -1
- package/lib/commonjs/ui/utils/userUtils.js +11 -21
- package/lib/commonjs/ui/utils/userUtils.js.map +1 -1
- package/lib/module/ui/screens/ProfileScreen.js +15 -4
- package/lib/module/ui/screens/ProfileScreen.js.map +1 -1
- package/lib/module/ui/session/backgroundSession.js +37 -12
- package/lib/module/ui/session/backgroundSession.js.map +1 -1
- package/lib/module/ui/session/useBackgroundSessionSync.js +4 -5
- package/lib/module/ui/session/useBackgroundSessionSync.js.map +1 -1
- package/lib/module/ui/utils/userUtils.js +12 -22
- package/lib/module/ui/utils/userUtils.js.map +1 -1
- package/lib/typescript/commonjs/ui/screens/ProfileScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/session/backgroundSession.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/session/useBackgroundSessionSync.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/userUtils.d.ts +5 -7
- package/lib/typescript/commonjs/ui/utils/userUtils.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/ProfileScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/session/backgroundSession.d.ts.map +1 -1
- package/lib/typescript/module/ui/session/useBackgroundSessionSync.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/userUtils.d.ts +5 -7
- package/lib/typescript/module/ui/utils/userUtils.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/ui/screens/ProfileScreen.tsx +17 -3
- package/src/ui/session/__tests__/backgroundSession.test.ts +63 -8
- package/src/ui/session/backgroundSession.ts +65 -20
- package/src/ui/session/useBackgroundSessionSync.ts +4 -5
- package/src/ui/utils/userUtils.ts +10 -29
|
@@ -2,16 +2,11 @@
|
|
|
2
2
|
* User display name and date formatting utilities.
|
|
3
3
|
*
|
|
4
4
|
* Display-name helpers follow the API contract: prefer `name.displayName` when
|
|
5
|
-
* present, otherwise fall back to the normalized handle
|
|
6
|
-
* `
|
|
7
|
-
* account-switcher surfaces without a handle.
|
|
5
|
+
* present, otherwise fall back to the normalized handle via
|
|
6
|
+
* `getNormalizedUserHandle`.
|
|
8
7
|
*/
|
|
9
8
|
|
|
10
|
-
import {
|
|
11
|
-
getAccountDisplayName as coreGetAccountDisplayName,
|
|
12
|
-
getNormalizedUserHandle,
|
|
13
|
-
type DisplayNameUserShape,
|
|
14
|
-
} from '@oxyhq/core';
|
|
9
|
+
import { getNormalizedUserHandle, type DisplayNameUserShape } from '@oxyhq/core';
|
|
15
10
|
|
|
16
11
|
/**
|
|
17
12
|
* Formats a date string to a readable format (e.g., "Feb 21, 2025")
|
|
@@ -42,20 +37,14 @@ function readDisplayName(user: DisplayNameUserShape | null | undefined): string
|
|
|
42
37
|
/**
|
|
43
38
|
* Gets a display name from user data.
|
|
44
39
|
*
|
|
45
|
-
* Prefers API `name.displayName`, then the normalized handle
|
|
46
|
-
* account-switcher fallback chain.
|
|
40
|
+
* Prefers API `name.displayName`, then the normalized handle.
|
|
47
41
|
*/
|
|
48
42
|
export const getDisplayName = (
|
|
49
43
|
user: DisplayNameUserShape | null | undefined,
|
|
50
|
-
locale?: string,
|
|
51
44
|
): string => {
|
|
52
45
|
const displayName = readDisplayName(user);
|
|
53
46
|
if (displayName) return displayName;
|
|
54
|
-
|
|
55
|
-
const handle = getNormalizedUserHandle(user);
|
|
56
|
-
if (handle) return handle;
|
|
57
|
-
|
|
58
|
-
return coreGetAccountDisplayName(user, locale);
|
|
47
|
+
return getNormalizedUserHandle(user) ?? '';
|
|
59
48
|
};
|
|
60
49
|
|
|
61
50
|
/**
|
|
@@ -63,7 +52,6 @@ export const getDisplayName = (
|
|
|
63
52
|
*/
|
|
64
53
|
export const getShortDisplayName = (
|
|
65
54
|
user: DisplayNameUserShape | null | undefined,
|
|
66
|
-
locale?: string,
|
|
67
55
|
): string => {
|
|
68
56
|
const displayName = readDisplayName(user);
|
|
69
57
|
if (displayName) {
|
|
@@ -71,18 +59,11 @@ export const getShortDisplayName = (
|
|
|
71
59
|
if (firstToken) return firstToken;
|
|
72
60
|
}
|
|
73
61
|
|
|
74
|
-
const name = user?.name;
|
|
75
|
-
if (name && typeof name === 'object') {
|
|
76
|
-
const first = typeof name.first === 'string' ? name.first.trim() : '';
|
|
77
|
-
if (first) return first.split(/\s+/)[0] ?? first;
|
|
78
|
-
const full = typeof name.full === 'string' ? name.full.trim() : '';
|
|
79
|
-
if (full) return full.split(/\s+/)[0] ?? full;
|
|
80
|
-
} else if (typeof name === 'string' && name.trim()) {
|
|
81
|
-
return name.trim().split(/\s+/)[0] ?? name.trim();
|
|
82
|
-
}
|
|
83
|
-
|
|
84
62
|
const handle = getNormalizedUserHandle(user);
|
|
85
|
-
if (handle)
|
|
63
|
+
if (handle) {
|
|
64
|
+
const firstToken = handle.split(/\s+/).find(Boolean);
|
|
65
|
+
return firstToken ?? handle;
|
|
66
|
+
}
|
|
86
67
|
|
|
87
|
-
return
|
|
68
|
+
return '';
|
|
88
69
|
};
|