feat: Show refresh modal on action cable disconnect (#4010)
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import globalConfigMixin from 'shared/mixins/globalConfigMixin';
|
import globalConfigMixin from 'shared/mixins/globalConfigMixin';
|
||||||
import { mapGetters } from 'vuex';
|
import { mapGetters } from 'vuex';
|
||||||
|
import { BUS_EVENTS } from 'shared/constants/busEvents';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [globalConfigMixin],
|
mixins: [globalConfigMixin],
|
||||||
@@ -46,6 +47,9 @@ export default {
|
|||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
window.addEventListener('offline', this.updateOnlineStatus);
|
window.addEventListener('offline', this.updateOnlineStatus);
|
||||||
|
window.bus.$on(BUS_EVENTS.WEBSOCKET_DISCONNECT, () => {
|
||||||
|
this.updateOnlineStatus({ type: 'offline' });
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
|
|||||||
@@ -5,4 +5,5 @@ export const BUS_EVENTS = {
|
|||||||
FOCUS_CUSTOM_ATTRIBUTE: 'FOCUS_CUSTOM_ATTRIBUTE',
|
FOCUS_CUSTOM_ATTRIBUTE: 'FOCUS_CUSTOM_ATTRIBUTE',
|
||||||
SCROLL_TO_MESSAGE: 'SCROLL_TO_MESSAGE',
|
SCROLL_TO_MESSAGE: 'SCROLL_TO_MESSAGE',
|
||||||
TOGGLE_SIDEMENU: 'TOGGLE_SIDEMENU',
|
TOGGLE_SIDEMENU: 'TOGGLE_SIDEMENU',
|
||||||
|
WEBSOCKET_DISCONNECT: 'WEBSOCKET_DISCONNECT',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { createConsumer } from '@rails/actioncable';
|
import { createConsumer } from '@rails/actioncable';
|
||||||
|
import { BUS_EVENTS } from 'shared/constants/busEvents';
|
||||||
|
|
||||||
const PRESENCE_INTERVAL = 20000;
|
const PRESENCE_INTERVAL = 20000;
|
||||||
|
|
||||||
@@ -18,6 +19,7 @@ class BaseActionCableConnector {
|
|||||||
this.perform('update_presence');
|
this.perform('update_presence');
|
||||||
},
|
},
|
||||||
received: this.onReceived,
|
received: this.onReceived,
|
||||||
|
disconnected: this.onDisconnected,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.app = app;
|
this.app = app;
|
||||||
@@ -33,6 +35,11 @@ class BaseActionCableConnector {
|
|||||||
this.consumer.disconnect();
|
this.consumer.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line class-methods-use-this
|
||||||
|
onDisconnected() {
|
||||||
|
window.bus.$emit(BUS_EVENTS.WEBSOCKET_DISCONNECT);
|
||||||
|
}
|
||||||
|
|
||||||
onReceived = ({ event, data } = {}) => {
|
onReceived = ({ event, data } = {}) => {
|
||||||
if (this.isAValidEvent(data)) {
|
if (this.isAValidEvent(data)) {
|
||||||
if (this.events[event] && typeof this.events[event] === 'function') {
|
if (this.events[event] && typeof this.events[event] === 'function') {
|
||||||
|
|||||||
Reference in New Issue
Block a user