Skip to content

Commit f4acf38

Browse files
committed
replace Vue.set with direct setting
Signed-off-by: grnd-alt <github@belakkaf.net>
1 parent 30e74a7 commit f4acf38

13 files changed

Lines changed: 62 additions & 88 deletions

File tree

package-lock.json

Lines changed: 0 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
"@nextcloud/notify_push": "^1.3.0",
4545
"@nextcloud/router": "^3.0.1",
4646
"@nextcloud/vue": "^9.0.0-alpha.7",
47-
"@vue/compat": "^3.5.13",
4847
"@vue/compiler-sfc": "^3.5.13",
4948
"@vue/vue3-jest": "^29.2.6",
5049
"@vueuse/core": "^13.1.0",

src/components/KeyboardShortcuts.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ export default {
260260
this.$refs.shortcutModal?.focus()
261261
},
262262
close() {
263-
console.log("HHHHH")
264263
this.card = null
265264
this.selector = null
266265
},

src/components/board/Stack.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
non-drag-area-selector=".dragDisabled"
9595
:drag-handle-selector="dragHandleSelector"
9696
data-dragscroll-enabled
97-
@should-accept-drop="canEdit"
97+
:should-accept-drop="() => canEdit"
9898
@drag-start="draggingCard = true"
9999
@drag-end="draggingCard = false"
100100
@drop="($event) => onDropCard(stack.id, $event)">

src/init-collections.js

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,34 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6-
import Vue from 'vue'
7-
86
import './../css/collections.css'
97
import FileSharingPicker from './views/FileSharingPicker.js'
108
import { buildSelector } from './helpers/selector.js'
119

1210
import './shared-init.js'
1311

