From b956d751c9afa47bdb2c55de4bdf5bee0138d7e7 Mon Sep 17 00:00:00 2001 From: izzy lyseggen Date: Fri, 2 Jul 2021 14:40:14 +0100 Subject: [PATCH] feat(subs): subscribe to branch and commit changes - branch created, branch updated, branch deleted, and commit updated - for more seamless user experience! --- src/components/StreamCard.vue | 60 +++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 6 deletions(-) diff --git a/src/components/StreamCard.vue b/src/components/StreamCard.vue index ca55b4d..0d1dcd7 100644 --- a/src/components/StreamCard.vue +++ b/src/components/StreamCard.vue @@ -318,9 +318,7 @@ export default { } `, variables() { - return { - id: this.savedStream.id - } + return { id: this.savedStream.id } }, result() { this.$apollo.queries.stream.refetch() @@ -333,9 +331,7 @@ export default { } `, variables() { - return { - streamId: this.savedStream.id - } + return { streamId: this.savedStream.id } }, result(commitInfo) { this.$apollo.queries.stream.refetch() @@ -344,6 +340,58 @@ export default { message: `New commit on ${this.stream.name} @ ${commitInfo.data.commitCreated.branchName}` }) } + }, + commitUpdated: { + query: gql` + subscription($id: String!) { + commitUpdated(streamId: $id) + } + `, + variables() { + return { id: this.savedStream.id } + }, + result() { + this.$apollo.queries.stream.refetch() + } + }, + branchCreated: { + query: gql` + subscription($id: String!) { + branchCreated(streamId: $id) + } + `, + variables() { + return { id: this.savedStream.id } + }, + result() { + this.$apollo.queries.stream.refetch() + } + }, + branchDeleted: { + query: gql` + subscription($id: String!) { + branchDeleted(streamId: $id) + } + `, + variables() { + return { id: this.savedStream.id } + }, + result() { + this.$apollo.queries.stream.refetch() + } + }, + branchUpdated: { + query: gql` + subscription($id: String!) { + branchUpdated(streamId: $id) + } + `, + variables() { + return { id: this.savedStream.id } + }, + result() { + this.$apollo.queries.stream.refetch() + } } } },