Fix assignment submission bug on navigation
This commit is contained in:
parent
543a9ea6e9
commit
365002f800
|
|
@ -91,16 +91,32 @@
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
_save: debounce(function () {
|
_save: debounce(function () {
|
||||||
|
const assignment = this.assignment;
|
||||||
this.$apollo.mutate({
|
this.$apollo.mutate({
|
||||||
mutation: UPDATE_ASSIGNMENT_MUTATION_WITH_SUCCESS,
|
mutation: UPDATE_ASSIGNMENT_MUTATION_WITH_SUCCESS,
|
||||||
variables: {
|
variables: {
|
||||||
input: {
|
input: {
|
||||||
assignment: {
|
assignment: {
|
||||||
id: this.assignment.id,
|
id: assignment.id,
|
||||||
answer: this.assignment.submission.text,
|
answer: assignment.submission.text,
|
||||||
document: this.assignment.submission.document,
|
document: assignment.submission.document,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
update(store, {data: {updateAssignment: {successful}}}) {
|
||||||
|
try {
|
||||||
|
if (successful) {
|
||||||
|
const query = ASSIGNMENT_QUERY;
|
||||||
|
const variables = {
|
||||||
|
id: assignment.id
|
||||||
|
};
|
||||||
|
const data = store.readQuery({query, variables});
|
||||||
|
data.assignment = Object.assign({}, assignment);
|
||||||
|
store.writeQuery({query, variables, data});
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// Query did not exist in the cache, and apollo throws a generic Error. Do nothing
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.unsaved = false;
|
this.unsaved = false;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue