mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-07-28 04:49:49 -07:00
fix(overlay): gate the maturity legend on known-word highlighting
The session help color legend showed the four tier rows whenever maturityEnabled was on, even with known-word highlighting off, where no token is ever tinted. Extract isKnownWordMaturityLegendEnabled so the legend requires both toggles, matching getKnownWordMaturityEnabled.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { ModalStateReader, RendererContext } from '../context';
|
||||
import type { RuntimeOptionId, RuntimeOptionState } from '../../types/runtime-options';
|
||||
import {
|
||||
buildSessionHelpSections,
|
||||
type SessionHelpSection,
|
||||
@@ -19,6 +20,19 @@ type SessionHelpBindingInfo = {
|
||||
fallbackUnavailable: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* Tiers only render when known-word highlighting is also on, matching
|
||||
* getKnownWordMaturityEnabled in anki-integration/known-word-maturity.
|
||||
*/
|
||||
export function isKnownWordMaturityLegendEnabled(runtimeOptions: RuntimeOptionState[]): boolean {
|
||||
const isOn = (id: RuntimeOptionId): boolean =>
|
||||
runtimeOptions.some((option) => option.id === id && option.value === true);
|
||||
return (
|
||||
isOn('subtitle.annotation.knownWords.highlightEnabled') &&
|
||||
isOn('subtitle.annotation.knownWords.maturityEnabled')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Maturity coloring is a live runtime toggle, so the color legend reads it from
|
||||
* runtime options instead of the resolved subtitle style. A missing or failing
|
||||
@@ -26,11 +40,7 @@ type SessionHelpBindingInfo = {
|
||||
*/
|
||||
async function readKnownWordMaturityEnabled(): Promise<boolean> {
|
||||
try {
|
||||
const runtimeOptions = await window.electronAPI.getRuntimeOptions();
|
||||
return runtimeOptions.some(
|
||||
(option) =>
|
||||
option.id === 'subtitle.annotation.knownWords.maturityEnabled' && option.value === true,
|
||||
);
|
||||
return isKnownWordMaturityLegendEnabled(await window.electronAPI.getRuntimeOptions());
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user