mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-06-09 15:13:32 -07:00
fix: suppress overlay subtitle immediately when character dictionary modal opens (#84)
This commit is contained in:
@@ -5,10 +5,12 @@ export type CharacterDictionaryAutoSyncNotificationEvent = CharacterDictionaryAu
|
||||
|
||||
export interface CharacterDictionaryAutoSyncNotificationDeps {
|
||||
getNotificationType: () => 'osd' | 'system' | 'both' | 'none' | undefined;
|
||||
showOsd: (message: string) => void;
|
||||
showOsd: (message: string) => boolean | void;
|
||||
showDesktopNotification: (title: string, options: { body?: string }) => void;
|
||||
startupOsdSequencer?: {
|
||||
notifyCharacterDictionaryStatus: (event: StartupOsdSequencerCharacterDictionaryEvent) => void;
|
||||
notifyCharacterDictionaryStatus: (
|
||||
event: StartupOsdSequencerCharacterDictionaryEvent,
|
||||
) => boolean;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -16,6 +18,16 @@ function shouldShowOsd(type: 'osd' | 'system' | 'both' | 'none' | undefined): bo
|
||||
return type !== 'none';
|
||||
}
|
||||
|
||||
function shouldFallbackToDesktop(
|
||||
type: 'osd' | 'system' | 'both' | 'none' | undefined,
|
||||
phase: CharacterDictionaryAutoSyncNotificationEvent['phase'],
|
||||
): boolean {
|
||||
return (
|
||||
(type === 'system' || type === 'both') &&
|
||||
(phase === 'generating' || phase === 'building' || phase === 'importing')
|
||||
);
|
||||
}
|
||||
|
||||
export function notifyCharacterDictionaryAutoSyncStatus(
|
||||
event: CharacterDictionaryAutoSyncNotificationEvent,
|
||||
deps: CharacterDictionaryAutoSyncNotificationDeps,
|
||||
@@ -23,12 +35,18 @@ export function notifyCharacterDictionaryAutoSyncStatus(
|
||||
const type = deps.getNotificationType();
|
||||
if (shouldShowOsd(type)) {
|
||||
if (deps.startupOsdSequencer) {
|
||||
deps.startupOsdSequencer.notifyCharacterDictionaryStatus({
|
||||
const shown = deps.startupOsdSequencer.notifyCharacterDictionaryStatus({
|
||||
phase: event.phase,
|
||||
message: event.message,
|
||||
});
|
||||
if (!shown && shouldFallbackToDesktop(type, event.phase)) {
|
||||
deps.showDesktopNotification('SubMiner', { body: event.message });
|
||||
}
|
||||
return;
|
||||
}
|
||||
deps.showOsd(event.message);
|
||||
const shown = deps.showOsd(event.message) !== false;
|
||||
if (!shown && shouldFallbackToDesktop(type, event.phase)) {
|
||||
deps.showDesktopNotification('SubMiner', { body: event.message });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user