Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#474 Start/stop notifications processing #489

Merged
merged 1 commit into from
May 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ export default {
return this.$store.state.auth.currentUser.displayName ? this.$store.state.auth.currentUser.displayName : this.$store.state.auth.currentUser.email;
},
},
created() {
this.$store.dispatch('services/bind');
},
destroyed() {
this.$store.dispatch('services/unbind');
},
methods: {
signOut() {
auth().signOut();
Expand Down
2 changes: 2 additions & 0 deletions src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Vue.use(Vuex);

// Vuex modules
import auth from '@/store/auth';
import services from '@/store/services';
import exerciseCollection from '@/store/exercise/collection';
import exerciseCreateJourney from '@/store/exercise/createJourney';
import exerciseDocument from '@/store/exercise/document';
Expand All @@ -23,6 +24,7 @@ const store = new Vuex.Store({
strict: process.env.NODE_ENV !== 'production',
modules: {
auth,
services,
exerciseCollection,
exerciseCreateJourney,
exerciseDocument,
Expand Down
29 changes: 29 additions & 0 deletions src/store/services.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { firestore } from '@/firebase';
import { firestoreAction } from 'vuexfire';
import vuexfireSerialize from '@/helpers/vuexfireSerialize';

export default {
namespaced: true,
actions: {
bind: firestoreAction(({ bindFirestoreRef }) => {
const firestoreRef = firestore.doc('settings/services');
return bindFirestoreRef('record', firestoreRef, { serialize: vuexfireSerialize });
}),
unbind: firestoreAction(({ unbindFirestoreRef }) => {
return unbindFirestoreRef('record');
}),
notificationsStart() {
return firestore.doc('settings/services').update({
'notifications.isProcessing': true,
});
},
notificationsStop() {
return firestore.doc('settings/services').update({
'notifications.isProcessing': false,
});
},
},
state: {
record: null,
},
};
13 changes: 4 additions & 9 deletions src/views/NotificationsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ export default {
},
],
activeTab: 'queue',
processing: false,
};
},
computed: {
Expand All @@ -169,24 +168,20 @@ export default {
return this.currentView === 'sent';
},
isProcessing() {
return this.processing;
const services = this.$store.state.services.record;
return services && services.notifications && services.notifications.isProcessing;
},
},
created() {
this.$store.dispatch('notifications/bindQueue');
this.$store.dispatch('notifications/bindSent');
},
methods: {
showTab(tab) {
this.currentView = tab;
},
startProcessing() {
this.processing = !this.processing;
console.log('start processing');
this.$store.dispatch('services/notificationsStart');
},
stopProcessing() {
this.processing = !this.processing;
console.log('stop processing');
this.$store.dispatch('services/notificationsStop');
},
},
};
Expand Down