mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-08 13:52:58 +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") {
|
if (typeof this.nostrService?.clearVideoSubscription === "function") {
|
||||||
try {
|
try {
|
||||||
this.nostrService.clearVideoSubscription();
|
this.nostrService.clearVideoSubscription();
|
||||||
|
|||||||
@@ -836,6 +836,14 @@ export default class AuthService {
|
|||||||
setCurrentUserNpub(null);
|
setCurrentUserNpub(null);
|
||||||
setActiveProfilePubkey(null, { persist: true });
|
setActiveProfilePubkey(null, { persist: true });
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (profileCache && typeof profileCache.reset === "function") {
|
||||||
|
profileCache.reset();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
this.log("[AuthService] profileCache.reset threw", error);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
resetModerationSettings({ persist: true });
|
resetModerationSettings({ persist: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -46,6 +46,11 @@ export class DmNotificationManager {
|
|||||||
return this.focusedConversationId;
|
return this.focusedConversationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reset() {
|
||||||
|
this.conversationCache.clear();
|
||||||
|
this.focusedConversationId = "";
|
||||||
|
}
|
||||||
|
|
||||||
setFocusedConversation(conversationId, isFocused = true) {
|
setFocusedConversation(conversationId, isFocused = true) {
|
||||||
if (typeof conversationId !== "string") {
|
if (typeof conversationId !== "string") {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -754,6 +754,13 @@ export class NostrService {
|
|||||||
if (this.dmPreviewCache) {
|
if (this.dmPreviewCache) {
|
||||||
this.dmPreviewCache.clear();
|
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(
|
const activeActor = normalizeHexPubkey(
|
||||||
typeof actorPubkey === "string" && actorPubkey
|
typeof actorPubkey === "string" && actorPubkey
|
||||||
? actorPubkey
|
? actorPubkey
|
||||||
|
|||||||
@@ -346,6 +346,14 @@ class ProfileCache {
|
|||||||
this.emit("runtimeCleared", { pubkey: normalized });
|
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) {
|
subscribe(callback) {
|
||||||
this.listeners.add(callback);
|
this.listeners.add(callback);
|
||||||
return () => this.listeners.delete(callback);
|
return () => this.listeners.delete(callback);
|
||||||
|
|||||||
Reference in new issue
Block a user