mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
Merge pull request #1301 from PR0M3TH3AN/fix-hashtag-reset-crash-11374645465269223196
Fix hashtag preferences crash and prevent data reset on load failure
This commit is contained in:
1 file changed
+11
-4
@@ -414,7 +414,7 @@ class HashtagPreferencesService {
|
||||
|
||||
async load(pubkey) {
|
||||
const normalized = normalizeHexPubkey(pubkey);
|
||||
const wasLoadedForUser =
|
||||
let wasLoadedForUser =
|
||||
this.activePubkey &&
|
||||
this.activePubkey === normalized &&
|
||||
(this.interests.size > 0 || this.disinterests.size > 0 || this.loaded);
|
||||
@@ -573,9 +573,16 @@ class HashtagPreferencesService {
|
||||
`${LOG_PREFIX} Failed to decrypt hashtag preferences`,
|
||||
decryptResult.error,
|
||||
);
|
||||
// If decryption fails on a reload, we might want to keep old data?
|
||||
// But typically decryption failure means key mismatch or bad payload.
|
||||
// Resetting is safer here to avoid stuck state, unless we want to be very conservative.
|
||||
|
||||
// If we already have loaded preferences (e.g. from cache), preserve them
|
||||
// rather than wiping everything just because the remote update couldn't be decrypted.
|
||||
if (wasLoadedForUser) {
|
||||
userLogger.warn(
|
||||
`${LOG_PREFIX} Preserving cached preferences despite decryption failure.`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
this.reset();
|
||||
this.loaded = true;
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user