fix(userstatus): Don't set predefined user status as custom when changing "Clear at"

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2024-08-15 14:39:56 +02:00
parent 601b3b16cb
commit 50c48aa538
No known key found for this signature in database
GPG key ID: 74434EFE0D2E2205

View file

@ -109,6 +109,7 @@ export default {
return {
clearAt: null,
editedMessage: '',
predefinedMessageId: null,
isSavingStatus: false,
statuses: getAllStatusOptions(),
}
@ -176,6 +177,7 @@ export default {
mounted() {
this.$store.dispatch('fetchBackupFromServer')
this.predefinedMessageId = this.$store.state.userStatus.messageId
if (this.$store.state.userStatus.clearAt !== null) {
this.clearAt = {
type: '_time',
@ -196,6 +198,7 @@ export default {
* @param {string} icon The new icon
*/
setIcon(icon) {
this.predefinedMessageId = null
this.$store.dispatch('setCustomMessage', {
message: this.message,
icon,
@ -211,6 +214,7 @@ export default {
* @param {string} message The new message
*/
setMessage(message) {
this.predefinedMessageId = null
this.editedMessage = message
},
/**
@ -227,6 +231,7 @@ export default {
* @param {object} status The predefined status object
*/
selectPredefinedMessage(status) {
this.predefinedMessageId = status.id
this.clearAt = status.clearAt
this.$store.dispatch('setPredefinedMessage', {
messageId: status.id,
@ -246,11 +251,18 @@ export default {
try {
this.isSavingStatus = true
await this.$store.dispatch('setCustomMessage', {
message: this.editedMessage,
icon: this.icon,
clearAt: this.clearAt,
})
if (this.predefinedMessageId === null) {
await this.$store.dispatch('setCustomMessage', {
message: this.editedMessage,
icon: this.icon,
clearAt: this.clearAt,
})
} else {
this.$store.dispatch('setPredefinedMessage', {
messageId: this.predefinedMessageId,
clearAt: this.clearAt,
})
}
} catch (err) {
showError(this.$t('user_status', 'There was an error saving the status'))
console.debug(err)
@ -278,6 +290,7 @@ export default {
}
this.isSavingStatus = false
this.predefinedMessageId = null
this.closeModal()
},
/**
@ -299,6 +312,7 @@ export default {
}
this.isSavingStatus = false
this.predefinedMessageId = this.$store.state.userStatus?.messageId
},
},
}