From 273cbfd9ccef2356c9449c77e4ede4f33640d0cf Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 7 Feb 2026 23:50:18 +0000 Subject: [PATCH] Refactor HashtagPreferencesService to use unified profile cache key Replaced the legacy "interests" string literal with NOTE_TYPES.HASHTAG_PREFERENCES in profileCache calls to unify key usage. Updated migration logic and comments. Verified that the underlying storage key remains consistent for backward compatibility. Co-authored-by: PR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> --- js/services/hashtagPreferencesService.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/js/services/hashtagPreferencesService.js b/js/services/hashtagPreferencesService.js index 438cd33a..50fca17e 100644 --- a/js/services/hashtagPreferencesService.js +++ b/js/services/hashtagPreferencesService.js @@ -352,18 +352,15 @@ class HashtagPreferencesService { eventId: this.eventId, createdAt: this.eventCreatedAt, }; - // Use the note type key directly, though "interests" maps to HASHTAG_PREFERENCES - // in profileCache. Using NOTE_TYPES.HASHTAG_PREFERENCES explicitly is safer if we import it, - // but relying on the mapped key "interests" is also consistent with current usage. - // However, the fix requires us to ensure we use the unified path. - // We'll stick to "interests" which maps to NOTE_TYPES.HASHTAG_PREFERENCES in profileCache.js - profileCache.set("interests", payload); + // Use the note type key directly. This maps to the same storage key as the legacy "interests" + // mapping in profileCache, ensuring backward compatibility while using the unified path. + profileCache.set(NOTE_TYPES.HASHTAG_PREFERENCES, payload); } loadFromCache(pubkey) { // profileCache internally uses activePubkey, but we should verify if it matches try { - let cached = profileCache.getProfileData(pubkey, "interests"); + let cached = profileCache.getProfileData(pubkey, NOTE_TYPES.HASHTAG_PREFERENCES); // Legacy fallback migration if (!cached && typeof localStorage !== "undefined") { @@ -372,7 +369,7 @@ class HashtagPreferencesService { if (legacy) { const parsed = JSON.parse(legacy); // Migrate to unified profile cache - profileCache.set("interests", parsed); + profileCache.set(NOTE_TYPES.HASHTAG_PREFERENCES, parsed); localStorage.removeItem(HASHTAG_IDENTIFIER); cached = parsed; devLogger.log(`${LOG_PREFIX} Migrated legacy preferences to profileCache.`);