mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-06 19:57:26 -08:00
fix: preserve user dictionary ordering
This commit is contained in:
@@ -472,6 +472,11 @@ test('dictionary settings helpers upsert and remove dictionary entries', async (
|
|||||||
{
|
{
|
||||||
options: {
|
options: {
|
||||||
dictionaries: [
|
dictionaries: [
|
||||||
|
{
|
||||||
|
name: 'Jitendex',
|
||||||
|
alias: 'Jitendex',
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'SubMiner Character Dictionary (AniList 1)',
|
name: 'SubMiner Character Dictionary (AniList 1)',
|
||||||
alias: 'SubMiner Character Dictionary (AniList 1)',
|
alias: 'SubMiner Character Dictionary (AniList 1)',
|
||||||
@@ -506,6 +511,18 @@ test('dictionary settings helpers upsert and remove dictionary entries', async (
|
|||||||
assert.equal(removed, true);
|
assert.equal(removed, true);
|
||||||
const setCalls = scripts.filter((script) => script.includes('setAllSettings')).length;
|
const setCalls = scripts.filter((script) => script.includes('setAllSettings')).length;
|
||||||
assert.equal(setCalls, 2);
|
assert.equal(setCalls, 2);
|
||||||
|
|
||||||
|
const upsertScript = scripts.find(
|
||||||
|
(script) =>
|
||||||
|
script.includes('setAllSettings') && script.includes('"SubMiner Character Dictionary (AniList 1)"'),
|
||||||
|
);
|
||||||
|
assert.ok(upsertScript);
|
||||||
|
const jitendexOffset = upsertScript?.indexOf('"Jitendex"') ?? -1;
|
||||||
|
const subMinerOffset = upsertScript?.indexOf('"SubMiner Character Dictionary (AniList 1)"') ?? -1;
|
||||||
|
assert.equal(jitendexOffset >= 0, true);
|
||||||
|
assert.equal(subMinerOffset >= 0, true);
|
||||||
|
assert.equal(jitendexOffset < subMinerOffset, true);
|
||||||
|
assert.match(upsertScript ?? '', /"enabled":true/);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('importYomitanDictionaryFromZip uses settings automation bridge instead of custom backend action', async () => {
|
test('importYomitanDictionaryFromZip uses settings automation bridge instead of custom backend action', async () => {
|
||||||
|
|||||||
@@ -1593,11 +1593,6 @@ export async function upsertYomitanDictionarySettings(
|
|||||||
existing.alias = normalizedTitle;
|
existing.alias = normalizedTitle;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
if (existingIndex > 0) {
|
|
||||||
dictionaries.splice(existingIndex, 1);
|
|
||||||
dictionaries.unshift(existing);
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user