diff options
Diffstat (limited to 'src/state/messages/convo/util.ts')
-rw-r--r-- | src/state/messages/convo/util.ts | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/state/messages/convo/util.ts b/src/state/messages/convo/util.ts new file mode 100644 index 000000000..ffaa4104a --- /dev/null +++ b/src/state/messages/convo/util.ts @@ -0,0 +1,22 @@ +import { + ConvoState, + ConvoStateBackgrounded, + ConvoStateReady, + ConvoStateSuspended, + ConvoStatus, +} from './types' + +/** + * Checks if a `Convo` has a `status` that is "active", meaning the chat is + * loaded and ready to be used, or its in a suspended or background state, and + * ready for resumption. + */ +export function isConvoActive( + convo: ConvoState, +): convo is ConvoStateReady | ConvoStateBackgrounded | ConvoStateSuspended { + return ( + convo.status === ConvoStatus.Ready || + convo.status === ConvoStatus.Backgrounded || + convo.status === ConvoStatus.Suspended + ) +} |