2022-04-30 01:09:53 +03:00
|
|
|
export enum AppState {
|
2022-05-02 06:12:34 +03:00
|
|
|
Loading, // Initial loading state as config + status is loading.
|
2022-05-03 03:45:22 +03:00
|
|
|
Registering, // Creating a default anonymous chat account.
|
2022-05-02 06:12:34 +03:00
|
|
|
Online, // Stream is active.
|
|
|
|
Offline, // Stream is not active.
|
|
|
|
OfflineWaiting, // Period of time after going offline chat is still available.
|
|
|
|
Banned, // Certain features are disabled for this single user.
|
2022-04-30 01:09:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
export enum ChatVisibilityState {
|
2022-05-02 06:12:34 +03:00
|
|
|
Hidden, // The chat components are not available to the user.
|
|
|
|
Visible, // The chat components are not available to the user visually.
|
2022-04-30 01:09:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
export enum ChatState {
|
2022-05-02 06:12:34 +03:00
|
|
|
Available, // Normal state. Chat can be visible and used.
|
|
|
|
NotAvailable, // Chat features are not available.
|
|
|
|
Loading, // Chat is connecting and loading history.
|
|
|
|
Offline, // Chat is offline/disconnected for some reason but is visible.
|
|
|
|
}
|
|
|
|
|
2022-05-11 01:36:09 +03:00
|
|
|
export enum VideoState {
|
|
|
|
Available, // Play button should be visible and the user can begin playback.
|
|
|
|
Unavailable, // Play button not be visible and video is not available.
|
|
|
|
Playing, // Playback is taking place and the play button should not be shown.
|
|
|
|
}
|
|
|
|
|
2022-05-02 06:12:34 +03:00
|
|
|
export function getChatState(state: AppState): ChatState {
|
|
|
|
switch (state) {
|
|
|
|
case AppState.Loading:
|
|
|
|
return ChatState.NotAvailable;
|
|
|
|
case AppState.Banned:
|
|
|
|
return ChatState.NotAvailable;
|
|
|
|
case AppState.Online:
|
|
|
|
return ChatState.Available;
|
|
|
|
case AppState.Offline:
|
|
|
|
return ChatState.NotAvailable;
|
|
|
|
case AppState.OfflineWaiting:
|
|
|
|
return ChatState.Available;
|
2022-05-03 03:45:22 +03:00
|
|
|
case AppState.Registering:
|
|
|
|
return ChatState.Loading;
|
2022-05-02 06:12:34 +03:00
|
|
|
default:
|
|
|
|
return ChatState.Offline;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getChatVisibilityState(state: AppState): ChatVisibilityState {
|
|
|
|
switch (state) {
|
|
|
|
case AppState.Loading:
|
|
|
|
return ChatVisibilityState.Hidden;
|
|
|
|
case AppState.Banned:
|
|
|
|
return ChatVisibilityState.Hidden;
|
|
|
|
case AppState.Online:
|
|
|
|
return ChatVisibilityState.Visible;
|
|
|
|
case AppState.Offline:
|
|
|
|
return ChatVisibilityState.Hidden;
|
|
|
|
case AppState.OfflineWaiting:
|
|
|
|
return ChatVisibilityState.Visible;
|
2022-05-03 03:45:22 +03:00
|
|
|
case AppState.Registering:
|
|
|
|
return ChatVisibilityState.Visible;
|
2022-05-02 06:12:34 +03:00
|
|
|
default:
|
|
|
|
return ChatVisibilityState.Hidden;
|
|
|
|
}
|
2022-04-30 01:09:53 +03:00
|
|
|
}
|