mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
working on concurrency bug
This commit is contained in:
@@ -48,7 +48,7 @@ export default function EditLecture({ lectureDay }: { lectureDay: string }) {
|
||||
} else {
|
||||
if (lecture) {
|
||||
console.log(
|
||||
"client not authoritative, updating client with server data"
|
||||
"client not authoritative, updating client with server lecture"
|
||||
);
|
||||
textUpdate(lectureToString(lecture), true);
|
||||
} else {
|
||||
|
||||
@@ -35,11 +35,17 @@ export default function EditAssignment({
|
||||
useAssignmentQuery(moduleName, assignmentName);
|
||||
const updateAssignment = useUpdateAssignmentMutation();
|
||||
|
||||
const { clientIsAuthoritative, text, textUpdate, monacoKey } =
|
||||
useAuthoritativeUpdates({
|
||||
serverUpdatedAt: serverDataUpdatedAt,
|
||||
startingText: localAssignmentMarkdown.toMarkdown(assignment),
|
||||
});
|
||||
const {
|
||||
clientIsAuthoritative,
|
||||
text,
|
||||
textUpdate,
|
||||
monacoKey,
|
||||
serverUpdatedAt,
|
||||
clientDataUpdatedAt,
|
||||
} = useAuthoritativeUpdates({
|
||||
serverUpdatedAt: serverDataUpdatedAt,
|
||||
startingText: localAssignmentMarkdown.toMarkdown(assignment),
|
||||
});
|
||||
|
||||
const [error, setError] = useState("");
|
||||
const [showHelp, setShowHelp] = useState(false);
|
||||
@@ -79,7 +85,11 @@ export default function EditAssignment({
|
||||
});
|
||||
} else {
|
||||
console.log(
|
||||
"client not authoritative, updating client with server data"
|
||||
"client not authoritative, updating client with server assignment",
|
||||
"client updated",
|
||||
clientDataUpdatedAt,
|
||||
"server updated",
|
||||
serverUpdatedAt
|
||||
);
|
||||
textUpdate(localAssignmentMarkdown.toMarkdown(assignment), true);
|
||||
}
|
||||
@@ -96,10 +106,12 @@ export default function EditAssignment({
|
||||
}, [
|
||||
assignment,
|
||||
assignmentName,
|
||||
clientDataUpdatedAt,
|
||||
clientIsAuthoritative,
|
||||
courseName,
|
||||
moduleName,
|
||||
router,
|
||||
serverUpdatedAt,
|
||||
text,
|
||||
textUpdate,
|
||||
updateAssignment,
|
||||
|
||||
@@ -72,7 +72,7 @@ export default function EditPage({
|
||||
});
|
||||
} else {
|
||||
console.log(
|
||||
"client not authoritative, updating client with server data"
|
||||
"client not authoritative, updating client with server page"
|
||||
);
|
||||
textUpdate(localPageMarkdownUtils.toMarkdown(page), true);
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ export default function EditQuiz({
|
||||
});
|
||||
} else {
|
||||
console.log(
|
||||
"client not authoritative, updating client with server data"
|
||||
"client not authoritative, updating client with server quiz"
|
||||
);
|
||||
textUpdate(quizMarkdownUtils.toMarkdown(quiz), true);
|
||||
}
|
||||
|
||||
@@ -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]
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user