|
|
|
@ -29,6 +29,10 @@ class StorageService { |
|
|
|
private accountRelayListEventMap: Record<string, Event | undefined> = {} // pubkey -> relayListEvent
|
|
|
|
private accountRelayListEventMap: Record<string, Event | undefined> = {} // pubkey -> relayListEvent
|
|
|
|
private accountFollowListEventMap: Record<string, Event | undefined> = {} // pubkey -> followListEvent
|
|
|
|
private accountFollowListEventMap: Record<string, Event | undefined> = {} // pubkey -> followListEvent
|
|
|
|
private accountMuteListEventMap: Record<string, Event | undefined> = {} // pubkey -> muteListEvent
|
|
|
|
private accountMuteListEventMap: Record<string, Event | undefined> = {} // pubkey -> muteListEvent
|
|
|
|
|
|
|
|
private accountMuteDecryptedTagsMap: Record< |
|
|
|
|
|
|
|
string, |
|
|
|
|
|
|
|
{ id: string; tags: string[][] } | undefined |
|
|
|
|
|
|
|
> = {} // pubkey -> { id, tags }
|
|
|
|
private accountProfileEventMap: Record<string, Event | undefined> = {} // pubkey -> profileEvent
|
|
|
|
private accountProfileEventMap: Record<string, Event | undefined> = {} // pubkey -> profileEvent
|
|
|
|
|
|
|
|
|
|
|
|
constructor() { |
|
|
|
constructor() { |
|
|
|
@ -67,6 +71,12 @@ class StorageService { |
|
|
|
this.accountMuteListEventMap = accountMuteListEventMapStr |
|
|
|
this.accountMuteListEventMap = accountMuteListEventMapStr |
|
|
|
? JSON.parse(accountMuteListEventMapStr) |
|
|
|
? JSON.parse(accountMuteListEventMapStr) |
|
|
|
: {} |
|
|
|
: {} |
|
|
|
|
|
|
|
const accountMuteDecryptedTagsMapStr = window.localStorage.getItem( |
|
|
|
|
|
|
|
StorageKey.ACCOUNT_MUTE_DECRYPTED_TAGS_MAP |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
this.accountMuteDecryptedTagsMap = accountMuteDecryptedTagsMapStr |
|
|
|
|
|
|
|
? JSON.parse(accountMuteDecryptedTagsMapStr) |
|
|
|
|
|
|
|
: {} |
|
|
|
const accountProfileEventMapStr = window.localStorage.getItem( |
|
|
|
const accountProfileEventMapStr = window.localStorage.getItem( |
|
|
|
StorageKey.ACCOUNT_PROFILE_EVENT_MAP |
|
|
|
StorageKey.ACCOUNT_PROFILE_EVENT_MAP |
|
|
|
) |
|
|
|
) |
|
|
|
@ -184,6 +194,7 @@ class StorageService { |
|
|
|
delete this.accountFollowListEventMap[account.pubkey] |
|
|
|
delete this.accountFollowListEventMap[account.pubkey] |
|
|
|
delete this.accountRelayListEventMap[account.pubkey] |
|
|
|
delete this.accountRelayListEventMap[account.pubkey] |
|
|
|
delete this.accountMuteListEventMap[account.pubkey] |
|
|
|
delete this.accountMuteListEventMap[account.pubkey] |
|
|
|
|
|
|
|
delete this.accountMuteDecryptedTagsMap[account.pubkey] |
|
|
|
delete this.accountProfileEventMap[account.pubkey] |
|
|
|
delete this.accountProfileEventMap[account.pubkey] |
|
|
|
window.localStorage.setItem(StorageKey.ACCOUNTS, JSON.stringify(this.accounts)) |
|
|
|
window.localStorage.setItem(StorageKey.ACCOUNTS, JSON.stringify(this.accounts)) |
|
|
|
window.localStorage.setItem( |
|
|
|
window.localStorage.setItem( |
|
|
|
@ -194,6 +205,10 @@ class StorageService { |
|
|
|
StorageKey.ACCOUNT_MUTE_LIST_EVENT_MAP, |
|
|
|
StorageKey.ACCOUNT_MUTE_LIST_EVENT_MAP, |
|
|
|
JSON.stringify(this.accountMuteListEventMap) |
|
|
|
JSON.stringify(this.accountMuteListEventMap) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
window.localStorage.setItem( |
|
|
|
|
|
|
|
StorageKey.ACCOUNT_MUTE_DECRYPTED_TAGS_MAP, |
|
|
|
|
|
|
|
JSON.stringify(this.accountMuteDecryptedTagsMap) |
|
|
|
|
|
|
|
) |
|
|
|
window.localStorage.setItem( |
|
|
|
window.localStorage.setItem( |
|
|
|
StorageKey.ACCOUNT_RELAY_LIST_EVENT_MAP, |
|
|
|
StorageKey.ACCOUNT_RELAY_LIST_EVENT_MAP, |
|
|
|
JSON.stringify(this.accountRelayListEventMap) |
|
|
|
JSON.stringify(this.accountRelayListEventMap) |
|
|
|
@ -276,6 +291,22 @@ class StorageService { |
|
|
|
return true |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getAccountMuteDecryptedTags(muteListEvent: Event) { |
|
|
|
|
|
|
|
const stored = this.accountMuteDecryptedTagsMap[muteListEvent.pubkey] |
|
|
|
|
|
|
|
if (stored && stored.id === muteListEvent.id) { |
|
|
|
|
|
|
|
return stored.tags |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return null |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setAccountMuteDecryptedTags(muteListEvent: Event, tags: string[][]) { |
|
|
|
|
|
|
|
this.accountMuteDecryptedTagsMap[muteListEvent.pubkey] = { id: muteListEvent.id, tags } |
|
|
|
|
|
|
|
window.localStorage.setItem( |
|
|
|
|
|
|
|
StorageKey.ACCOUNT_MUTE_DECRYPTED_TAGS_MAP, |
|
|
|
|
|
|
|
JSON.stringify(this.accountMuteDecryptedTagsMap) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getAccountProfileEvent(pubkey: string) { |
|
|
|
getAccountProfileEvent(pubkey: string) { |
|
|
|
return this.accountProfileEventMap[pubkey] |
|
|
|
return this.accountProfileEventMap[pubkey] |
|
|
|
} |
|
|
|
} |
|
|
|
|