@@ -19,6 +19,8 @@ import { resetLastFetched } from "./actions/reset-last-fetched";
19
19
import { setView } from "./actions/set-view" ;
20
20
import { toggleInbox } from "./actions/toggle-inbox" ;
21
21
import { unpinMessage } from "./actions/unpin-message" ;
22
+ import { addTag } from "./actions/add-tag" ;
23
+ import { removeTag } from "./actions/remove-tag" ;
22
24
23
25
import { useEffect } from "react" ;
24
26
import { markMessageOpened } from "./actions/mark-message-opened" ;
@@ -44,6 +46,12 @@ export interface IInboxActions {
44
46
setView : ( view : string | "preferences" ) => void ;
45
47
toggleInbox : ( isOpen ?: boolean ) => void ;
46
48
unpinMessage : ( messageId : string , fromWS ?: boolean ) => Promise < void > ;
49
+ addTag : ( messageId : string , tag : string , fromWS ?: boolean ) => Promise < void > ;
50
+ removeTag : (
51
+ messageId : string ,
52
+ tag : string ,
53
+ fromWS ?: boolean
54
+ ) => Promise < void > ;
47
55
trackClick : ( messageId : string , trackingId : string ) => Promise < void > ;
48
56
}
49
57
@@ -242,6 +250,40 @@ const useInboxActions = (): IInboxActions => {
242
250
} ) ;
243
251
}
244
252
} ,
253
+ addTag : async ( messageId , tag , fromWS ) => {
254
+ dispatch ( addTag ( messageId , tag ) ) ;
255
+ if ( ! fromWS ) {
256
+ await inboxClient . addTag ( messageId , { tag } ) ;
257
+ }
258
+
259
+ if ( onEvent ) {
260
+ onEvent ( {
261
+ event : "add-tag" ,
262
+ message : allMessages . find ( ( m ) => m . messageId === messageId ) ,
263
+ messageId,
264
+ data : {
265
+ tag,
266
+ } ,
267
+ } ) ;
268
+ }
269
+ } ,
270
+ removeTag : async ( messageId , tag , fromWS ) => {
271
+ dispatch ( removeTag ( messageId , tag ) ) ;
272
+ if ( ! fromWS ) {
273
+ await inboxClient . removeTag ( messageId , { tag } ) ;
274
+ }
275
+
276
+ if ( onEvent ) {
277
+ onEvent ( {
278
+ event : "remove-tag" ,
279
+ message : allMessages . find ( ( m ) => m . messageId === messageId ) ,
280
+ messageId,
281
+ data : {
282
+ tag,
283
+ } ,
284
+ } ) ;
285
+ }
286
+ } ,
245
287
unpinMessage : async ( messageId , fromWS ) => {
246
288
dispatch ( unpinMessage ( messageId ) ) ;
247
289
if ( ! fromWS ) {
0 commit comments