Skip to content

Commit

Permalink
fix blockid
Browse files Browse the repository at this point in the history
  • Loading branch information
Newdea committed Oct 11, 2024
1 parent 3083d80 commit a0458a7
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/dataStore/itemTrans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,8 @@ export class ItemTrans {
let blockID = question.questionText.obsidianBlockId;
const count: number = question.cards.length;
const scheduling: RegExpMatchArray[] = [];
if (settings.cardBlockID && !blockID) {
blockID = question.questionText.genBlockId = "^" + BlockUtils.generateBlockId();
}
let cardinfo = trackedFile.getSyncCardInfo(lineNo, cardTextHash, blockID);

if (cardinfo != null) {
cardinfo.itemIds
.map((id: number) => store.getItembyID(id).getSched())
Expand All @@ -162,6 +160,15 @@ export class ItemTrans {
cardinfo = trackedFile.trackCard(lineNo, cardTextHash);
}

// update blockid
if (settings.cardBlockID && !blockID) {
if (!cardinfo.blockID) {
blockID = "^" + BlockUtils.generateBlockId();
cardinfo = trackedFile.getSyncCardInfo(lineNo, cardTextHash, blockID);
}
question.questionText.genBlockId = cardinfo.blockID;
}

const dtppath = question.topicPathList.list[0] ?? undefined;
let deckname = dtppath?.hasPath ? dtppath.path[0] : topicPath.path[0];
deckname = Tags.isDefaultDackName(deckname) ? deckname : "#" + deckname;
Expand All @@ -187,8 +194,8 @@ function updateCardObjs(cards: Card[], cardinfo: CardInfo, scheduling: RegExpMat
const cardObj = cards[i];
const hasScheduleInfo: boolean = i < schedInfoList.length;
const schedule: CardScheduleInfo = schedInfoList[i];
const hassched = !schedule.isDummyScheduleForNewCard();
cardObj.scheduleInfo = hasScheduleInfo && hassched ? schedule : null;
const hassched = hasScheduleInfo && !schedule.isDummyScheduleForNewCard();
cardObj.scheduleInfo = hassched ? schedule : null;
cardObj.Id = carditemIds[i];

if (hassched) update = true;
Expand Down

0 comments on commit a0458a7

Please sign in to comment.