From 0604b1d5b7b19db41096876d0d911ea95c3c778f Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Mon, 3 Aug 2020 18:44:35 -0500 Subject: Rename legacy PleromaFE Chat functionality to "Shout" --- src/modules/api.js | 4 ++-- src/modules/chat.js | 34 ---------------------------------- src/modules/instance.js | 6 +++--- src/modules/shout.js | 33 +++++++++++++++++++++++++++++++++ src/modules/users.js | 2 +- 5 files changed, 39 insertions(+), 40 deletions(-) delete mode 100644 src/modules/chat.js create mode 100644 src/modules/shout.js (limited to 'src/modules') diff --git a/src/modules/api.js b/src/modules/api.js index 8654b90a..54f94356 100644 --- a/src/modules/api.js +++ b/src/modules/api.js @@ -255,12 +255,12 @@ const api = { initializeSocket ({ dispatch, commit, state, rootState }) { // Set up websocket connection const token = state.wsToken - if (rootState.instance.chatAvailable && typeof token !== 'undefined' && state.socket === null) { + if (rootState.instance.shoutAvailable && typeof token !== 'undefined' && state.socket === null) { const socket = new Socket('/socket', { params: { token } }) socket.connect() commit('setSocket', socket) - dispatch('initializeChat', socket) + dispatch('initializeShout', socket) } }, disconnectFromSocket ({ commit, state }) { diff --git a/src/modules/chat.js b/src/modules/chat.js deleted file mode 100644 index ffeb272b..00000000 --- a/src/modules/chat.js +++ /dev/null @@ -1,34 +0,0 @@ -const chat = { - state: { - messages: [], - channel: { state: '' } - }, - mutations: { - setChannel (state, channel) { - state.channel = channel - }, - addMessage (state, message) { - state.messages.push(message) - state.messages = state.messages.slice(-19, 20) - }, - setMessages (state, messages) { - state.messages = messages.slice(-19, 20) - } - }, - actions: { - initializeChat (store, socket) { - const channel = socket.channel('chat:public') - - channel.on('new_msg', (msg) => { - store.commit('addMessage', msg) - }) - channel.on('messages', ({ messages }) => { - store.commit('setMessages', messages) - }) - channel.join() - store.commit('setChannel', channel) - } - } -} - -export default chat diff --git a/src/modules/instance.js b/src/modules/instance.js index 96de73ca..0dff256a 100644 --- a/src/modules/instance.js +++ b/src/modules/instance.js @@ -19,7 +19,7 @@ const defaultState = { defaultBanner: '/images/banner.png', background: '/static/aurora_borealis.jpg', collapseMessageWithSubject: false, - disableChat: false, + disableShout: false, greentext: false, hideFilteredStatuses: false, hideMutedPosts: false, @@ -57,7 +57,7 @@ const defaultState = { knownDomains: [], // Feature-set, apparently, not everything here is reported... - chatAvailable: false, + shoutAvailable: false, pleromaChatMessagesAvailable: false, gopherAvailable: false, mediaProxyAvailable: false, @@ -107,7 +107,7 @@ const instance = { case 'name': dispatch('setPageTitle') break - case 'chatAvailable': + case 'shoutAvailable': if (value) { dispatch('initializeSocket') } diff --git a/src/modules/shout.js b/src/modules/shout.js new file mode 100644 index 00000000..c04f08e9 --- /dev/null +++ b/src/modules/shout.js @@ -0,0 +1,33 @@ +const shout = { + state: { + messages: [], + channel: { state: '' } + }, + mutations: { + setChannel (state, channel) { + state.channel = channel + }, + addMessage (state, message) { + state.messages.push(message) + state.messages = state.messages.slice(-19, 20) + }, + setMessages (state, messages) { + state.messages = messages.slice(-19, 20) + } + }, + actions: { + initializeShout (store, socket) { + const channel = socket.channel('shout:public') + channel.on('new_msg', (msg) => { + store.commit('addMessage', msg) + }) + channel.on('messages', ({ messages }) => { + store.commit('setMessages', messages) + }) + channel.join() + store.commit('setChannel', channel) + } + } +} + +export default shout diff --git a/src/modules/users.js b/src/modules/users.js index 8a764a16..2b416f94 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -531,7 +531,7 @@ const users = { if (user.token) { store.dispatch('setWsToken', user.token) - // Initialize the chat socket. + // Initialize the shout socket. store.dispatch('initializeSocket') } -- cgit v1.2.3-70-g09d2 From e0cde9a29bea808f5f4b92dbe79d0552dd5b81ed Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Tue, 1 Jun 2021 14:31:58 -0500 Subject: Keep channel name the same for backwards compatibility --- src/modules/shout.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/shout.js b/src/modules/shout.js index c04f08e9..507a4d83 100644 --- a/src/modules/shout.js +++ b/src/modules/shout.js @@ -17,7 +17,7 @@ const shout = { }, actions: { initializeShout (store, socket) { - const channel = socket.channel('shout:public') + const channel = socket.channel('chat:public') channel.on('new_msg', (msg) => { store.commit('addMessage', msg) }) -- cgit v1.2.3-70-g09d2 From 21477d07e93497a9576b3fc14fbbe8ff61fa0dea Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Tue, 1 Jun 2021 16:51:47 -0500 Subject: This setting didn't actually do anything --- src/modules/instance.js | 1 - static/config.json | 1 - 2 files changed, 2 deletions(-) (limited to 'src/modules') diff --git a/src/modules/instance.js b/src/modules/instance.js index 0dff256a..539b9c66 100644 --- a/src/modules/instance.js +++ b/src/modules/instance.js @@ -19,7 +19,6 @@ const defaultState = { defaultBanner: '/images/banner.png', background: '/static/aurora_borealis.jpg', collapseMessageWithSubject: false, - disableShout: false, greentext: false, hideFilteredStatuses: false, hideMutedPosts: false, diff --git a/static/config.json b/static/config.json index 0574b50e..53a4be82 100644 --- a/static/config.json +++ b/static/config.json @@ -2,7 +2,6 @@ "alwaysShowSubjectInput": true, "background": "/static/aurora_borealis.jpg", "collapseMessageWithSubject": false, - "disableShout": false, "greentext": false, "hideFilteredStatuses": false, "hideMutedPosts": false, -- cgit v1.2.3-70-g09d2