1
0

fix: directly set arrays, objects and delete directly

Not needed since vue3 uses proxies
This commit is contained in:
Dominik Pschenitschni
2021-08-19 21:35:38 +02:00
parent 2b20f328cb
commit db49b9b532
33 changed files with 104 additions and 113 deletions

View File

@ -142,7 +142,7 @@ export default {
const list = new ListModel(listData)
this.listService.get(list)
.then(r => {
this.$set(this, 'list', r)
this.list = r
this.$store.commit(CURRENT_LIST, r)
this.setTitle(this.getListTitle(r))
})

View File

@ -104,8 +104,8 @@ export default {
return
}
// This is an extra method to reset a few things when searching to not break loading more photos.
this.$set(this, 'backgroundSearchResult', [])
this.$set(this, 'backgroundThumbs', {})
this.backgroundSearchResult = []
this.backgroundThumbs = {}
this.searchBackgrounds()
},
searchBackgrounds(page = 1) {
@ -124,7 +124,7 @@ export default {
r.forEach(b => {
this.backgroundService.thumb(b)
.then(t => {
this.$set(this.backgroundThumbs, b.id, t)
this.backgroundThumbs[b.id] = t
})
})
})

View File

@ -106,7 +106,7 @@ export default {
this.listService.get(list)
.then(r => {
this.$set(this, 'list', r)
this.list = r
this.$store.commit(CURRENT_LIST, r)
this.setTitle(this.$t('list.edit.title', {list: this.list.title}))
})

View File

@ -61,7 +61,7 @@ export default {
this.listService.get(list)
.then(r => {
this.$set(this, 'list', r)
this.list = r
this.$store.commit(CURRENT_LIST, r)
// This will trigger the dynamic loading of components once we actually have all the data to pass to them
this.manageTeamsComponent = 'userTeam'

View File

@ -398,20 +398,20 @@ export default {
this.$message.error(e)
})
.finally(() => {
this.$set(this.taskUpdating, task.id, false)
this.taskUpdating[task.id] = false
this.oneTaskUpdating = false
})
},
toggleShowNewTaskInput(bucket) {
this.$set(this.showNewTaskInput, bucket, !this.showNewTaskInput[bucket])
this.showNewTaskInput[bucket] = !this.showNewTaskInput[bucket]
},
addTaskToBucket(bucketId) {
if (this.newTaskText === '') {
this.$set(this.newTaskError, bucketId, true)
this.newTaskError[bucketId] = true
return
}
this.$set(this.newTaskError, bucketId, false)
this.newTaskError[bucketId] = false
this.createNewTask(this.newTaskText, bucketId)
.then(r => {
@ -557,7 +557,7 @@ export default {
})
},
collapseBucket(bucket) {
this.$set(this.collapsedBuckets, bucket.id, true)
this.collapsedBuckets[bucket.id] = true
saveCollapsedBucketState(this.$route.params.listId, this.collapsedBuckets)
},
unCollapseBucket(bucket) {
@ -565,7 +565,7 @@ export default {
return
}
this.$set(this.collapsedBuckets, bucket.id, false)
this.collapsedBuckets[bucket.id] = false
saveCollapsedBucketState(this.$route.params.listId, this.collapsedBuckets)
},
},

View File

@ -279,7 +279,7 @@ export default {
updateTasks(updatedTask) {
for (const t in this.tasks) {
if (this.tasks[t].id === updatedTask.id) {
this.$set(this.tasks, t, updatedTask)
this.tasks[t] = updatedTask
break
}
}
@ -299,7 +299,7 @@ export default {
this.$store.dispatch('tasks/update', newTask)
.then(r => {
this.$set(this.tasks, e.newIndex, r)
this.tasks[e.newIndex] = r
})
.catch(e => {
this.$message.error(e)

View File

@ -239,16 +239,16 @@ export default {
created() {
const savedShowColumns = localStorage.getItem('tableViewColumns')
if (savedShowColumns !== null) {
this.$set(this, 'activeColumns', JSON.parse(savedShowColumns))
this.activeColumns = JSON.parse(savedShowColumns)
}
const savedSortBy = localStorage.getItem('tableViewSortBy')
if (savedSortBy !== null) {
this.$set(this, 'sortBy', JSON.parse(savedSortBy))
this.sortBy = JSON.parse(savedSortBy)
}
this.$set(this.params, 'filter_by', [])
this.$set(this.params, 'filter_value', [])
this.$set(this.params, 'filter_comparator', [])
this.params.filter_by = []
this.params.filter_value = []
this.params.filter_comparator = []
this.initTasks(1)
@ -286,11 +286,11 @@ export default {
sort(property) {
const order = this.sortBy[property]
if (typeof order === 'undefined' || order === 'none') {
this.$set(this.sortBy, property, 'desc')
this.sortBy[property] = 'desc'
} else if (order === 'desc') {
this.$set(this.sortBy, property, 'asc')
this.sortBy[property] = 'asc'
} else {
this.$delete(this.sortBy, property)
delete this.sortBy[property]
}
this.initTasks(this.currentPage, this.searchTerm)
// Save the order to be able to retrieve them later

View File

@ -110,7 +110,7 @@ export default {
const namespace = new NamespaceModel({id: this.$route.params.id})
this.namespaceService.get(namespace)
.then(r => {
this.$set(this, 'namespace', r)
this.namespace = r
// This will trigger the dynamic loading of components once we actually have all the data to pass to them
this.manageTeamsComponent = 'manageSharing'
this.manageUsersComponent = 'manageSharing'

View File

@ -61,7 +61,7 @@ export default {
const namespace = new NamespaceModel({id: this.$route.params.id})
this.namespaceService.get(namespace)
.then(r => {
this.$set(this, 'namespace', r)
this.namespace = r
// This will trigger the dynamic loading of components once we actually have all the data to pass to them
this.manageTeamsComponent = 'manageSharing'
this.manageUsersComponent = 'manageSharing'

View File

@ -206,7 +206,7 @@ export default {
})
const tasks = r.filter(t => t.dueDate !== null).concat(r.filter(t => t.dueDate === null))
this.$set(this, 'tasks', tasks)
this.tasks = tasks
})
.catch(e => {
this.$message.error(e)
@ -215,7 +215,7 @@ export default {
updateTasks(updatedTask) {
for (const t in this.tasks) {
if (this.tasks[t].id === updatedTask.id) {
this.$set(this.tasks, t, updatedTask)
this.tasks[t] = updatedTask
// Move the task to the end of the done tasks if it is now done
if (updatedTask.done) {
this.tasks.splice(t, 1)

View File

@ -561,7 +561,7 @@ export default {
this.taskId = Number(this.$route.params.id)
this.taskService.get({id: this.taskId})
.then(r => {
this.$set(this, 'task', r)
this.task = r
this.$store.commit('attachments/set', r.attachments)
this.taskColor = this.task.hexColor
this.setActiveFields()

View File

@ -232,7 +232,7 @@ export default {
this.teamService
.get(this.team)
.then((response) => {
this.$set(this, 'team', response)
this.team = response
this.title = this.$t('team.edit.title', {team: this.team.name})
this.setTitle(this.title)
})
@ -305,7 +305,7 @@ export default {
.then((r) => {
for (const tm in this.team.members) {
if (this.team.members[tm].id === member.id) {
this.$set(this.team.members[tm], 'admin', r.admin)
this.team.members[tm].admin = r.admin
break
}
}
@ -321,21 +321,21 @@ export default {
},
findUser(query) {
if (query === '') {
this.$set(this, 'foundUsers', [])
this.clearAll()
return
}
this.userService
.getAll({}, {s: query})
.then((response) => {
this.$set(this, 'foundUsers', response)
this.foundUsers = response
})
.catch((e) => {
this.$message.error(e)
})
},
clearAll() {
this.$set(this, 'foundUsers', [])
this.foundUsers = []
},
},
}

View File

@ -46,7 +46,7 @@ export default {
loadTeams() {
this.teamService.getAll()
.then(response => {
this.$set(this, 'teams', response)
this.teams = response
})
.catch(e => {
this.$message.error(e)

View File

@ -409,7 +409,7 @@ export default {
}
this.totpService.get()
.then(r => {
this.$set(this, 'totp', r)
this.totp = r
this.totpSetQrCode()
})
.catch(e => {
@ -433,7 +433,7 @@ export default {
this.totpService.enroll()
.then(r => {
this.totpEnrolled = true
this.$set(this, 'totp', r)
this.totp = r
this.totpSetQrCode()
})
.catch(e => this.$message.error(e))
@ -441,7 +441,7 @@ export default {
totpConfirm() {
this.totpService.enable({passcode: this.totpConfirmPasscode})
.then(() => {
this.$set(this.totp, 'enabled', true)
this.totp.enabled = true
this.$message.success({message: this.$t('user.settings.totp.confirmSuccess')})
})
.catch(e => this.$message.error(e))
@ -450,7 +450,7 @@ export default {
this.totpService.disable({password: this.totpDisablePassword})
.then(() => {
this.totpEnrolled = false
this.$set(this, 'totp', new TotpModel())
this.totp = new TotpModel()
this.$message.success({message: this.$t('user.settings.totp.disableSuccess')})
})
.catch(e => this.$message.error(e))