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:
thePR0M3TH3AN authored and GitHub committed 2026-01-29 15:55:14 -05:00
commit b58b4b0df6
5 files changed
+44

No files matched your search

+16
View File
@@ -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();
+8
View File
@@ -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) {
+5
View File
@@ -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;
+7
View File
@@ -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
+8
View File
@@ -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);