@oxyhq/core 3.4.15 → 3.4.16
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/README.md +7 -2
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/utils/accountUtils.js +5 -9
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/utils/accountUtils.js +5 -9
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/models/interfaces.d.ts +2 -0
- package/dist/types/utils/accountUtils.d.ts +4 -14
- package/package.json +1 -1
- package/src/models/interfaces.ts +2 -0
- package/src/utils/__tests__/accountUtils.test.ts +10 -22
- package/src/utils/accountUtils.ts +6 -16
- package/src/utils/asyncUtils.ts +1 -1
|
@@ -17,13 +17,9 @@ export const formatPublicKeyHandle = (publicKey) => {
|
|
|
17
17
|
* Resolve a friendly display name for a user.
|
|
18
18
|
*
|
|
19
19
|
* Order of preference:
|
|
20
|
-
* 1. `
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* 2. `name` (when stored as a plain string)
|
|
24
|
-
* 3. `displayName` (server `displayName` virtual — `username || truncatedKey`).
|
|
25
|
-
* Placed AFTER the structured name on purpose: the server virtual ignores
|
|
26
|
-
* `name`, so preferring it first would re-introduce the first-only bug.
|
|
20
|
+
* 1. `displayName` from the API contract.
|
|
21
|
+
* 2. `name.full`, or composed `name.first name.last` for local unsaved shapes.
|
|
22
|
+
* 3. `name` when stored as a plain string.
|
|
27
23
|
* 4. `username`
|
|
28
24
|
* 5. `Account 0x12345678…` (derived from publicKey, when present)
|
|
29
25
|
* 6. Translated fallback (e.g. "Unnamed")
|
|
@@ -35,6 +31,8 @@ export const getAccountDisplayName = (user, locale) => {
|
|
|
35
31
|
if (!user)
|
|
36
32
|
return translate(locale, 'common.unnamed');
|
|
37
33
|
const { name, displayName, username, publicKey } = user;
|
|
34
|
+
if (typeof displayName === 'string' && displayName.trim())
|
|
35
|
+
return displayName.trim();
|
|
38
36
|
if (name && typeof name === 'object') {
|
|
39
37
|
if (typeof name.full === 'string' && name.full.trim())
|
|
40
38
|
return name.full.trim();
|
|
@@ -47,8 +45,6 @@ export const getAccountDisplayName = (user, locale) => {
|
|
|
47
45
|
else if (typeof name === 'string' && name.trim()) {
|
|
48
46
|
return name.trim();
|
|
49
47
|
}
|
|
50
|
-
if (typeof displayName === 'string' && displayName.trim())
|
|
51
|
-
return displayName.trim();
|
|
52
48
|
if (typeof username === 'string' && username.trim())
|
|
53
49
|
return username.trim();
|
|
54
50
|
if (typeof publicKey === 'string' && publicKey.length > 0) {
|