Skip to content

Commit

Permalink
chore(vue3): remove $set/$delete
Browse files Browse the repository at this point in the history
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
  • Loading branch information
ShGKme committed May 15, 2024
1 parent 1336369 commit d114f80
Show file tree
Hide file tree
Showing 18 changed files with 163 additions and 185 deletions.
4 changes: 2 additions & 2 deletions src/components/CallView/CallView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ export default {
removedModelIds.forEach(removedModelId => {
this.sharedDatas[removedModelId].remoteVideoBlocker.destroy()

this.$delete(this.sharedDatas, removedModelId)
delete this.sharedDatas[removedModelId]

this.speakingUnwatchers[removedModelId]()
// Not reactive, but not a problem
Expand All @@ -485,7 +485,7 @@ export default {
screenVisible: false,
}

this.$set(this.sharedDatas, addedModel.attributes.peerId, sharedData)
this.sharedDatas[addedModel.attributes.peerId] = sharedData

// Not reactive, but not a problem
this.speakingUnwatchers[addedModel.attributes.peerId] = this.$watch(function() {
Expand Down
5 changes: 1 addition & 4 deletions src/components/ConversationSettings/BotsSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
</template>

<script>

import Vue from 'vue'

import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'

import { BOT } from '../../constants.js'
Expand Down Expand Up @@ -87,7 +84,7 @@ export default {

async created() {
(await this.botsStore.loadConversationBots(this.token)).forEach(id => {
Vue.set(this.isLoading, id, false)
this.isLoading[id] = false
})
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export default {
},

toggleCollapsed(group) {
this.$set(group, 'collapsed', !group.collapsed)
group.collapsed = !group.collapsed
this.groupIsCollapsed[group.id] = group.collapsed
},

Expand Down
12 changes: 6 additions & 6 deletions src/components/MessagesList/MessagesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -393,11 +393,11 @@ export default {
this.softUpdateAuthorGroups(oldDateGroups[dateTimestamp], newDateGroups[dateTimestamp], dateTimestamp)
} else {
// the group is new
this.$set(this.messagesGroupedByDateByAuthor, dateTimestamp, newDateGroups[dateTimestamp])
this.messagesGroupedByDateByAuthor[dateTimestamp] = newDateGroups[dateTimestamp]
}
} else {
// the group is not in the new list, remove it
this.$delete(this.messagesGroupedByDateByAuthor, dateTimestamp)
delete this.messagesGroupedByDateByAuthor[dateTimestamp]
}
})
},
Expand All @@ -415,7 +415,7 @@ export default {
if (oldGroup.messages.some(message => !newGroupIdSet.has(message.id))) {
// Delete groups of normal and temporary messages,
// if at least one message from the group is no longer in the store
this.$delete(this.messagesGroupedByDateByAuthor[dateTimestamp], id)
delete this.messagesGroupedByDateByAuthor[dateTimestamp][id]
}
})
Object.entries(newGroups).forEach(([id, newGroup]) => {
Expand All @@ -424,13 +424,13 @@ export default {
.find(key => +id < +key && oldGroups[key].nextMessageId <= newGroup.nextMessageId)
if (oldId) {
// newGroup includes oldGroup and more old messages, remove oldGroup
this.$delete(this.messagesGroupedByDateByAuthor[dateTimestamp], oldId)
delete this.messagesGroupedByDateByAuthor[dateTimestamp][oldId]
}
// newGroup is not presented in the list, add it
this.$set(this.messagesGroupedByDateByAuthor[dateTimestamp], id, newGroup)
this.messagesGroupedByDateByAuthor[dateTimestamp][id] = newGroup
} else if (!this.areGroupsIdentical(newGroup, oldGroups[id])) {
// newGroup includes oldGroup and more recent messages
this.$set(this.messagesGroupedByDateByAuthor[dateTimestamp], id, newGroup)
this.messagesGroupedByDateByAuthor[dateTimestamp][id] = newGroup
}
})
},
Expand Down
8 changes: 3 additions & 5 deletions src/store/callViewStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import Vue from 'vue'

import {
CONVERSATION,
} from '../constants.js'
Expand Down Expand Up @@ -93,16 +91,16 @@ const mutations = {
throw new Error('Missing or empty sessionId argument in call to setParticipantHandRaised')
}
if (raisedHand && raisedHand.state) {
Vue.set(state.participantRaisedHands, sessionId, raisedHand)
state.participantRaisedHands[sessionId] = raisedHand
} else {
Vue.delete(state.participantRaisedHands, sessionId)
delete state.participantRaisedHands[sessionId]
}
},
clearParticipantHandRaised(state) {
state.participantRaisedHands = {}
},
setCachedBackgroundImageAverageColor(state, { videoBackgroundId, backgroundImageAverageColor }) {
Vue.set(state.backgroundImageAverageColorCache, videoBackgroundId, backgroundImageAverageColor)
state.backgroundImageAverageColorCache[videoBackgroundId] = backgroundImageAverageColor
},
clearBackgroundImageAverageColorCache(state) {
state.backgroundImageAverageColorCache = {}
Expand Down
31 changes: 15 additions & 16 deletions src/store/conversationsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import Vue from 'vue'

import { getCurrentUser } from '@nextcloud/auth'
// eslint-disable-next-line
Expand Down Expand Up @@ -164,7 +163,7 @@ const mutations = {
* @param {object} conversation the conversation;
*/
addConversation(state, conversation) {
Vue.set(state.conversations, conversation.token, conversation)
state.conversations[conversation.token] = conversation
},

/**
Expand All @@ -184,59 +183,59 @@ const mutations = {
* @param {string} token the token of the conversation to delete;
*/
deleteConversation(state, token) {
Vue.delete(state.conversations, token)
delete state.conversations[token]
},

setConversationDescription(state, { token, description }) {
Vue.set(state.conversations[token], 'description', description)
state.conversations[token].description = description
},

updateConversationLastReadMessage(state, { token, lastReadMessage }) {
Vue.set(state.conversations[token], 'lastReadMessage', lastReadMessage)
state.conversations[token].lastReadMessage = lastReadMessage
},

updateConversationLastMessage(state, { token, lastMessage }) {
Vue.set(state.conversations[token], 'lastMessage', lastMessage)
state.conversations[token].lastMessage = lastMessage
},

updateUnreadMessages(state, { token, unreadMessages, unreadMention, unreadMentionDirect }) {
if (unreadMessages !== undefined) {
Vue.set(state.conversations[token], 'unreadMessages', unreadMessages)
state.conversations[token].unreadMessages = unreadMessages
}
if (unreadMention !== undefined) {
Vue.set(state.conversations[token], 'unreadMention', unreadMention)
state.conversations[token].unreadMention = unreadMention
}
if (unreadMentionDirect !== undefined) {
Vue.set(state.conversations[token], 'unreadMentionDirect', unreadMentionDirect)
state.conversations[token].unreadMentionDirect = unreadMentionDirect
}
},

setNotificationLevel(state, { token, notificationLevel }) {
Vue.set(state.conversations[token], 'notificationLevel', notificationLevel)
state.conversations[token].notificationLevel = notificationLevel
},

setNotificationCalls(state, { token, notificationCalls }) {
Vue.set(state.conversations[token], 'notificationCalls', notificationCalls)
state.conversations[token].notificationCalls = notificationCalls
},

setConversationPermissions(state, { token, permissions }) {
Vue.set(state.conversations[token], 'defaultPermissions', permissions)
state.conversations[token].defaultPermissions = permissions
},

setCallPermissions(state, { token, permissions }) {
Vue.set(state.conversations[token], 'callPermissions', permissions)
state.conversations[token].callPermissions = permissions
},

setCallRecording(state, { token, callRecording }) {
Vue.set(state.conversations[token], 'callRecording', callRecording)
state.conversations[token].callRecording = callRecording
},

setMessageExpiration(state, { token, seconds }) {
Vue.set(state.conversations[token], 'messageExpiration', seconds)
state.conversations[token].messageExpiration = seconds
},

setConversationHasPassword(state, { token, hasPassword }) {
Vue.set(state.conversations[token], 'hasPassword', hasPassword)
state.conversations[token].hasPassword = hasPassword
},
}

Expand Down
20 changes: 9 additions & 11 deletions src/store/fileUploadStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import Vue from 'vue'

// eslint-disable-next-line
// import { showError } from '@nextcloud/dialogs'
import { loadState } from '@nextcloud/initial-state'
Expand Down Expand Up @@ -115,18 +113,18 @@ const mutations = {
const index = temporaryMessage.messageParameters.file.index
// Create upload id if not present
if (!state.uploads[uploadId]) {
Vue.set(state.uploads, uploadId, {
state.uploads[uploadId] = {
token,
files: {},
})
}
}
Vue.set(state.uploads[uploadId].files, index, {
state.uploads[uploadId].files[index] = {
file,
status: 'initialised',
totalSize: file.size,
temporaryMessage,
})
Vue.set(state.localUrls, temporaryMessage.referenceId, localUrl)
}
state.localUrls[temporaryMessage.referenceId] = localUrl
},

// Marks a given file as initialized (for retry)
Expand All @@ -137,7 +135,7 @@ const mutations = {
// Marks a given file as ready to be uploaded (after propfind)
markFileAsPendingUpload(state, { uploadId, index, sharePath }) {
state.uploads[uploadId].files[index].status = 'pendingUpload'
Vue.set(state.uploads[uploadId].files[index], 'sharePath', sharePath)
state.uploads[uploadId].files[index].sharePath = sharePath
},

// Marks a given file as failed upload
Expand Down Expand Up @@ -178,7 +176,7 @@ const mutations = {
// Set temporary message for each file
setTemporaryMessageForFile(state, { uploadId, index, temporaryMessage }) {
console.debug('uploadId: ' + uploadId + ' index: ' + index)
Vue.set(state.uploads[uploadId].files[index], 'temporaryMessage', temporaryMessage)
state.uploads[uploadId].files[index].temporaryMessage = temporaryMessage
},

// Sets the id of the current upload operation
Expand All @@ -190,13 +188,13 @@ const mutations = {
const uploadId = state.currentUploadId
for (const key in state.uploads[uploadId].files) {
if (state.uploads[uploadId].files[key].temporaryMessage.id === temporaryMessageId) {
Vue.delete(state.uploads[uploadId].files, key)
delete state.uploads[uploadId].files[key]
}
}
},

discardUpload(state, { uploadId }) {
Vue.delete(state.uploads, uploadId)
delete state.uploads[uploadId]
},

storeFilesTemplates(state, { template }) {
Expand Down
Loading

0 comments on commit d114f80

Please sign in to comment.