Skip to content

Commit

Permalink
🎨 fix #10318
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Feb 6, 2024
1 parent b35b38d commit 851a2e6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion app/src/card/openCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ export const bindCardEvent = async (options: {
element.previousElementSibling.textContent = options.cardsData.cards[index].nextDues[btnIndex];
});
actionElements[1].classList.remove("fn__none");
emitEvent(options.app, options.cardsData.cards, type);
return;
}
} else if (type === "-2") { // 上一步
Expand All @@ -380,6 +381,7 @@ export const bindCardEvent = async (options: {
index,
cardsData: options.cardsData
});
emitEvent(options.app, options.cardsData.cards, type);
}
return;
}
Expand Down Expand Up @@ -410,6 +412,7 @@ export const bindCardEvent = async (options: {
}, async (result) => {
index = 0;
options.cardsData = result.data;
emitEvent(options.app, options.cardsData.cards, type);
for (let i = 0; i < options.app.plugins.length; i++) {
options.cardsData = await options.app.plugins[i].updateCards(options.cardsData);
}
Expand Down Expand Up @@ -438,12 +441,22 @@ export const bindCardEvent = async (options: {
index,
cardsData: options.cardsData
});
emitEvent(options.app, options.cardsData.cards, type);
});
}
});
return editor;
};

const emitEvent = (app: App, cards: ICard[], type: string) => {
app.plugins.forEach(item => {
item.eventBus.emit("click-flashcard-action", {
type,
cards
});
});
};

export const openCard = (app: App) => {
fetchPost("/api/riff/getRiffDueCards", {deckID: ""}, (cardsResponse) => {
openCardByData(app, cardsResponse.data, "all");
Expand Down Expand Up @@ -530,7 +543,7 @@ const nextCard = (options: {
options.actionElements[1].classList.add("fn__none");
options.editor.protyle.element.classList.remove("fn__none");
options.editor.protyle.element.nextElementSibling.classList.add("fn__none");
options.countElement.innerHTML = genCardCount(options.cardsData.unreviewedNewCardCount, options.cardsData.unreviewedOldCardCount, options.index + 1);
options.countElement.innerHTML = genCardCount(options.cardsData.unreviewedNewCardCount, options.cardsData.unreviewedOldCardCount, options.index + 1);
options.countElement.classList.remove("fn__none");
if (options.index === 0) {
options.actionElements[0].firstElementChild.setAttribute("disabled", "disabled");
Expand Down

0 comments on commit 851a2e6

Please sign in to comment.