diff options
author | Joas Schilling <coding@schilljs.com> | 2021-08-30 15:51:57 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2021-08-30 15:51:57 +0200 |
commit | d0ec78e78e8bd8e7f5117c9417f2bea66c15b92a (patch) | |
tree | b004864bebce6eedd307d61e6cb557dfa39b90cc | |
parent | d1873a40d5bfe383b5449c2a709717f000c72cbd (diff) |
Finish the stores
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | src/init.js | 2 | ||||
-rw-r--r-- | src/services/conversationsService.js | 2 | ||||
-rw-r--r-- | src/services/filesIntegrationServices.js | 2 | ||||
-rw-r--r-- | src/services/messagesService.js | 6 | ||||
-rw-r--r-- | src/services/participantsService.js | 2 | ||||
-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 |
15 files changed, 155 insertions, 137 deletions
diff --git a/src/init.js b/src/init.js index e2789c323..0fe2418c6 100644 --- a/src/init.js +++ b/src/init.js @@ -33,7 +33,7 @@ if (!window.OCA.Talk) { /** * Frontend message API for adding actions to talk messages. * - * @param {object} data the wrapping object. + * @param {object} data the wrapping object; * @param {string} data.label the action label. * @param {Function} data.callback the callback function. This function will receive * the messageAPIData object as a parameter and be triggered by a click on the diff --git a/src/services/conversationsService.js b/src/services/conversationsService.js index 49cb4fb22..fffbb9005 100644 --- a/src/services/conversationsService.js +++ b/src/services/conversationsService.js @@ -62,7 +62,7 @@ const searchListedConversations = async function({ searchText }, options) { /** * Fetch possible conversations * - * @param {object} data the wrapping object. + * @param {object} data the wrapping object; * @param {string} data.searchText The string that will be used in the search query. * @param {string} [data.token] The token of the conversation (if any), or "new" for a new one * @param {boolean} [data.onlyUsers] Only return users diff --git a/src/services/filesIntegrationServices.js b/src/services/filesIntegrationServices.js index 64c7a4aec..8b4964359 100644 --- a/src/services/filesIntegrationServices.js +++ b/src/services/filesIntegrationServices.js @@ -26,7 +26,7 @@ import { generateOcsUrl } from '@nextcloud/router' /** * Gets the conversation token for a given file id * - * @param {object} data the wrapping object. + * @param {object} data the wrapping object; * @param {number} data.fileId The file id to get the conversation for * @param {object} options unused * @return {string} the conversation token diff --git a/src/services/messagesService.js b/src/services/messagesService.js index 849c881f0..f9d29a713 100644 --- a/src/services/messagesService.js +++ b/src/services/messagesService.js @@ -29,7 +29,7 @@ import Hex from 'crypto-js/enc-hex' * Fetches messages that belong to a particular conversation * specified with its token. * - * @param {object} data the wrapping object. + * @param {object} data the wrapping object; * @param {string} data.token the conversation token; * @param {string} data.lastKnownMessageId last known message id; * @param {boolean} data.includeLastKnown whether to include the last known message in the response; @@ -50,7 +50,7 @@ const fetchMessages = async function({ token, lastKnownMessageId, includeLastKno * Fetches newly created messages that belong to a particular conversation * specified with its token. * - * @param {object} data the wrapping object. + * @param {object} data the wrapping object; * @param {number} data.lastKnownMessageId The id of the last message in the store. * @param {string} data.token The conversation token; * @param {object} options options @@ -101,7 +101,7 @@ const deleteMessage = async function({ token, id }) { * Post a rich object to a conversation * * @param {string} token conversation token - * @param {object} data the wrapping object. + * @param {object} data the wrapping object; * @param {string} data.objectType object type * @param {string} data.objectId object id * @param {string} data.metaData JSON metadata of the rich object encoded as string diff --git a/src/services/participantsService.js b/src/services/participantsService.js index 3b50b54d8..286a4552f 100644 --- a/src/services/participantsService.js +++ b/src/services/participantsService.js @@ -33,7 +33,7 @@ import { * Joins the current user to a conversation specified with * the token. * - * @param {object} data the wrapping object. + * @param {object} data the wrapping object; * @param {string} data.token The conversation token; * @param {boolean} data.forceJoin whether to force join; * @param {options} options request options; 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, las |