Move socket listeners into app.js

This commit is contained in:
RemixDev 2022-07-29 19:55:43 +02:00
parent 2f9eabc3db
commit c2e9ecfeec
2 changed files with 10 additions and 16 deletions

View File

@ -158,14 +158,6 @@ function setClientModeKeyBindings() {
} }
}) })
} }
/* ===== Socketio listeners ===== */
// Debug messages for socketio
socket.on('message', function (msg) {
console.log(msg)
})
function loggedIn(data) { function loggedIn(data) {
const { status, user } = data const { status, user } = data
@ -201,6 +193,12 @@ function loggedIn(data) {
} }
} }
/* ===== Socketio listeners ===== */
// Debug messages for socketio
socket.on('message', function (msg) {
console.log(msg)
})
socket.on('restoringQueue', function () { socket.on('restoringQueue', function () {
toast(i18n.t('toasts.restoringQueue'), 'loading', false, 'restoring_queue') toast(i18n.t('toasts.restoringQueue'), 'loading', false, 'restoring_queue')
}) })
@ -256,3 +254,7 @@ socket.on('startGeneratingItems', function (data) {
socket.on('finishGeneratingItems', function (data) { socket.on('finishGeneratingItems', function (data) {
toast(i18n.t('toasts.finishGeneratingItems', { n: data.total }), 'done', true, 'batch_' + data.uuid) toast(i18n.t('toasts.finishGeneratingItems', { n: data.total }), 'done', true, 'batch_' + data.uuid)
}) })
socket.on('toast', data => {
const { msg, icon, dismiss, id } = data
toast(msg, icon || null, dismiss !== undefined ? dismiss : true, id || null)
})

View File

@ -2,8 +2,6 @@ import Toastify from 'toastify-js'
import 'toastify-js/src/toastify.css' import 'toastify-js/src/toastify.css'
import '@/styles/css/toasts.css' import '@/styles/css/toasts.css'
import { socket } from '@/utils/socket'
const sharedOptions = { const sharedOptions = {
gravity: 'bottom', gravity: 'bottom',
position: 'left' position: 'left'
@ -118,9 +116,3 @@ export const toast = function (msg, icon = null, dismiss = true, id = null) {
} }
} }
} }
socket.on('toast', data => {
const { msg, icon, dismiss, id } = data
toast(msg, icon || null, dismiss !== undefined ? dismiss : true, id || null)
})