diff options
author | Joas Schilling <coding@schilljs.com> | 2021-08-30 16:51:57 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2021-08-30 16:51:57 +0300 |
commit | d0ec78e78e8bd8e7f5117c9417f2bea66c15b92a (patch) | |
tree | b004864bebce6eedd307d61e6cb557dfa39b90cc /src/store | |
parent | d1873a40d5bfe383b5449c2a709717f000c72cbd (diff) |
Finish the stores
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'src/store')
-rw-r--r-- | src/store/callViewStore.js | 7 | ||||
-rw-r--r-- | src/store/conversationsStore.js | 11 | ||||
-rw-r--r-- | src/store/fileUploadStore.js | 58 | ||||
-rw-r--r-- | src/store/guestNameStore.js | 24 | ||||
-rw-r--r-- | src/store/messagesStore.js | 111 | ||||
-rw-r--r-- | src/store/newGroupConversationStore.js | 4 | ||||
-rw-r--r-- | src/store/participantsStore.js | 39 | ||||
-rw-r--r-- | src/store/quoteReplyStore.js | 10 | ||||
-rw-r--r-- | src/store/tokenStore.js | 10 | ||||
-rw-r--r-- | src/store/uiModeStore.js | 4 |
10 files changed, 148 insertions, 130 deletions
diff --git a/src/store/callViewStore.js b/src/store/callViewStore.js index 05d9b311b..c63f7488b 100644 --- a/src/store/callViewStore.js +++ b/src/store/callViewStore.js @@ -140,9 +140,10 @@ const actions = { * If clearLast is false, also remembers it in separate properties. * * @param {object} context default store context; - * @param {boolean|null} isGrid true for enabled grid mode, false for speaker view; - * @param {boolean|null} isStripeOpen true for visible stripel mode, false for speaker view; - * @param {boolean} clearLast set to false to not reset last temporary remembered state; + * @param {object} data the wrapping object; + * @param {boolean|null} data.isGrid true for enabled grid mode, false for speaker view; + * @param {boolean|null} data.isStripeOpen true for visible stripel mode, false for speaker view; + * @param {boolean} data.clearLast set to false to not reset last temporary remembered state; */ setCallViewMode(context, { isGrid = null, isStripeOpen = null, clearLast = true }) { if (clearLast) { diff --git a/src/store/conversationsStore.js b/src/store/conversationsStore.js index 4bef78e5c..31a3caf3b 100644 --- a/src/store/conversationsStore.js +++ b/src/store/conversationsStore.js @@ -78,8 +78,7 @@ const getters = { * Get a conversation providing it's token * * @param {object} state state object - * @return {Function} The callback function - * @return {object} The conversation object + * @return {Function} The callback function returning the conversation object */ conversation: state => token => state.conversations[token], dummyConversation: state => Object.assign({}, DUMMY_CONVERSATION), @@ -192,8 +191,8 @@ const actions = { * Delete a conversation from the server. * * @param {object} context default store context; - * @param token.token - * @param {object} token the token of the conversation to be deleted; + * @param {object} data the wrapping object; + * @param {object} data.token the token of the conversation to be deleted; */ async deleteConversationFromServer(context, { token }) { await deleteConversation(token) @@ -205,8 +204,8 @@ const actions = { * Delete all the messages from a conversation. * * @param {object} context default store context; - * @param token.token - * @param {object} token the token of the conversation whose history is + * @param {object} data the wrapping object; + * @param {object} data.token the token of the conversation whose history is * to be cleared; */ async clearConversationHistory(context, { token }) { diff --git a/src/store/fileUploadStore.js b/src/store/fileUploadStore.js index 93ec22a6b..0cf8f7c40 100644 --- a/src/store/fileUploadStore.js +++ b/src/store/fileUploadStore.js @@ -189,12 +189,15 @@ const actions = { /** * Initialises uploads and shares files to a conversation * - * @param files.commit - * @param files.dispatch - * @param {object} files the files to be processed - * @param {string} token the conversation's token where to share the files - * @param {number} uploadId a unique id for the upload operation indexing - * @param {boolean} rename whether to rename the files (usually after pasting) + * @param {object} context the wrapping object. + * @param {Function} context.commit the contexts commit function. + * @param {Function} context.dispatch the contexts dispatch function. + * @param {object} data the wrapping object; + * @param {object} data.files the files to be processed + * @param {string} data.token the conversation's token where to share the files + * @param {number} data.uploadId a unique id for the upload operation indexing + * @param {boolean} data.rename whether to rename the files (usually after pasting) + * @param {boolean} data.isVoiceMessage whether the file is a voice recording */ async initialiseUpload({ commit, dispatch }, { uploadId, token, files, rename = false, isVoiceMessage }) { // Set last upload id @@ -233,13 +236,12 @@ const actions = { /** * Discards an upload * - * @param {object} param0 Commit and state - * @param param0.commit - * @param param0.state + * @param {object} context the wrapping object. + * @param {Function} context.commit the contexts commit function. + * @param {object} context.state the contexts state object. * @param {object} uploadId The unique uploadId - * @param param0.getters */ - discardUpload({ commit, state, getters }, uploadId) { + discardUpload({ commit, state }, uploadId) { if (state.currentUploadId === uploadId) { commit('setCurrentUploadId', undefined) } @@ -250,12 +252,12 @@ const actions = { /** * Uploads the files to the root directory of the user * - * @param {object} param0 Commit, state and getters - * @param param0.commit - * @param param0.dispatch - * @param {object} uploadId The unique uploadId - * @param param0.state - * @param param0.getters + * @param {object} context the wrapping object. + * @param {Function} context.commit the contexts commit function. + * @param {Function} context.dispatch the contexts dispatch function. + * @param {object} context.getters the contexts getters object. + * @param {object} context.state the contexts state object. + * @param {string} uploadId The unique uploadId */ async uploadFiles({ commit, dispatch, state, getters }, uploadId) { if (state.currentUploadId === uploadId) { @@ -366,12 +368,12 @@ const actions = { /** * Mark a file as shared * - * @param {object} context default store context; - * @param {object} param1 The unique upload id original file index - * @param context.commit - * @param context.state - * @param param1.uploadId - * @param param1.index + * @param {object} context the wrapping object. + * @param {Function} context.commit the contexts commit function. + * @param {object} context.state the contexts state object. + * @param {object} data the wrapping object; + * @param {string} data.uploadId The id of the upload process + * @param {number} data.index The object index inside the upload process * @throws {Error} when the item is already being shared by another async call */ markFileAsSharing({ commit, state }, { uploadId, index }) { @@ -385,9 +387,9 @@ const actions = { * Mark a file as shared * * @param {object} context default store context; - * @param {object} param1 The unique upload id original file index - * @param param1.uploadId - * @param param1.index + * @param {object} data the wrapping object; + * @param {string} data.uploadId The id of the upload process + * @param {number} data.index The object index inside the upload process */ markFileAsShared(context, { uploadId, index }) { context.commit('markFileAsShared', { uploadId, index }) @@ -396,8 +398,8 @@ const actions = { /** * Mark a file as shared * - * @param {object} context default store context; - * @param context.commit + * @param {object} context the wrapping object. + * @param {Function} context.commit the contexts commit function. * @param {string} temporaryMessageId message id of the temporary message associated to the file to remove */ removeFileFromSelection({ commit }, temporaryMessageId) { diff --git a/src/store/guestNameStore.js b/src/store/guestNameStore.js index 88675e903..94f39acc5 100644 --- a/src/store/guestNameStore.js +++ b/src/store/guestNameStore.js @@ -46,10 +46,11 @@ const mutations = { * Adds a guest name to the store * * @param {object} state current store state - * @param {boolean} noUpdate Only set the guest name if it was not set before - * @param {string} token the token of the conversation - * @param {string} actorId the guest - * @param {string} actorDisplayName the display name to set + * @param {object} data the wrapping object; + * @param {boolean} data.noUpdate Only set the guest name if it was not set before + * @param {string} data.token the token of the conversation + * @param {string} data.actorId the guest + * @param {string} data.actorDisplayName the display name to set */ addGuestName(state, { noUpdate, token, actorId, actorDisplayName }) { if (!state.guestNames[token]) { @@ -70,20 +71,23 @@ const actions = { * Add guest name of a chat message to the store * * @param {object} context default store context - * @param {string} token the token of the conversation - * @param {string} actorId the guest - * @param {string} actorDisplayName the display name to set + * @param {object} data the wrapping object; + * @param {string} data.token the token of the conversation + * @param {string} data.actorId the guest + * @param {string} data.actorDisplayName the display name to set */ setGuestNameIfEmpty(context, { token, actorId, actorDisplayName }) { context.commit('addGuestName', { noUpdate: true, token, actorId, actorDisplayName }) }, + /** * Add guest name of a chat message to the store * * @param {object} context default store context - * @param {string} token the token of the conversation - * @param {string} actorId the guest - * @param {string} actorDisplayName the display name to set + * @param {object} data the wrapping object; + * @param {string} data.token the token of the conversation + * @param {string} data.actorId the guest + * @param {string} data.actorDisplayName the display name to set */ forceGuestName(context, { token, actorId, actorDisplayName }) { context.commit('addGuestName', { noUpdate: false, token, actorId, actorDisplayName }) diff --git a/src/store/messagesStore.js b/src/store/messagesStore.js index 5c3be0c55..8e1541d8d 100644 --- a/src/store/messagesStore.js +++ b/src/store/messagesStore.js @@ -262,10 +262,9 @@ const mutations = { * Deletes a message from the store. * * @param {object} state current store state; - * @param message.message - * @param {object} message the message; - * @param {string} placeholder Placeholder message until deleting finished - * @param message.placeholder + * @param {object} data the wrapping object; + * @param {object} data.message the message; + * @param {string} data.placeholder Placeholder message until deleting finished */ markMessageAsDeleting(state, { message, placeholder }) { Vue.set(state.messages[message.token][message.id], 'messageType', 'comment_deleted') @@ -288,10 +287,9 @@ const mutations = { * Adds a temporary message to the store. * * @param {object} state current store state; - * @param message.message - * @param {object} message the temporary message; - * @param {string} reason the reason the temporary message failed; - * @param message.reason + * @param {object} data the wrapping object; + * @param {object} data.message the temporary message; + * @param {string} data.reason the reason the temporary message failed; */ markTemporaryMessageAsFailed(state, { message, reason }) { if (state.messages[message.token][message.id]) { @@ -301,8 +299,9 @@ const mutations = { /** * @param {object} state current store state; - * @param {string} token Token of the conversation - * @param {string} id Id of the first known chat message + * @param {object} data the wrapping object; + * @param {string} data.token Token of the conversation + * @param {string} data.id Id of the first known chat message */ setFirstKnownMessageId(state, { token, id }) { Vue.set(state.firstKnown, token, id) @@ -310,8 +309,9 @@ const mutations = { /** * @param {object} state current store state; - * @param {string} token Token of the conversation - * @param {string} id Id of the last known chat message + * @param {object} data the wrapping object; + * @param {string} data.token Token of the conversation + * @param {string} data.id Id of the last known chat message */ setLastKnownMessageId(state, { token, id }) { Vue.set(state.lastKnown, token, id) @@ -319,8 +319,9 @@ const mutations = { /** * @param {object} state current store state; - * @param {string} token Token of the conversation - * @param {string} id Id of the last read chat message + * @param {object} data the wrapping object; + * @param {string} data.token Token of the conversation + * @param {string} data.id Id of the last read chat message */ setVisualLastReadMessageId(state, { token, id }) { Vue.set(state.visualLastReadMessageId, token, id) @@ -379,10 +380,9 @@ const actions = { * Delete a message * * @param {object} context default store context; - * @param message.message - * @param {object} message the message to be deleted; - * @param {string} placeholder Placeholder message until deleting finished - * @param message.placeholder + * @param {object} data the wrapping object; + * @param {object} data.message the message to be deleted; + * @param {string} data.placeholder Placeholder message until deleting finished */ async deleteMessage(context, { message, placeholder }) { const messageObject = Object.assign({}, context.getters.message(message.token, message.id)) @@ -413,12 +413,14 @@ const actions = { * on the message to be replied and the current actor * * @param {object} context default store context; - * @param {string} text message string; - * @param {string} token conversation token; - * @param {string} uploadId upload id; - * @param {number} index index; - * @param {object} file file to upload; - * @param {string} localUrl local URL of file to upload; + * @param {object} data the wrapping object; + * @param {string} data.text message string; + * @param {string} data.token conversation token; + * @param {string} data.uploadId upload id; + * @param {number} data.index index; + * @param {object} data.file file to upload; + * @param {string} data.localUrl local URL of file to upload; + * @param {boolean} data.isVoiceMessage whether the temporary file is a voice message * @return {object} temporary message */ createTemporaryMessage(context, { text, token, uploadId, index, file, localUrl, isVoiceMessage }) { @@ -484,10 +486,9 @@ const actions = { * Mark a temporary message as failed to allow retrying it again * * @param {object} context default store context; - * @param message.message - * @param {object} message the temporary message; - * @param {string} reason the reason the temporary message failed; - * @param message.reason + * @param {object} data the wrapping object; + * @param {object} data.message the temporary message; + * @param {string} data.reason the reason the temporary message failed; */ markTemporaryMessageAsFailed(context, { message, reason }) { context.commit('markTemporaryMessageAsFailed', { message, reason }) @@ -505,8 +506,9 @@ const actions = { /** * @param {object} context default store context; - * @param {string} token Token of the conversation - * @param {string} id Id of the first known chat message + * @param {object} data the wrapping object; + * @param {string} data.token Token of the conversation + * @param {string} data.id Id of the first known chat message */ setFirstKnownMessageId(context, { token, id }) { context.commit('setFirstKnownMessageId', { token, id }) @@ -514,8 +516,9 @@ const actions = { /** * @param {object} context default store context; - * @param {string} token Token of the conversation - * @param {string} id Id of the last known chat message + * @param {object} data the wrapping object; + * @param {string} data.token Token of the conversation + * @param {string} data.id Id of the last known chat message */ setLastKnownMessageId(context, { token, id }) { context.commit('setLastKnownMessageId', { token, id }) @@ -523,8 +526,9 @@ const actions = { /** * @param {object} context default store context; - * @param {string} token Token of the conversation - * @param {string} id Id of the last read chat message + * @param {object} data the wrapping object; + * @param {string} data.token Token of the conversation + * @param {string} data.id Id of the last read chat message */ setVisualLastReadMessageId(context, { token, id }) { context.commit('setVisualLastReadMessageId', { token, id }) @@ -545,10 +549,9 @@ const actions = { * in the conversation. * * @param {object} context default store context; - * @param token.token - * @param {object} token the token of the conversation to be updated; - * @param {boolean} updateVisually whether to also clear the marker visually in the UI; - * @param token.updateVisually + * @param {object} data the wrapping object; + * @param {object} data.token the token of the conversation to be updated; + * @param {boolean} data.updateVisually whether to also clear the marker visually in the UI; */ async clearLastReadMessage(context, { token, updateVisually = false }) { const conversation = context.getters.conversations[token] @@ -565,12 +568,10 @@ const actions = { * Optionally also updated the marker visually in the UI if specified. * * @param {object} context default store context; - * @param token.token - * @param {object} token the token of the conversation to be updated; - * @param {number} id the id of the message on which to set the read marker; - * @param {boolean} updateVisually whether to also update the marker visually in the UI; - * @param token.id - * @param token.updateVisually + * @param {object} data the wrapping object; + * @param {object} data.token the token of the conversation to be updated; + * @param {number} data.id the id of the message on which to set the read marker; + * @param {boolean} data.updateVisually whether to also update the marker visually in the UI; */ async updateLastReadMessage(context, { token, id = 0, updateVisually = false }) { const conversation = context.getters.conversations[token] @@ -599,10 +600,11 @@ const actions = { * specified with its token. * * @param {object} context default store context; - * @param {string} token the conversation token; - * @param {object} requestOptions request options; - * @param {string} lastKnownMessageId last known message id; - * @param {boolean} includeLastKnown whether to include the last known message in the response; + * @param {object} data the wrapping object; + * @param {string} data.token the conversation token; + * @param {object} data.requestOptions request options; + * @param {string} data.lastKnownMessageId last known message id; + * @param {boolean} data.includeLastKnown whether to include the last known message in the response; */ async fetchMessages(context, { token, lastKnownMessageId, includeLastKnown, requestOptions }) { context.dispatch('cancelFetchMessages') @@ -681,10 +683,11 @@ const actions = { * This call will long-poll when hasMoreMessagesToLoad() returns false. * * @param {object} context default store context; - * @param {string} token The conversation token; - * @param {string} requestId id to identify request uniquely - * @param {object} requestOptions request options; - * @param {number} lastKnownMessageId The id of the last message in the store. + * @param {object} data the wrapping object; + * @param {string} data.token The conversation token; + * @param {string} data.requestId id to identify request uniquely + * @param {object} data.requestOptions request options; + * @param {number} data.lastKnownMessageId The id of the last message in the store. */ async lookForNewMessages(context, { token, lastKnownMessageId, requestId, requestOptions }) { context.dispatch('cancelLookForNewMessages', { requestId }) @@ -902,8 +905,8 @@ const actions = { * * @param {object} context default store context; * will be forwarded; - * @param {object} message the message object; - * @param message.messageToBeForwarded + * @param {object} data the wrapping object; + * @param {object} data.messageToBeForwarded the message object; */ async forwardMessage(context, { messageToBeForwarded }) { const response = await postNewMessage(messageToBeForwarded) diff --git a/src/store/newGroupConversationStore.js b/src/store/newGroupConversationStore.js index 63257d2e1..2682f2e87 100644 --- a/src/store/newGroupConversationStore.js +++ b/src/store/newGroupConversationStore.js @@ -85,8 +85,8 @@ const actions = { * Adds or removes the participant to the selected participants array * * @param {object} context default store context; - * @param context.commit - * @param context.state + * @param {Function} context.commit the contexts commit function. + * @param {object} context.state the contexts state object. * @param {object} participant the clicked participant; */ updateSelectedParticipants({ commit, state }, participant) { diff --git a/src/store/participantsStore.js b/src/store/participantsStore.js index 5fa13a44e..0123b33d5 100644 --- a/src/store/participantsStore.js +++ b/src/store/participantsStore.js @@ -112,10 +112,9 @@ const mutations = { * Adds a message to the store. * * @param {object} state current store state; - * @param token.token - * @param {object} token the token of the conversation; - * @param {object} participant the participant; - * @param token.participant + * @param {object} data the wrapping object; + * @param {object} data.token the token of the conversation; + * @param {object} data.participant the participant; */ addParticipant(state, { token, participant }) { if (!state.participants[token]) { @@ -196,9 +195,10 @@ const actions = { * Only call this after purgeParticipantsStore, otherwise use addParticipantOnce * * @param {object} context default store context; - * @param context.commit - * @param {string} token the conversation to add the participant; - * @param {object} participant the participant; + * @param {Function} context.commit the contexts commit function. + * @param {object} data the wrapping object; + * @param {string} data.token the conversation to add the participant; + * @param {object} data.participant the participant; */ addParticipant({ commit }, { token, participant }) { commit('addParticipant', { token, participant }) @@ -207,10 +207,11 @@ const actions = { * Only add a participant when they are not there yet * * @param {object} context default store context; - * @param context.commit - * @param context.getters - * @param {string} token the conversation to add the participant; - * @param {object} participant the participant; + * @param {Function} context.commit the contexts commit function. + * @param {object} context.getters the contexts getters object. + * @param {object} data the wrapping object; + * @param {string} data.token the conversation to add the participant; + * @param {object} data.participant the participant; */ addParticipantOnce({ commit, getters }, { token, participant }) { const index = getters.getParticipantIndex(token, participant) @@ -265,7 +266,7 @@ const actions = { * Purges a given conversation from the previously added participants * * @param {object} context default store context; - * @param context.commit + * @param {Function} context.commit the contexts commit function. * @param {string} token the conversation to purge; */ purgeParticipantsStore({ commit }, token) { @@ -369,8 +370,9 @@ const actions = { * If no userId is set, send to all applicable participants. * * @param {object} _ unused - * @param {string} token conversation token - * @param {number} attendeeId attendee id to target, or null for all + * @param {object} data the wrapping object; + * @param {string} data.token conversation token + * @param {number} data.attendeeId attendee id to target, or null for all */ async resendInvitations(_, { token, attendeeId }) { await resendInvitations(token, { attendeeId }) @@ -380,7 +382,8 @@ const actions = { * Makes the current user active in the given conversation. * * @param {object} context unused - * @param {string} token conversation token + * @param {object} data the wrapping object; + * @param {string} data.token conversation token */ async joinConversation(context, { token }) { const forceJoin = SessionStorage.getItem('joined_conversation') === token @@ -468,7 +471,8 @@ const actions = { * Makes the current user inactive in the given conversation. * * @param {object} context unused - * @param {string} token conversation token + * @param {object} data the wrapping object; + * @param {string} data.token conversation token */ async leaveConversation(context, { token }) { await leaveConversation(token) @@ -479,7 +483,8 @@ const actions = { * means the user is not a participant any more. * * @param {object} context unused - * @param {string} token conversation token + * @param {object} data the wrapping object; + * @param {string} data.token conversation token */ async removeCurrentUserFromConversation(context, { token }) { await removeCurrentUserFromConversation(token) diff --git a/src/store/quoteReplyStore.js b/src/store/quoteReplyStore.js index 54167fa07..533100ce0 100644 --- a/src/store/quoteReplyStore.js +++ b/src/store/quoteReplyStore.js @@ -71,8 +71,9 @@ const mutations = { * Sets the current message input for a given conversation * * @param {object} state Current store state; - * @param {string} token The conversation token; - * @param {string} text Message text to set or null to clear it; + * @param {object} data the wrapping object; + * @param {string} data.token The conversation token; + * @param {string} data.text Message text to set or null to clear it; */ setCurrentMessageInput(state, { token, text = null }) { if (text !== null) { @@ -123,8 +124,9 @@ const actions = { * Stores the current message input for a given conversation * * @param {object} context default store context; - * @param {string} token the token of the conversation to be deleted; - * @param {string} text string to set or null to clear it; + * @param {object} data the wrapping object; + * @param {string} data.token the token of the conversation to be deleted; + * @param {string} data.text string to set or null to clear it; */ setCurrentMessageInput(context, { token, text }) { context.commit('setCurrentMessageInput', { token, text }) diff --git a/src/store/tokenStore.js b/src/store/tokenStore.js index 6276f708b..9be124f3c 100644 --- a/src/store/tokenStore.js +++ b/src/store/tokenStore.js @@ -60,8 +60,9 @@ const mutations = { * Updates the file ID for the current token * * @param {object} state current store state - * @param {string} newToken The token of the active conversation - * @param {number} newFileId The file ID of the active conversation + * @param {object} data the wrapping object; + * @param {string} data.newToken The token of the active conversation + * @param {number} data.newFileId The file ID of the active conversation */ updateTokenAndFileIdForToken(state, { newToken, newFileId }) { state.token = newToken @@ -89,8 +90,9 @@ const actions = { * Updates the file ID for the current token * * @param {object} context default store context - * @param {string} newToken The token of the active conversation - * @param {number} newFileId The file ID of the active conversation + * @param {object} data the wrapping object; + * @param {string} data.newToken The token of the active conversation + * @param {number} data.newFileId The file ID of the active conversation */ updateTokenAndFileIdForToken(context, { newToken, newFileId }) { context.commit('updateTokenAndFileIdForToken', { newToken, newFileId }) diff --git a/src/store/uiModeStore.js b/src/store/uiModeStore.js index f780fbd61..eeff51141 100644 --- a/src/store/uiModeStore.js +++ b/src/store/uiModeStore.js @@ -3,7 +3,7 @@ * * @author Daniel Calviño Sánchez <danxuliu@gmail.com> * - * @license GNU AGPL version 3 or any later version + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -49,7 +49,7 @@ const actions = { * By default the container selector is undefined, which in practice will * cause the components to use "body" as the selector. * - * @param {Object} context default store context + * @param {object} context default store context * @param {string} mainContainerSelector the selector for the container */ setMainContainerSelector(context, mainContainerSelector) { |