mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
Merge pull request #1949 from PR0M3TH3AN/codex/review-and-update-logout-flow-cache-handling
Reset profile and DM caches on logout
This commit is contained in:
5 files changed
+44
No files matched your search
@@ -4706,6 +4706,22 @@ class Application {
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof this.nostrService?.stopDirectMessageSubscription === "function") {
|
||||
try {
|
||||
this.nostrService.stopDirectMessageSubscription();
|
||||
} catch (error) {
|
||||
devLogger.warn("Failed to stop DM subscription during logout:", error);
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof this.nostrService?.clearDirectMessages === "function") {
|
||||
try {
|
||||
this.nostrService.clearDirectMessages({ emit: true });
|
||||
} catch (error) {
|
||||
devLogger.warn("Failed to clear cached DMs during logout:", error);
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof this.nostrService?.clearVideoSubscription === "function") {
|
||||
try {
|
||||
this.nostrService.clearVideoSubscription();
|
||||
|
||||
@@ -836,6 +836,14 @@ export default class AuthService {
|
||||
setCurrentUserNpub(null);
|
||||
setActiveProfilePubkey(null, { persist: true });
|
||||
|
||||
try {
|
||||
if (profileCache && typeof profileCache.reset === "function") {
|
||||
profileCache.reset();
|
||||
}
|
||||
} catch (error) {
|
||||
this.log("[AuthService] profileCache.reset threw", error);
|
||||
}
|
||||
|
||||
try {
|
||||
resetModerationSettings({ persist: true });
|
||||
} catch (error) {
|
||||
|
||||
@@ -46,6 +46,11 @@ export class DmNotificationManager {
|
||||
return this.focusedConversationId;
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.conversationCache.clear();
|
||||
this.focusedConversationId = "";
|
||||
}
|
||||
|
||||
setFocusedConversation(conversationId, isFocused = true) {
|
||||
if (typeof conversationId !== "string") {
|
||||
return;
|
||||
|
||||
@@ -754,6 +754,13 @@ export class NostrService {
|
||||
if (this.dmPreviewCache) {
|
||||
this.dmPreviewCache.clear();
|
||||
}
|
||||
if (this.dmNotificationManager?.reset) {
|
||||
try {
|
||||
this.dmNotificationManager.reset();
|
||||
} catch (error) {
|
||||
userLogger.warn("[nostrService] Failed to reset DM notifications cache", error);
|
||||
}
|
||||
}
|
||||
const activeActor = normalizeHexPubkey(
|
||||
typeof actorPubkey === "string" && actorPubkey
|
||||
? actorPubkey
|
||||
|
||||
@@ -346,6 +346,14 @@ class ProfileCache {
|
||||
this.emit("runtimeCleared", { pubkey: normalized });
|
||||
}
|
||||
|
||||
reset() {
|
||||
const previousPubkey = this.activePubkey;
|
||||
this.activePubkey = null;
|
||||
this.memoryCache.clear();
|
||||
this.emit("profileChanged", { pubkey: null, previousPubkey: previousPubkey || null });
|
||||
this.emit("reset", { previousPubkey: previousPubkey || null });
|
||||
}
|
||||
|
||||
subscribe(callback) {
|
||||
this.listeners.add(callback);
|
||||
return () => this.listeners.delete(callback);
|
||||
|
||||
Reference in new issue
Block a user