@@ -125,6 +125,7 @@ export default {
125125 return {
126126 clearAt: null ,
127127 editedMessage: ' ' ,
128+ predefinedMessageId: null ,
128129 isSavingStatus: false ,
129130 statuses: getAllStatusOptions (),
130131 }
@@ -192,6 +193,7 @@ export default {
192193 mounted () {
193194 this .$store .dispatch (' fetchBackupFromServer' )
194195
196+ this .predefinedMessageId = this .$store .state .userStatus .messageId
195197 if (this .$store .state .userStatus .clearAt !== null ) {
196198 this .clearAt = {
197199 type: ' _time' ,
@@ -212,6 +214,7 @@ export default {
212214 * @param {string} icon The new icon
213215 */
214216 setIcon (icon ) {
217+ this .predefinedMessageId = null
215218 this .$store .dispatch (' setCustomMessage' , {
216219 message: this .message ,
217220 icon,
@@ -227,6 +230,7 @@ export default {
227230 * @param {string} message The new message
228231 */
229232 setMessage (message ) {
233+ this .predefinedMessageId = null
230234 this .editedMessage = message
231235 },
232236 /**
@@ -243,6 +247,7 @@ export default {
243247 * @param {object} status The predefined status object
244248 */
245249 selectPredefinedMessage (status ) {
250+ this .predefinedMessageId = status .id
246251 this .clearAt = status .clearAt
247252 this .$store .dispatch (' setPredefinedMessage' , {
248253 messageId: status .id ,
@@ -262,11 +267,18 @@ export default {
262267 try {
263268 this .isSavingStatus = true
264269
265- await this .$store .dispatch (' setCustomMessage' , {
266- message: this .editedMessage ,
267- icon: this .icon ,
268- clearAt: this .clearAt ,
269- })
270+ if (this .predefinedMessageId === null ) {
271+ await this .$store .dispatch (' setCustomMessage' , {
272+ message: this .editedMessage ,
273+ icon: this .icon ,
274+ clearAt: this .clearAt ,
275+ })
276+ } else {
277+ this .$store .dispatch (' setPredefinedMessage' , {
278+ messageId: this .predefinedMessageId ,
279+ clearAt: this .clearAt ,
280+ })
281+ }
270282 } catch (err) {
271283 showError (this .$t (' user_status' , ' There was an error saving the status' ))
272284 console .debug (err)
@@ -294,6 +306,7 @@ export default {
294306 }
295307
296308 this .isSavingStatus = false
309+ this .predefinedMessageId = null
297310 this .closeModal ()
298311 },
299312 /**
@@ -315,6 +328,7 @@ export default {
315328 }
316329
317330 this .isSavingStatus = false
331+ this .predefinedMessageId = this .$store .state .userStatus ? .messageId
318332 },
319333 },
320334}
0 commit comments