Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run updates to cards in sequence to not overload ankiConnect connections #132

Merged
merged 1 commit into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "anki",
"displayName": "Anki for VSCode",
"description": "Sync notes with your locally running Anki",
"version": "1.3.3",
"version": "1.3.4",
"publisher": "jasew",
"license": "MIT",
"engines": {
Expand Down
11 changes: 7 additions & 4 deletions src/models/Deck.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Card } from "./Card";
import { workspace } from "vscode";
import { AnkiService } from "../AnkiService";
import { Card } from "./Card";
import { SendDiff } from "./SendDiff";
import { workspace } from "vscode";

export class Deck {
public readonly name: string;
Expand Down Expand Up @@ -112,8 +112,11 @@ export class Deck {
}

// Calls anki to update the fields of all the passed cards.
private async _pushUpdatedCardsToAnki(cards: Card[]): Promise<Card[]> {
return Promise.all(cards.map((card) => this.ankiService?.updateFields(card)));
private async _pushUpdatedCardsToAnki(cards: Card[]): Promise<void> {
// This should be in sequence to not overload AnkiConnect's connection limit
for (const card of cards) {
await this.ankiService?.updateFields(card);
}
}

async createAndUpdateCards(): Promise<Card[]> {
Expand Down
Loading