From 3ddc85669f488838cf17514552ca843491ab4e4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Thu, 23 Apr 2026 09:13:03 +0100 Subject: [PATCH] Clear nostr event cache from Settings --- app/components/app-menu/settings/nostr.gjs | 23 ++++++++++++++++++++++ app/services/nostr-data.js | 7 +++++++ app/utils/icons.js | 2 ++ 3 files changed, 32 insertions(+) diff --git a/app/components/app-menu/settings/nostr.gjs b/app/components/app-menu/settings/nostr.gjs index d332111..4260bf5 100644 --- a/app/components/app-menu/settings/nostr.gjs +++ b/app/components/app-menu/settings/nostr.gjs @@ -12,6 +12,7 @@ const stripProtocol = (url) => (url ? url.replace(/^wss?:\/\//, '') : ''); export default class AppMenuSettingsNostr extends Component { @service settings; @service nostrData; + @service toast; @tracked newReadRelay = ''; @tracked newWriteRelay = ''; @@ -90,6 +91,16 @@ export default class AppMenuSettingsNostr extends Component { this.settings.update('nostrWriteRelays', null); } + @action + async clearCache() { + try { + await this.nostrData.clearCache(); + this.toast.show('Nostr cache cleared'); + } catch (e) { + this.toast.show(`Failed to clear Nostr cache: ${e.message}`); + } + } + diff --git a/app/services/nostr-data.js b/app/services/nostr-data.js index a3df768..fd6c256 100644 --- a/app/services/nostr-data.js +++ b/app/services/nostr-data.js @@ -356,6 +356,13 @@ export default class NostrDataService extends Service { return 'Not connected'; } + async clearCache() { + await this._cachePromise; + if (this.cache) { + await this.cache.deleteAllEvents(); + } + } + _cleanupSubscriptions() { if (this._requestSub) { this._requestSub.unsubscribe(); diff --git a/app/utils/icons.js b/app/utils/icons.js index 4f24d68..a7513df 100644 --- a/app/utils/icons.js +++ b/app/utils/icons.js @@ -7,6 +7,7 @@ import checkSquare from 'feather-icons/dist/icons/check-square.svg?raw'; import chevronLeft from 'feather-icons/dist/icons/chevron-left.svg?raw'; import chevronRight from 'feather-icons/dist/icons/chevron-right.svg?raw'; import clock from 'feather-icons/dist/icons/clock.svg?raw'; +import database from 'feather-icons/dist/icons/database.svg?raw'; import edit from 'feather-icons/dist/icons/edit.svg?raw'; import facebook from 'feather-icons/dist/icons/facebook.svg?raw'; import gift from 'feather-icons/dist/icons/gift.svg?raw'; @@ -153,6 +154,7 @@ const ICONS = { 'comedy-mask-and-tragedy-mask': comedyMaskAndTragedyMask, croissant, 'cup-and-saucer': cupAndSaucer, + database, donut, edit, eyeglasses,