fix(anon mode): user id could change for pending post, name field could bug out

This commit is contained in:
Tom (plebeius.eth)
2024-09-19 17:33:00 +02:00
parent b18c1bc491
commit bb976409ff
8 changed files with 40 additions and 110 deletions
-9
View File
@@ -10,8 +10,6 @@ interface AnonModeState {
getThreadSigner: (postCid: string) => any | undefined;
setAddressSigner: (signer: any) => void;
getAddressSigner: (address: string) => any | undefined;
currentAnonSignerAddress: string | null;
setCurrentAnonSignerAddress: (address: string | null) => void;
}
const anonModeStore = localForageLru.createInstance({
@@ -42,10 +40,6 @@ const useAnonModeStore = create<AnonModeState>((set, get) => ({
},
getAddressSigner: (address: string) => get().addressSigners[address],
currentAnonSignerAddress: null,
setCurrentAnonSignerAddress: (address: string | null) => {
set({ currentAnonSignerAddress: address });
anonModeStore.setItem('currentAnonSignerAddress', address);
},
}));
const initializeAnonModeStore = async () => {
@@ -64,13 +58,10 @@ const initializeAnonModeStore = async () => {
}
});
const currentAnonSignerAddress = await anonModeStore.getItem('currentAnonSignerAddress');
useAnonModeStore.setState((state) => ({
anonMode, // Set the retrieved anonMode state
threadSigners: { ...threadSigners, ...state.threadSigners },
addressSigners: { ...addressSigners, ...state.addressSigners },
currentAnonSignerAddress: currentAnonSignerAddress || null,
}));
};