Skip to content

Commit

Permalink
Fix some events not being registered/unregistered properly when switc…
Browse files Browse the repository at this point in the history
…hing views
  • Loading branch information
Fajfa committed Jun 30, 2023
1 parent f7dbefb commit 1cd5c22
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default {
}),
},
created () {
mounted () {
this.fetchReminders()
// @todo remove this, when sockets get implemented
this.$root.$on('reminders.pull', this.fetchReminders)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,11 @@ export default {
},
},
created () {
mounted () {
this.$root.$on('builder-createRequestFulfilled', this.createRequestFulfilled)
},
destroyed () {
beforeDestroy () {
this.$root.$off('builder-createRequestFulfilled', this.createRequestFulfilled)
},
Expand Down
4 changes: 2 additions & 2 deletions client/web/compose/src/components/Public/Page/Block/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ export default {
},
},
created () {
mounted () {
this.$root.$on('magnify-page-block', this.magnifyPageBlock)
},
destroyed () {
beforeDestroy () {
this.$root.$off('magnify-page-block', this.magnifyPageBlock)
},
Expand Down
2 changes: 1 addition & 1 deletion client/web/compose/src/components/Public/Record/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export default {
},
},
created () {
mounted () {
this.$root.$on('show-record-modal', ({ recordID, recordPageID }) => {
this.$router.push({
query: {
Expand Down
9 changes: 3 additions & 6 deletions client/web/compose/src/views/Admin/Pages/Builder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -456,16 +456,13 @@ export default {
},
},
created () {
mounted () {
window.addEventListener('paste', this.pasteBlock)
this.$root.$on('tab-editRequest', this.fulfilEditRequest)
this.$root.$on('tab-createRequest', this.fulfilCreateRequest)
this.$root.$on('tabChange', this.untabBlock)
},
mounted () {
window.addEventListener('paste', this.pasteBlock)
},
beforeRouteUpdate (to, from, next) {
this.checkUnsavedBlocks(next)
},
Expand All @@ -474,7 +471,7 @@ export default {
this.checkUnsavedBlocks(next)
},
destroyed () {
beforeDestroy () {
window.removeEventListener('paste', this.pasteBlock)
this.$root.$off('tab-editRequest', this.fulfilEditRequest)
this.$root.$off('tab-createRequest', this.fulfilCreateRequest)
Expand Down
6 changes: 5 additions & 1 deletion client/web/compose/src/views/Public/Pages/Records/View.vue
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export default {
},
},
created () {
mounted () {
this.$root.$on('refetch-record-blocks', () => {
// Don*t refresh when creating and prompt user before refreshing when editing
if (this.inCreating || (this.inEditing && !window.confirm(this.$t('notification:record.staleDataRefresh')))) {
Expand All @@ -265,6 +265,10 @@ export default {
})
},
beforeDestroy () {
this.$root.$off('refetch-record-blocks')
},
// Destroy event before route leave to ensure it doesn't destroy the newly created one
beforeRouteLeave (to, from, next) {
this.$root.$off('refetch-record-blocks')
Expand Down
2 changes: 1 addition & 1 deletion client/web/compose/src/views/Public/Pages/View.vue
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export default {
},
},
created () {
mounted () {
this.$root.$on('refetch-records', () => {
// If on a record page, let it take care of events else just refetch non record-blocks (that use records)
this.$root.$emit(this.page.moduleID !== NoID ? 'refetch-record-blocks' : `refetch-non-record-blocks:${this.page.pageID}`)
Expand Down

0 comments on commit 1cd5c22

Please sign in to comment.