mirror of
https://github.com/logos-messaging/OpChan.git
synced 2026-01-04 05:43:10 +00:00
fix: ens
This commit is contained in:
parent
e4192f8d20
commit
9605c9a1b3
@ -81,12 +81,7 @@ export class UserIdentityService {
|
|||||||
getAll(): UserIdentity[] {
|
getAll(): UserIdentity[] {
|
||||||
return Object.entries(localDatabase.cache.userIdentities).map(([address, cached]) => ({
|
return Object.entries(localDatabase.cache.userIdentities).map(([address, cached]) => ({
|
||||||
address,
|
address,
|
||||||
ensName: cached.ensName,
|
...cached,
|
||||||
ordinalDetails: cached.ordinalDetails,
|
|
||||||
callSign: cached.callSign,
|
|
||||||
displayPreference: cached.displayPreference,
|
|
||||||
displayName: this.getDisplayName(address),
|
|
||||||
lastUpdated: cached.lastUpdated,
|
|
||||||
verificationStatus: this.mapVerificationStatus(cached.verificationStatus),
|
verificationStatus: this.mapVerificationStatus(cached.verificationStatus),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@ -186,18 +181,17 @@ export class UserIdentityService {
|
|||||||
/**
|
/**
|
||||||
* Get display name for user based on their preferences
|
* Get display name for user based on their preferences
|
||||||
*/
|
*/
|
||||||
getDisplayName(address: string): string {
|
getDisplayName({address, ensName, displayPreference}: {address: string, ensName?: string | null, displayPreference?: EDisplayPreference}): string {
|
||||||
const identity = localDatabase.cache.userIdentities[address];
|
const storedIdentity = localDatabase.cache.userIdentities[address];
|
||||||
|
|
||||||
if (
|
if (
|
||||||
identity.displayPreference === EDisplayPreference.CALL_SIGN &&
|
storedIdentity?.callSign &&
|
||||||
identity.callSign
|
displayPreference === EDisplayPreference.CALL_SIGN
|
||||||
) {
|
) {
|
||||||
return identity.callSign;
|
return storedIdentity.callSign;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (identity.ensName) {
|
if (ensName) {
|
||||||
return identity.ensName;
|
return ensName;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${address.slice(0, 6)}...${address.slice(-4)}`;
|
return `${address.slice(0, 6)}...${address.slice(-4)}`;
|
||||||
@ -241,10 +235,6 @@ export class UserIdentityService {
|
|||||||
this.resolveOrdinalDetails(address),
|
this.resolveOrdinalDetails(address),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Default to wallet address display preference
|
|
||||||
const defaultDisplayPreference: EDisplayPreference =
|
|
||||||
EDisplayPreference.WALLET_ADDRESS;
|
|
||||||
|
|
||||||
const isWalletConnected = WalletManager.hasInstance()
|
const isWalletConnected = WalletManager.hasInstance()
|
||||||
? walletManager.getInstance().isConnected()
|
? walletManager.getInstance().isConnected()
|
||||||
: false;
|
: false;
|
||||||
@ -255,14 +245,16 @@ export class UserIdentityService {
|
|||||||
verificationStatus = isWalletConnected ? EVerificationStatus.WALLET_CONNECTED : EVerificationStatus.WALLET_UNCONNECTED;
|
verificationStatus = isWalletConnected ? EVerificationStatus.WALLET_CONNECTED : EVerificationStatus.WALLET_UNCONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const displayPreference = localDatabase.cache.userIdentities[address]?.displayPreference ?? EDisplayPreference.WALLET_ADDRESS;
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
address,
|
address,
|
||||||
ensName: ensName || undefined,
|
ensName: ensName || undefined,
|
||||||
ordinalDetails: ordinalDetails || undefined,
|
ordinalDetails: ordinalDetails || undefined,
|
||||||
callSign: undefined, // Will be populated from Waku messages
|
callSign: undefined, // Will be populated from Waku messages
|
||||||
displayPreference: defaultDisplayPreference,
|
displayPreference: displayPreference,
|
||||||
displayName: this.getDisplayName(address),
|
displayName: this.getDisplayName({address, ensName, displayPreference}),
|
||||||
lastUpdated: Date.now(),
|
lastUpdated: Date.now(),
|
||||||
verificationStatus,
|
verificationStatus,
|
||||||
};
|
};
|
||||||
@ -338,7 +330,7 @@ export class UserIdentityService {
|
|||||||
ordinalDetails: record.ordinalDetails,
|
ordinalDetails: record.ordinalDetails,
|
||||||
callSign: record.callSign,
|
callSign: record.callSign,
|
||||||
displayPreference: record.displayPreference,
|
displayPreference: record.displayPreference,
|
||||||
displayName: this.getDisplayName(address),
|
displayName: this.getDisplayName({address, ensName: record.ensName, displayPreference: record.displayPreference}),
|
||||||
lastUpdated: record.lastUpdated,
|
lastUpdated: record.lastUpdated,
|
||||||
verificationStatus: this.mapVerificationStatus(record.verificationStatus),
|
verificationStatus: this.mapVerificationStatus(record.verificationStatus),
|
||||||
};
|
};
|
||||||
|
|||||||
@ -34,26 +34,16 @@ export const StoreWiring: React.FC = () => {
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Hydrate identity cache from LocalDatabase
|
// Hydrate identity cache from LocalDatabase using UserIdentityService
|
||||||
const identityCache = client.database.cache.userIdentities;
|
const allIdentities = client.userIdentityService.getAll();
|
||||||
const identityUpdates: Record<string, UserIdentity> = {};
|
const identityUpdates: Record<string, UserIdentity> = {};
|
||||||
const displayNameUpdates: Record<string, string> = {};
|
const displayNameUpdates: Record<string, string> = {};
|
||||||
const lastUpdatedMap: Record<string, number> = {};
|
const lastUpdatedMap: Record<string, number> = {};
|
||||||
|
|
||||||
for (const address of Object.keys(identityCache)) {
|
for (const identity of allIdentities) {
|
||||||
const identity = identityCache[address]!;
|
identityUpdates[identity.address] = identity;
|
||||||
identityUpdates[address] = {
|
displayNameUpdates[identity.address] = identity.displayName;
|
||||||
address,
|
lastUpdatedMap[identity.address] = identity.lastUpdated;
|
||||||
ensName: identity.ensName,
|
|
||||||
ordinalDetails: identity.ordinalDetails,
|
|
||||||
callSign: identity.callSign,
|
|
||||||
displayPreference: identity.displayPreference,
|
|
||||||
displayName: client.userIdentityService.getDisplayName(address),
|
|
||||||
lastUpdated: identity.lastUpdated,
|
|
||||||
verificationStatus: identity.verificationStatus as EVerificationStatus,
|
|
||||||
};
|
|
||||||
displayNameUpdates[address] = client.userIdentityService.getDisplayName(address);
|
|
||||||
lastUpdatedMap[address] = identity.lastUpdated;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setOpchanState(prev => ({
|
setOpchanState(prev => ({
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user