mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-04-11 04:19:26 -07:00
feat(stats): add v1 immersion stats dashboard (#19)
This commit is contained in:
@@ -7,6 +7,11 @@ export interface UiFeedbackState {
|
||||
progressFrame: number;
|
||||
}
|
||||
|
||||
export interface UiFeedbackResult {
|
||||
success: boolean;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface UiFeedbackNotificationContext {
|
||||
getNotificationType: () => string | undefined;
|
||||
showOsd: (text: string) => void;
|
||||
@@ -66,6 +71,15 @@ export function endUpdateProgress(
|
||||
state.progressDepth = Math.max(0, state.progressDepth - 1);
|
||||
if (state.progressDepth > 0) return;
|
||||
|
||||
clearUpdateProgress(state, clearProgressTimer);
|
||||
}
|
||||
|
||||
export function clearUpdateProgress(
|
||||
state: UiFeedbackState,
|
||||
clearProgressTimer: (timer: ReturnType<typeof setInterval>) => void,
|
||||
): void {
|
||||
state.progressDepth = 0;
|
||||
|
||||
if (state.progressTimer) {
|
||||
clearProgressTimer(state.progressTimer);
|
||||
state.progressTimer = null;
|
||||
@@ -85,6 +99,19 @@ export function showProgressTick(
|
||||
showOsdNotification(`${state.progressMessage} ${frame}`);
|
||||
}
|
||||
|
||||
export function showUpdateResult(
|
||||
state: UiFeedbackState,
|
||||
options: {
|
||||
clearProgressTimer: (timer: ReturnType<typeof setInterval>) => void;
|
||||
showOsdNotification: (text: string) => void;
|
||||
},
|
||||
result: UiFeedbackResult,
|
||||
): void {
|
||||
clearUpdateProgress(state, options.clearProgressTimer);
|
||||
const prefix = result.success ? '✓' : 'x';
|
||||
options.showOsdNotification(`${prefix} ${result.message}`);
|
||||
}
|
||||
|
||||
export async function withUpdateProgress<T>(
|
||||
state: UiFeedbackState,
|
||||
options: UiFeedbackOptions,
|
||||
|
||||
Reference in New Issue
Block a user