fix(web): reauthenticateInstance works without existing live instance (stale disconnected entries)
This commit is contained in:
@@ -564,25 +564,26 @@ export const useInstanceStore = create<InstanceState>((set, get) => ({
|
|||||||
|
|
||||||
reauthenticateInstance: async (origin: string, password: string) => {
|
reauthenticateInstance: async (origin: string, password: string) => {
|
||||||
const inst = get().instances.find(i => i.origin === origin);
|
const inst = get().instances.find(i => i.origin === origin);
|
||||||
if (!inst) return;
|
|
||||||
|
|
||||||
// Remove the stale placeholder
|
// Clean up existing instance if present (stale placeholder or disconnected entry)
|
||||||
set((state) => ({
|
if (inst) {
|
||||||
instances: state.instances.filter(i => i.origin !== origin),
|
set((state) => ({
|
||||||
}));
|
instances: state.instances.filter(i => i.origin !== origin),
|
||||||
|
}));
|
||||||
// Remove its spaces from the space store
|
useSpaceStore.getState().removeInstanceSpaces(origin);
|
||||||
useSpaceStore.getState().removeInstanceSpaces(origin);
|
}
|
||||||
|
|
||||||
// Disconnect any lingering WS
|
// Disconnect any lingering WS
|
||||||
disconnectWs(origin);
|
disconnectWs(origin);
|
||||||
|
|
||||||
// Re-connect through the standard flow (handles register/login)
|
// Re-connect through the standard flow (handles register/login)
|
||||||
const currentUser = useAuthStore.getState().user;
|
const currentUser = useAuthStore.getState().user;
|
||||||
|
if (!currentUser) return;
|
||||||
|
|
||||||
await get().connectToRemote(
|
await get().connectToRemote(
|
||||||
origin,
|
origin,
|
||||||
password,
|
password,
|
||||||
currentUser?.displayName || undefined,
|
currentUser.displayName || undefined,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Clear pending password sync — connectToRemote uses the current password
|
// Clear pending password sync — connectToRemote uses the current password
|
||||||
|
|||||||
Reference in New Issue
Block a user