14-
Vue.prototype.t = t
15-
Vue.prototype.n = n
16-
Vue.prototype.OC = OC
17-
18-
window.addEventListener('DOMContentLoaded', () => {
19-
if (OCA.Sharing && OCA.Sharing.ShareSearch) {
20-
OCA.Sharing.ShareSearch.addNewResult(FileSharingPicker)
21-
}
12+
export function initCollections() {
13+
window.addEventListener('DOMContentLoaded', () => {
14+
if (OCA.Sharing && OCA.Sharing.ShareSearch) {
15+
OCA.Sharing.ShareSearch.addNewResult(FileSharingPicker)
16+
}
2217

23-
window.OCP.Collaboration.registerType('deck', {
24-
action: () => {
25-
const BoardSelector = () => import('./BoardSelector.vue')
26-
return buildSelector(BoardSelector)
27-
},
28-
typeString: t('deck', 'Link to a board'),
29-
typeIconClass: 'icon-deck',
30-
})
18+
window.OCP.Collaboration.registerType('deck', {
19+
action: () => {
20+
const BoardSelector = () => import('./BoardSelector.vue')
21+
return buildSelector(BoardSelector)
22+
},
23+
typeString: t('deck', 'Link to a board'),
24+
typeIconClass: 'icon-deck',
25+
})
3126

32-
window.OCP.Collaboration.registerType('deck-card', {
33-
action: () => {
34-
const CardSelector = () => import('./CardSelector.vue')
35-
return buildSelector(CardSelector)
36-
},
37-
typeString: t('deck', 'Link to a card'),
38-
typeIconClass: 'icon-deck',
27+
window.OCP.Collaboration.registerType('deck-card', {
28+
action: () => {
29+
const CardSelector = () => import('./CardSelector.vue')
30+
return buildSelector(CardSelector)
31+
},
32+
typeString: t('deck', 'Link to a card'),
33+
typeIconClass: 'icon-deck',
34+
})
3935
})
40-
})
36+
}

src/main.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ import ClickOutside from 'vue-click-outside'
1313
import './shared-init.js'
1414
import './models/index.js'
1515
import './sessions.js'
16-
import { configureCompat } from '@vue/compat'
17-
18-
configureCompat({ MODE: 3, INSTANCE_SCOPED_SLOTS: false, ATTR_ENUMERATED_COERCION: true, INSTANCE_EVENT_EMITTER: true, OPTIONS_BEFORE_DESTROY: true, CUSTOM_DIR: true, OPTIONS_DESTROYED: true, INSTANCE_LISTENERS: true, GLOBAL_SET: true })
16+
import { initCollections } from './init-collections.js'
1917

2018
// the server snap.js conflicts with vertical scrolling so we disable it
2119
document.body.setAttribute('data-snap-ignore', 'true')
@@ -24,6 +22,9 @@ const app = createApp(App)
2422

2523
app.config.globalProperties.t = translate
2624
app.config.globalProperties.n = translatePlural
25+
app.config.globalProperties.OC = OC
26+
27+
initCollections({ t, n, OC })
2728

2829
app.directive('click-outside', ClickOutside)
2930

src/store/attachment.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55

66
import { AttachmentApi } from './../services/AttachmentApi.js'
7-
import Vue from 'vue'
87

98
const apiClient = new AttachmentApi()
109

@@ -24,20 +23,20 @@ export default {
2423
mutations: {
2524
createAttachment(state, { cardId, attachment }) {
2625
if (typeof state.attachments[cardId] === 'undefined') {
27-
Vue.set(state.attachments, cardId, [attachment])
26+
state.attachments[cardId] = [attachment]
2827
} else {
2928
state.attachments[cardId].push(attachment)
3029
}
3130
},
3231

3332
createAttachments(state, { cardId, attachments }) {
34-
Vue.set(state.attachments, cardId, attachments)
33+
state.attachments[cardId] = attachments
3534
},
3635

3736
updateAttachment(state, { cardId, attachment }) {
3837
const existingIndex = state.attachments[attachment.cardId].findIndex(a => a.id === attachment.id && a.type === attachment.type)
3938
if (existingIndex !== -1) {
40-
Vue.set(state.attachments[cardId], existingIndex, attachment)
39+
state.attachments[cardId][existingIndex] = attachment
4140
}
4241
},
4342

src/store/card.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import { CardApi } from './../services/CardApi.js'
77
import moment from 'moment'
8-
import Vue from 'vue'
98

109
const apiClient = new CardApi()
1110

@@ -180,6 +179,7 @@ export default {
180179
.sort((a, b) => a.order - b.order || a.createdAt - b.createdAt)
181180
},
182181
cardById: state => (id) => {
182+
alert('cardById')
183183
return state.cards.find((card) => card.id === id)
184184
},
185185
},
@@ -190,7 +190,7 @@ export default {
190190
const existingIndex = state.cards.findIndex(_card => _card.id === card.id)
191191
if (existingIndex !== -1) {
192192
const existingCard = state.cards.find(_card => _card.id === card.id)
193-
Vue.set(state.cards, existingIndex, Object.assign({}, existingCard, card))
193+
state.cards[existingIndex] = { ...existingCard, ...card }
194194
} else {
195195
state.cards.push(card)
196196
}
@@ -204,15 +204,15 @@ export default {
204204
updateCard(state, card) {
205205
const existingIndex = state.cards.findIndex(_card => _card.id === card.id)
206206
if (existingIndex !== -1) {
207-
Vue.set(state.cards, existingIndex, Object.assign({}, state.cards[existingIndex], card))
207+
state.cards[existingIndex] = { ...state.cards[existingIndex], ...card }
208208
}
209209
},
210210
updateCardsReorder(state, cards) {
211211
for (const newCard of cards) {
212212
const existingIndex = state.cards.findIndex(_card => _card.id === newCard.id)
213213
if (existingIndex !== -1) {
214-
Vue.set(state.cards[existingIndex], 'order', newCard.order)
215-
Vue.set(state.cards[existingIndex], 'stackId', newCard.stackId)
214+
state.cards[existingIndex].order = newCard.order
215+
state.cards[existingIndex].stackId = newCard.stackId
216216
}
217217
}
218218
},
@@ -234,26 +234,26 @@ export default {
234234
updateCardProperty(state, { card, property }) {
235235
const existingIndex = state.cards.findIndex(_card => _card.id === card.id)
236236
if (existingIndex !== -1) {
237-
Vue.set(state.cards[existingIndex], property, card[property])
238-
Vue.set(state.cards[existingIndex], 'lastModified', Date.now() / 1000)
237+
state.cards[existingIndex][property] = card[property]
238+
state.cards[existingIndex].lastModifiedBy = Date.now() / 1000
239239
}
240240
},
241241
cardSetAttachmentCount(state, { cardId, count }) {
242242
const existingIndex = state.cards.findIndex(_card => _card.id === cardId)
243243
if (existingIndex !== -1) {
244-
Vue.set(state.cards[existingIndex], 'attachmentCount', count)
244+
state.cards[existingIndex].attachmentCount = count
245245
}
246246
},
247247
cardIncreaseAttachmentCount(state, cardId) {
248248
const existingIndex = state.cards.findIndex(_card => _card.id === cardId)
249249
if (existingIndex !== -1) {
250-
Vue.set(state.cards[existingIndex], 'attachmentCount', state.cards[existingIndex].attachmentCount + 1)
250+
state.cards[existingIndex].attachmentCount = state.cards[existingIndex].attachmentCount + 1
251251
}
252252
},
253253
cardDecreaseAttachmentCount(state, cardId) {
254254
const existingIndex = state.cards.findIndex(_card => _card.id === cardId)
255255
if (existingIndex !== -1) {
256-
Vue.set(state.cards[existingIndex], 'attachmentCount', state.cards[existingIndex].attachmentCount - 1)
256+
state.cards[existingIndex].attachmentCount = state.cards[existingIndex].attachmentCount - 1
257257
}
258258
},
259259
addNewCard(state, card) {
@@ -344,6 +344,7 @@ export default {
344344
commit('removeUserFromCard', user)
345345
},
346346
async addLabel({ commit }, data) {
347+
alert('hello world')
347348
await apiClient.assignLabelToCard(data)
348349
commit('updateCardProperty', { property: 'labels', card: data.card })
349350
},

src/store/comment.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ export default {
3434
},
3535
addComments(state, { comments, cardId }) {
3636
if (state.comments[cardId] === undefined) {
37-
Vue.set(state.comments, cardId, {
38-
hasMore: comments.length > 0,
37+
state.comments[cardId] = {
38+
hasMore: comments.length >= 0,
3939
comments: [...comments],
40-
})
40+
}
4141
} else {
4242
const newComments = comments.filter((comment) => {
4343
return state.comments[cardId].comments.findIndex((item) => item.id === comment.id) === -1
@@ -59,11 +59,11 @@ export default {
5959
},
6060
markCommentsAsRead(state, cardId) {
6161
state.comments[cardId].comments.forEach(_comment => {
62-
Vue.set(_comment, 'isUnread', false)
62+
_comment.isUnread = false
6363
})
6464
},
6565
setReplyTo(state, comment) {
66-
Vue.set(state, 'replyTo', comment)
66+
state.replyTo = comment
6767
},
6868
},
6969
actions: {

src/store/main.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import 'url-search-params-polyfill'
77

88
import { loadState } from '@nextcloud/initial-state'
9-
import Vue from 'vue'
109
import { createStore } from 'vuex'
1110
import axios from '@nextcloud/axios'
1211
import { generateOcsUrl, generateUrl } from '@nextcloud/router'
@@ -129,7 +128,7 @@ const store = createStore({
129128
},
130129
mutations: {
131130
setFullApp(state, isFullApp) {
132-
Vue.set(state, 'isFullApp', isFullApp)
131+
state.isFullApp = isFullApp
133132
},
134133
setHasCardSaveError(state, hasCardSaveError) {
135134
Vue.set(state, 'hasCardSaveError', hasCardSaveError)
@@ -144,11 +143,11 @@ const store = createStore({
144143
})
145144

146145
if (indexExisting > -1) {
147-
Vue.set(state.boards[indexExisting].settings, configKey, value)
146+
state.boards[indexExisting].settings[configKey] = value
148147
}
149148
break
150149
default:
151-
Vue.set(state.config, key, value)
150+
state.config[key] = value
152151
}
153152
},
154153
setSearchQuery(state, searchQuery) {
@@ -161,7 +160,7 @@ const store = createStore({
161160
Object.keys(filter).forEach((key) => {
162161
switch (key) {
163162
case 'due':
164-
Vue.set(state.filter, key, filter.due)
163+
state.filter[key] = filter.due
165164
break
166165
default:
167166
filter[key].forEach((item) => {
@@ -188,7 +187,7 @@ const store = createStore({
188187
})
189188

190189
if (indexExisting > -1) {
191-
Vue.set(state.boards, indexExisting, board)
190+
state.boards[indexExisting] = board
192191
} else {
193192
state.boards.push(board)
194193
}
@@ -200,7 +199,7 @@ const store = createStore({
200199
})
201200

202201
if (indexExisting > -1) {
203-
Vue.set(state.boards, indexExisting, board)
202+
state.boards[indexExisting] = board
204203
} else {
205204
state.boards.push(board)
206205
}
@@ -233,7 +232,7 @@ const store = createStore({
233232
state.boards = boards
234233
},
235234
setSharees(state, shareesUsersAndGroups) {
236-
Vue.set(state, 'sharees', shareesUsersAndGroups.exact.users)
235+
state.sharees = shareesUsersAndGroups.exact.users
237236
state.sharees.push(...shareesUsersAndGroups.exact.groups)
238237
state.sharees.push(...shareesUsersAndGroups.exact.circles)
239238

@@ -283,7 +282,7 @@ const store = createStore({
283282
updateAclFromCurrentBoard(state, acl) {
284283
for (const acl_ in state.currentBoard.acl) {
285284
if (state.currentBoard.acl[acl_].participant.uid === acl.participant.uid) {
286-
Vue.set(state.currentBoard.acl, acl_, acl)
285+
state.currentBoard.acl[acl_] = acl
287286
break
288287
}
289288
}
@@ -299,7 +298,7 @@ const store = createStore({
299298
}
300299

301300
if (removeIndex > -1) {
302-
Vue.delete(state.currentBoard.acl, removeIndex)
301+
state.currentBoard.acl.splice(removeIndex, 1)
303302
}
304303
},
305304
TOGGLE_SHORTCUT_LOCK(state, lock) {

0 commit comments

Comments
 (0)