mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-08-02 07:21:33 -07:00
refactor: split anki-connect and stats-server resolvers into modules (#169)
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { DEFAULT_CONFIG } from '../../definitions';
|
||||
import type { ResolveContext } from '../context';
|
||||
import { asString } from '../shared';
|
||||
import { applyModernValue } from './modern-value';
|
||||
|
||||
export function applyModernFieldsResolution(
|
||||
context: ResolveContext,
|
||||
fields: Record<string, unknown>,
|
||||
): void {
|
||||
for (const key of ['word', 'audio', 'image', 'sentence', 'miscInfo', 'translation'] as const) {
|
||||
applyModernValue(
|
||||
context,
|
||||
fields,
|
||||
key,
|
||||
`ankiConnect.fields.${key}`,
|
||||
asString,
|
||||
DEFAULT_CONFIG.ankiConnect.fields[key],
|
||||
(value) => {
|
||||
context.resolved.ankiConnect.fields[key] = value;
|
||||
},
|
||||
'Expected string.',
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user