Clean up code
This commit is contained in:
parent
f3eb6ded51
commit
cabbceb843
|
|
@ -11,8 +11,6 @@
|
|||
import NEW_ROOM_ENTRY_MUTATION from '@/graphql/gql/mutations/addRoomEntry.gql';
|
||||
import ROOM_ENTRIES_QUERY from '@/graphql/gql/roomEntriesQuery.gql';
|
||||
|
||||
import store from '@/store/index';
|
||||
|
||||
import ContentsForm from '@/components/content-block-form/ContentsForm';
|
||||
|
||||
export default {
|
||||
|
|
@ -30,6 +28,12 @@
|
|||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
room() {
|
||||
return this.$store.state.parentRoom;
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
saveEntry(entry) {
|
||||
this.$apollo.mutate({
|
||||
|
|
@ -37,14 +41,14 @@
|
|||
variables: {
|
||||
input: {
|
||||
roomEntry: Object.assign({}, entry, {
|
||||
room: store.state.parentRoom.id
|
||||
room: this.room.id
|
||||
})
|
||||
}
|
||||
},
|
||||
update: (store, {data: {addRoomEntry: {roomEntry}}}) => {
|
||||
try {
|
||||
const query = ROOM_ENTRIES_QUERY;
|
||||
const variables = {slug: this.$store.state.parentRoom.slug};
|
||||
const variables = {slug: this.room.slug};
|
||||
const data = store.readQuery({query, variables});
|
||||
if (data.room && data.room.roomEntries) {
|
||||
data.room.roomEntries.edges.push({
|
||||
|
|
@ -54,7 +58,6 @@
|
|||
store.writeQuery({query, variables, data});
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
// Query did not exist in the cache, and apollo throws a generic Error. Do nothing
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue