@@ -28,6 +28,7 @@ export type AuthUser = {
2828
2929export type State = {
3030 owner : string | null
31+ nextRoute : string | null
3132 loadingThreads : boolean
3233 loadingMessages : boolean
3334 archivedThreads : boolean
@@ -46,6 +47,7 @@ export const state = (): State => ({
4647 threads : [ ] ,
4748 threadId : null ,
4849 heartbeat : null ,
50+ nextRoute : null ,
4951 loadingThreads : true ,
5052 archivedThreads : false ,
5153 loadingMessages : true ,
@@ -130,6 +132,10 @@ export const getters = {
130132 return state . loadingMessages
131133 } ,
132134
135+ getNextRoute ( state : State ) : string | null {
136+ return state . nextRoute
137+ } ,
138+
133139 getThreadMessages ( state : State ) : Array < Message > {
134140 return state . threadMessages
135141 } ,
@@ -218,6 +224,10 @@ export const mutations = {
218224 state . archivedThreads = false
219225 state . owner = null
220226 } ,
227+
228+ setNextRoute ( state : State , payload : string | null ) {
229+ state . nextRoute = payload
230+ } ,
221231}
222232
223233export type SendMessageRequest = {
@@ -250,6 +260,10 @@ export const actions = {
250260 if ( context . getters . getPhones . length > 0 && ! force ) {
251261 return
252262 }
263+ if ( ! context . getters . authUser ) {
264+ return
265+ }
266+
253267 const response = await axios . get ( '/v1/phones' , { params : { limit : 100 } } )
254268 context . commit ( 'setPhones' , response . data . data )
255269 } ,
@@ -309,6 +323,10 @@ export const actions = {
309323 context . commit ( 'disableNotification' )
310324 } ,
311325
326+ setNextRoute ( context : ActionContext < State , State > , payload : string | null ) {
327+ context . commit ( 'setNextRoute' , payload )
328+ } ,
329+
312330 async loadThreadMessages (
313331 context : ActionContext < State , State > ,
314332 threadId : string | null
@@ -325,10 +343,14 @@ export const actions = {
325343
326344 async setAuthUser (
327345 context : ActionContext < State , State > ,
328- user : AuthUser | null
346+ user : AuthUser | null | undefined
329347 ) {
330348 const userChanged = user ?. id !== context . getters . getAuthUser ?. id
331349
350+ if ( user === undefined ) {
351+ user = null
352+ }
353+
332354 await context . commit ( 'setAuthUser' , user )
333355
334356 if ( userChanged && user !== null ) {
0 commit comments