working on concurrency bug

This commit is contained in:
2024-11-18 13:01:27 -07:00
parent d689b4b684
commit cdd71a672f
5 changed files with 25 additions and 16 deletions

View File

@@ -13,11 +13,6 @@ export function useAuthoritativeUpdates({
useState(serverUpdatedAt);
const [updateMonacoKey, setUpdateMonacoKey] = useState(1);
const clientIsAuthoritative = useMemo(
() => serverUpdatedAt <= clientDataUpdatedAt,
[clientDataUpdatedAt, serverUpdatedAt]
);
// console.log("client is authoritative", clientIsAuthoritative);
const textUpdate = useCallback((t: string, updateMonaco: boolean = false) => {
setText(t);
@@ -27,11 +22,13 @@ export function useAuthoritativeUpdates({
return useMemo(
() => ({
clientIsAuthoritative,
clientIsAuthoritative: serverUpdatedAt <= clientDataUpdatedAt,
serverUpdatedAt,
clientDataUpdatedAt,
textUpdate,
text,
monacoKey: updateMonacoKey,
}),
[clientIsAuthoritative, text, textUpdate, updateMonacoKey]
[clientDataUpdatedAt, serverUpdatedAt, text, textUpdate, updateMonacoKey]
);
}