add how to populate from wanikani

This commit is contained in:
polv committed 2022-04-28 13:28:06 +07:00
1 parent 92c1de3d1f
commit 45232b33fc
4 files changed
+130 -28

No files matched your search

+1 -20
View File
@@ -1,3 +1,4 @@
import { soundTag } from '@/anki';
import { AnkiConnect } from '@/ankiconnect';
export async function listTags(
@@ -14,26 +15,6 @@ export async function listTags(
});
}
const soundTag = {
pre: '[sound:',
post: ']',
is(src: string) {
return src.startsWith(this.pre) && src.endsWith(this.post);
},
add(src: string) {
if (soundTag.is(src)) return src;
return this.pre + src + this.post;
},
remove(src: string) {
if (!soundTag.is(src)) return src;
if (this.isEmpty(src)) return src;
return src.substring(this.pre.length, src.length - this.post.length);
},
isEmpty(src: string) {
return src === this.pre + this.post;
},
};
export async function addSoundTag(query: string, fieldNames: string[]) {
query +=
' (' + fieldNames.map((f) => `(-${f}: -${f}:[sound:*)`).join(' OR ') + ')';