diff options
author | Eric Bailey <git@esb.lol> | 2024-05-14 11:59:53 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-14 11:59:53 -0500 |
commit | 1c51a48764e4145679198f68368713410e28c8da (patch) | |
tree | 6f2840665b10dfbb3591f0a694c9d5165f383be3 /src/state/messages/convo/util.ts | |
parent | bffb9b590672c1e636083bdf9873f5cd8ab97b57 (diff) | |
download | voidsky-1c51a48764e4145679198f68368713410e28c8da.tar.zst |
[🐴] Make status checks easier, fix load state (#4010)
* Make status checks easier, fix load state * Make naming more clear * Split up types for easier re-use * Replace hacky usage
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 + ) +} |