Fix snapshot list bug
This commit is contained in:
parent
be651c0489
commit
40f0f1cfb8
|
|
@ -141,10 +141,12 @@ describe('Snapshot', () => {
|
|||
CreateSnapshot: {
|
||||
createSnapshot: {
|
||||
snapshot: {
|
||||
id: '',
|
||||
title: '',
|
||||
created: '',
|
||||
creator: '',
|
||||
id: 'snapshot-id',
|
||||
title: 'Mi Snapshot',
|
||||
created: '2022-01-01',
|
||||
creator: 'me',
|
||||
shared: false,
|
||||
mine: true
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -39,6 +39,7 @@
|
|||
import me from '@/mixins/me';
|
||||
|
||||
import CREATE_SNAPSHOT_MUTATION from '@/graphql/gql/mutations/createSnapshot.gql';
|
||||
import MODULE_SNAPSHOTS_QUERY from '@/graphql/gql/queries/moduleSnapshots.gql';
|
||||
|
||||
export default {
|
||||
mixins: [me],
|
||||
|
|
@ -66,10 +67,38 @@
|
|||
selectedClass: this.me.selectedClass.id,
|
||||
},
|
||||
},
|
||||
update: (store, {data: {createSnapshot: {snapshot}}}) => {
|
||||
const slug = this.$route.params.slug;
|
||||
const query = MODULE_SNAPSHOTS_QUERY;
|
||||
const variables = {
|
||||
slug,
|
||||
};
|
||||
const cached = store.readQuery({
|
||||
query,
|
||||
variables,
|
||||
});
|
||||
if (cached) {
|
||||
const {module} = cached;
|
||||
const data = {
|
||||
module: {
|
||||
...module,
|
||||
snapshots: [
|
||||
snapshot,
|
||||
...module.snapshots,
|
||||
],
|
||||
}
|
||||
};
|
||||
store.writeQuery({
|
||||
query,
|
||||
variables,
|
||||
data,
|
||||
});
|
||||
}
|
||||
},
|
||||
}).then(({data: {createSnapshot: {snapshot}}}) => {
|
||||
this.showPopover = false;
|
||||
this.$modal.open('snapshot-created', {
|
||||
snapshot
|
||||
snapshot,
|
||||
});
|
||||
});
|
||||
},
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
fragment SnapshotParts on SnapshotNode {
|
||||
id
|
||||
title
|
||||
created
|
||||
mine
|
||||
shared
|
||||
creator
|
||||
}
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
#import "../fragments/snapshotParts.gql"
|
||||
mutation CreateSnapshot($input: CreateSnapshotInput!) {
|
||||
createSnapshot(input: $input) {
|
||||
snapshot {
|
||||
id
|
||||
title
|
||||
created
|
||||
creator
|
||||
...SnapshotParts
|
||||
}
|
||||
success
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#import "../fragments/snapshotParts.gql"
|
||||
query ModuleSnapshotsQuery($slug: String!) {
|
||||
module(slug: $slug) {
|
||||
id
|
||||
|
|
@ -8,12 +9,7 @@ query ModuleSnapshotsQuery($slug: String!) {
|
|||
title
|
||||
}
|
||||
snapshots {
|
||||
id
|
||||
title
|
||||
created
|
||||
mine
|
||||
shared
|
||||
creator
|
||||
...SnapshotParts
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue