mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-11-10 16:46:06 -08:00
fix(hachidori): keep the hachidori tag alongside SubMiner's Anki tags
- Untouched default templates now get configured tags plus `hachidori` instead of replacing it - Tags edited in Hachidori settings are left as written - Update Anki integration docs and changelog fragment
This commit is contained in:
4 files changed
+16
-4
No files matched your search
@@ -83,7 +83,7 @@ test('fresh Hachidori settings inherit deck, tags, a unique model and configured
|
||||
assert.deepEqual(await h.sync(), { updated: true, matched: true, pending: false });
|
||||
assert.deepEqual(
|
||||
await h.run('[options.anki.url, options.anki.deck, options.anki.model, options.anki.tags]'),
|
||||
['http://127.0.0.1:8766', 'Mining', 'Japanese', config.tags],
|
||||
['http://127.0.0.1:8766', 'Mining', 'Japanese', [...config.tags, 'hachidori']],
|
||||
);
|
||||
assert.deepEqual(
|
||||
await h.run(
|
||||
@@ -102,6 +102,16 @@ test('fresh Hachidori settings inherit deck, tags, a unique model and configured
|
||||
assert.equal(await h.run('writes'), 1);
|
||||
});
|
||||
|
||||
test('leaves tags edited in Hachidori settings alone', async () => {
|
||||
const h = await harness({
|
||||
templates: [
|
||||
{ id: 'default', name: 'Default', deck: 'Mining', model: 'Japanese', tags: ['SubMiner'] },
|
||||
],
|
||||
});
|
||||
await h.sync();
|
||||
assert.deepEqual(await h.run('options.anki.tags'), ['SubMiner']);
|
||||
});
|
||||
|
||||
// SubMiner's new-card polling only watches ankiConnect.deck, so the first
|
||||
// template's deck follows it the way Yomitan's term card deck does.
|
||||
test('moves the first template to the SubMiner deck and preserves the rest of custom templates', async () => {
|
||||
|
||||
@@ -49,8 +49,10 @@ export const HACHIDORI_ANKI_SETTINGS_SCRIPT = String.raw`
|
||||
// SubMiner's new-card polling only watches its configured deck, so the
|
||||
// first template follows it like Yomitan's term card deck.
|
||||
if (deck) template.deck = deck;
|
||||
// SubMiner's tags join Hachidori's own so cards show which backend mined
|
||||
// them. Only the untouched default is filled; edits in Hachidori settings win.
|
||||
if (hints?.tags && JSON.stringify(first.tags) === JSON.stringify(['hachidori'])) {
|
||||
template.tags = [...hints.tags];
|
||||
template.tags = [...new Set([...hints.tags, 'hachidori'])];
|
||||
}
|
||||
let pending = false;
|
||||
// Advanced templates include intentionally blank fields. Preserve them
|
||||
|
||||
Reference in new issue
Block a user