@@ -150,6 +150,10 @@ export const getters = {
150150 return state . pooling
151151 } ,
152152
153+ getIsArchived ( state : State ) : boolean {
154+ return state . archivedThreads
155+ } ,
156+
153157 getNotification ( state : State ) : Notification {
154158 return state . notification
155159 } ,
@@ -205,6 +209,15 @@ export const mutations = {
205209 state . loadingThreads = true
206210 state . loadingMessages = true
207211 } ,
212+
213+ setArchivedThreads ( state : State , payload : boolean ) {
214+ state . archivedThreads = payload
215+ } ,
216+
217+ resetState ( state : State ) {
218+ state . archivedThreads = false
219+ state . owner = null
220+ } ,
208221}
209222
210223export type SendMessageRequest = {
@@ -223,11 +236,16 @@ export const actions = {
223236 const response = await axios . get ( '/v1/message-threads' , {
224237 params : {
225238 owner : context . getters . getOwner ,
239+ is_archived : context . getters . getIsArchived ,
226240 } ,
227241 } )
228242 await context . commit ( 'setThreads' , response . data . data )
229243 } ,
230244
245+ async toggleArchive ( context : ActionContext < State , State > ) {
246+ await context . commit ( 'setArchivedThreads' , ! context . getters . getIsArchived )
247+ } ,
248+
231249 async loadPhones ( context : ActionContext < State , State > , force : boolean ) {
232250 if ( context . getters . getPhones . length > 0 && ! force ) {
233251 return
@@ -241,6 +259,10 @@ export const actions = {
241259 context . commit ( 'setUser' , response . data . data )
242260 } ,
243261
262+ resetState ( context : ActionContext < State , State > ) {
263+ context . commit ( 'resetState' , false )
264+ } ,
265+
244266 async getHeartbeat ( context : ActionContext < State , State > ) {
245267 const response = await axios . get ( '/v1/heartbeats' , {
246268 params : {
@@ -338,4 +360,15 @@ export const actions = {
338360
339361 context . commit ( 'setUser' , response . data . data )
340362 } ,
363+
364+ async updateThread (
365+ context : ActionContext < State , State > ,
366+ payload : { threadId : string ; isArchived : boolean }
367+ ) {
368+ await axios . put ( `/v1/message-threads/${ payload . threadId } ` , {
369+ is_archived : payload . isArchived ,
370+ } )
371+ await context . commit ( 'setArchivedThreads' , payload . isArchived )
372+ await context . dispatch ( 'loadThreads' )
373+ } ,
341374}
0 commit comments