Fix chaching bug for submissions
This commit is contained in:
parent
f1c27cf0e4
commit
e8d7402349
|
|
@ -269,6 +269,7 @@ onResult(async () => {
|
||||||
assignment.value = {
|
assignment.value = {
|
||||||
...loadedAssignment,
|
...loadedAssignment,
|
||||||
};
|
};
|
||||||
|
// Bugfix: this nextTick is needed. Without it the submissions are not diplayed when loading the module page.
|
||||||
await nextTick();
|
await nextTick();
|
||||||
|
|
||||||
assignment.value.submission = Object.assign(initialSubmission, assignment.value.submission);
|
assignment.value.submission = Object.assign(initialSubmission, assignment.value.submission);
|
||||||
|
|
@ -341,7 +342,7 @@ const reopen = () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const _save = debounce(function (submission) {
|
const _save = debounce(function () {
|
||||||
saving.value++;
|
saving.value++;
|
||||||
const variables = {
|
const variables = {
|
||||||
input: {
|
input: {
|
||||||
|
|
@ -354,36 +355,13 @@ const _save = debounce(function (submission) {
|
||||||
};
|
};
|
||||||
doUpdateAssignmentWithSuccess(variables, {
|
doUpdateAssignmentWithSuccess(variables, {
|
||||||
update(
|
update(
|
||||||
cache,
|
_cache,
|
||||||
{
|
{
|
||||||
data: {
|
data: {
|
||||||
updateAssignment: { successful, updatedAssignment },
|
updateAssignment: { _successful, _updatedAssignment },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
) {
|
) {},
|
||||||
try {
|
|
||||||
if (successful) {
|
|
||||||
const id = cache.identify({
|
|
||||||
id: updatedAssignment.id,
|
|
||||||
__typename: updatedAssignment.__typename,
|
|
||||||
});
|
|
||||||
const fragment = assignmentFragment;
|
|
||||||
const fragmentName = 'AssignmentParts';
|
|
||||||
cache.writeFragment({
|
|
||||||
fragment,
|
|
||||||
fragmentName,
|
|
||||||
id,
|
|
||||||
data: {
|
|
||||||
...updatedAssignment,
|
|
||||||
submission,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
// Query did not exist in the cache, and apollo throws a generic Error. Do nothing
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
saving.value--;
|
saving.value--;
|
||||||
if (saving.value === 0) {
|
if (saving.value === 0) {
|
||||||
|
|
@ -396,9 +374,9 @@ const saveInput = (answer: string) => {
|
||||||
corrections.value = '';
|
corrections.value = '';
|
||||||
unsaved.value = true;
|
unsaved.value = true;
|
||||||
/*
|
/*
|
||||||
We update the assignment on this component, so the changes are reflected on it. The server does not return
|
We update the assignment on this component, so the changes are reflected on it. The server does not return
|
||||||
the updated entity, to prevent the UI to update when the user is entering his input
|
the updated entity, to prevent the UI to update when the user is entering his input
|
||||||
*/
|
*/
|
||||||
assignment.value.submission.text = answer;
|
assignment.value.submission.text = answer;
|
||||||
_save(assignment.value.submission);
|
_save(assignment.value.submission);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue