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) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue