frontend client for gemstone. decentralised workplace app

refactor: use lattice at uri instead of did as map key

serenity f26730af 5b66a1f4

Changed files
+7 -7
src
providers
+7 -7
src/providers/authed/HandshakesProvider.tsx
···
import { DEFAULT_STALE_TIME } from "@/lib/consts";
-
import type { Did } from "@/lib/types/atproto";
+
import type { AtUri, Did } from "@/lib/types/atproto";
import type { LatticeSessionInfo } from "@/lib/types/handshake";
import type { SystemsGmstnDevelopmentChannelMembership } from "@/lib/types/lexicon/systems.gmstn.development.channel.membership";
import type { SystemsGmstnDevelopmentChannel } from "@/lib/types/lexicon/systems.gmstn.development.channels";
···
import type { ReactNode } from "react";
import { createContext, useContext, useMemo } from "react";
-
type HandshakesMap = Map<Did, LatticeSessionInfo>;
+
type HandshakesMap = Map<AtUri, LatticeSessionInfo>;
interface HandshakeContextValue {
handshakesMap: HandshakesMap;
isInitialising: boolean;
error: Error | null;
-
getHandshake: (latticeDid: Did) => LatticeSessionInfo | undefined;
+
getHandshake: (latticeDid: AtUri) => LatticeSessionInfo | undefined;
}
const HandshakesContext = createContext<HandshakeContextValue | null>(null);
···
null;
const handshakes = useMemo(() => {
-
const handshakesMap = new Map<Did, LatticeSessionInfo>();
+
const handshakesMap = new Map<AtUri, LatticeSessionInfo>();
handshakeQueries.forEach((queryResult) => {
if (queryResult.data) {
-
const { did, sessionInfo } = queryResult.data;
-
handshakesMap.set(did, sessionInfo);
+
const { latticeAtUri, sessionInfo } = queryResult.data;
+
handshakesMap.set(latticeAtUri, sessionInfo);
}
});
return handshakesMap;
···
}
return {
-
did,
+
latticeAtUri: latticeAtUri.data,
sessionInfo: handshakeResult.data,
};
};