@@ -644,6 +644,50 @@ export class Channel<StreamChatGenerics extends ExtendableGenerics = DefaultGene
644
644
} ) ;
645
645
}
646
646
647
+ /**
648
+ * archive - archives the current channel
649
+ * @param {{ user_id?: string } } opts user_id if called server side
650
+ * @return {Promise<ChannelMemberResponse<StreamChatGenerics>> } The server response
651
+ *
652
+ * example:
653
+ * await channel.archives();
654
+ *
655
+ * example server side:
656
+ * await channel.archive({user_id: userId});
657
+ *
658
+ */
659
+ async archive ( opts : { user_id ?: string } = { } ) {
660
+ const cli = this . getClient ( ) ;
661
+ const uid = opts . user_id || cli . userID ;
662
+ if ( ! uid ) {
663
+ throw Error ( 'A user_id is required for archiving a channel' ) ;
664
+ }
665
+ const resp = await this . partialUpdateMember ( uid , { set : { archived : true } } ) ;
666
+ return resp . channel_member ;
667
+ }
668
+
669
+ /**
670
+ * unarchive - unarchives the current channel
671
+ * @param {{ user_id?: string } } opts user_id if called server side
672
+ * @return {Promise<ChannelMemberResponse<StreamChatGenerics>> } The server response
673
+ *
674
+ * example:
675
+ * await channel.unarchive();
676
+ *
677
+ * example server side:
678
+ * await channel.unarchive({user_id: userId});
679
+ *
680
+ */
681
+ async unarchive ( opts : { user_id ?: string } = { } ) {
682
+ const cli = this . getClient ( ) ;
683
+ const uid = opts . user_id || cli . userID ;
684
+ if ( ! uid ) {
685
+ throw Error ( 'A user_id is required for unarchiving a channel' ) ;
686
+ }
687
+ const resp = await this . partialUpdateMember ( uid , { set : { archived : false } } ) ;
688
+ return resp . channel_member ;
689
+ }
690
+
647
691
/**
648
692
* pin - pins the current channel
649
693
* @param {{ user_id?: string } } opts user_id if called server side
0 commit comments