Move showDupes()

This commit is contained in:
Abdo 2025-06-02 03:41:58 +03:00
parent 0966cd4552
commit 8391761bc2
3 changed files with 30 additions and 25 deletions

View file

@ -30,7 +30,7 @@ import aqt.operations
import aqt.sound
from anki._legacy import deprecated
from anki.cards import Card
from anki.collection import Config, SearchNode
from anki.collection import Config
from anki.consts import MODEL_CLOZE
from anki.hooks import runFilter
from anki.httpclient import HttpClient
@ -588,21 +588,6 @@ require("anki/ui").loaded.then(() => require("anki/NoteEditor").instances[0].too
"}); "
)
def showDupes(self) -> None:
assert self.note is not None
aqt.dialogs.open(
"Browser",
self.mw,
search=(
SearchNode(
dupe=SearchNode.Dupe(
notetype_id=self.note_type()["id"],
first_field=self.note.fields[0],
)
),
),
)
def fieldsAreBlank(self, previousNote: Note | None = None) -> bool:
if not self.note:
return True
@ -1268,7 +1253,6 @@ require("anki/ui").loaded.then(() => require("anki/NoteEditor").instances[0].too
attach=Editor.onAddMedia,
record=Editor.onRecSound,
more=Editor.onAdvanced,
dupes=Editor.showDupes,
paste=Editor.onPaste,
cutOrCopy=Editor.onCutOrCopy,
htmlEdit=Editor.onHtmlEdit,

View file

@ -3,12 +3,29 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import { searchInBrowser } from "@generated/backend";
import * as tr from "@generated/ftl";
import { bridgeCommand } from "@tslib/bridgecommand";
import type { Note } from "@generated/anki/notes_pb";
export let note: Note | null = null;
function showDupes() {
if (note) {
searchInBrowser({
filter: {
case: "dupe",
value: {
notetypeId: note.notetypeId,
firstField: note.fields[0],
},
},
});
}
}
</script>
<span class="duplicate-link-container">
<a class="duplicate-link" href="/#" on:click={() => bridgeCommand("dupes")}>
<a class="duplicate-link" href="/#" on:click={showDupes}>
{tr.editingShowDuplicates()}
</a>
</span>

View file

@ -585,7 +585,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
});
}
async function loadNote(nid: bigint, notetypeId: bigint, focusTo: number, originalNoteId: bigint | null) {
async function loadNote(
nid: bigint,
notetypeId: bigint,
focusTo: number,
originalNoteId: bigint | null,
) {
const notetype = await getNotetype({
ntid: notetypeId,
});
@ -658,8 +663,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
noteId: nid,
},
});
}
else if(originalNoteId) {
} else if (originalNoteId) {
setupMaskEditor({
html: imageField,
mode: {
@ -863,7 +867,7 @@ components and functionality for general note editing.
</svelte:fragment>
<FieldState>
{#if cols[index] === "dupe"}
<DuplicateLink />
<DuplicateLink {note} />
{/if}
{#if mode === "add"}
<StickyBadge