Skip to content

Commit

Permalink
fix#56 #58 (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
Newdea authored Jun 26, 2024
1 parent 27109e5 commit 2bb88ae
Show file tree
Hide file tree
Showing 15 changed files with 257 additions and 224 deletions.
7 changes: 7 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

## [1.12.4.7]

- fix: #56 复习时打开了没到期的笔记;
- fix: #58 卡片复习数据显示不正确;
- iteminfo 窗口显示优化


## [1.12.4.6]

- fix: #54 #56 复习时打开了没到期的笔记
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-spaced-repetition-recall",
"name": "Spaced Repetition Recall",
"version": "1.12.4.6",
"version": "1.12.4.7",
"minAppVersion": "0.15.4",
"description": "Fight the forgetting curve by reviewing flashcards & entire notes.",
"author": "Newdea",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-spaced-repetition",
"version": "1.12.4.6",
"version": "1.12.4.7",
"description": "Fight the forgetting curve by reviewing flashcards & entire notes.",
"main": "main.js",
"scripts": {
Expand Down
1 change: 0 additions & 1 deletion src/CardSchedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { ReviewResponse, schedule } from "./scheduling";
import { SRSettings } from "./settings";
import { formatDate_YYYY_MM_DD } from "./util/utils";
import { DateUtil, globalDateProvider } from "./util/DateProvider";
import { DateUtils } from "./util/utils_recall";

export class CardScheduleInfo {
dueDate: Moment;
Expand Down
5 changes: 4 additions & 1 deletion src/NoteQuestionParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ export class NoteQuestionParser {
//
private determineQuestionTopicPathList(question: Question): TopicPathList {
let result: TopicPathList;
if (this.settings.convertFoldersToDecks || this.settings.trackedNoteToDecks) {
if (this.settings.convertFoldersToDecks) {
result = new TopicPathList([this.folderTopicPath]);
} else {
// If present, the question specific TopicPath takes precedence over everything else
Expand Down Expand Up @@ -348,6 +348,9 @@ export class NoteQuestionParser {
}
}
}
if (!result && this.settings.trackedNoteToDecks && this.folderTopicPath) {
result = new TopicPathList([this.folderTopicPath]);
}
return result;
}
}
1 change: 0 additions & 1 deletion src/ReviewDeck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { TFile } from "obsidian";

import { t } from "src/lang/helpers";
import { RepetitionItem } from "./dataStore/repetitionItem";
import { DateUtils } from "./util/utils_recall";
import { globalDateProvider } from "./util/DateProvider";

export interface SchedNote {
Expand Down
6 changes: 3 additions & 3 deletions src/commands.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { MarkdownView, Notice } from "obsidian";
import ObsidianSrsPlugin from "./main";
import { ReviewNote } from "src/reviewNote/review-note";
import { ItemInfoModal } from "src/gui/info";
import { Queue } from "./dataStore/queue";
import { debug } from "./util/utils_recall";
import { postponeItems } from "./algorithms/balance/postpone";
import { reschedule } from "./algorithms/balance/reschedule";
import { GetInputModal } from "./gui/getInputModal";
import { ReviewView } from "./gui/reviewView";

export default class Commands {
plugin: ObsidianSrsPlugin;
Expand Down Expand Up @@ -38,7 +38,7 @@ export default class Commands {
// decks: deck.scheduledNotes.map((sn) => [sn.note.path, sn.item]),
que: store.data.queues.toDayLaterQueue,
});
new ItemInfoModal(plugin.data.settings, file).open();
new ItemInfoModal(plugin, file).open();
}
return true;
}
Expand Down Expand Up @@ -124,7 +124,7 @@ export default class Commands {
name: "Review",
callback: () => {
Queue.getInstance().buildQueue();
ReviewNote.recallReviewNote(this.plugin.data.settings);
ReviewView.getInstance().recallReviewNote(this.plugin.data.settings);
},
});

Expand Down
57 changes: 21 additions & 36 deletions src/dataStore/itemToDecks.ts → src/dataStore/itemTrans.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import { TFile } from "obsidian";
import { CardScheduleInfo, NoteCardScheduleParser } from "src/CardSchedule";
import { Note } from "src/Note";
import { ReviewDeck } from "src/ReviewDeck";
import { ReviewDeck, SchedNote } from "src/ReviewDeck";
import { SrTFile } from "src/SRFile";
import { TopicPath } from "src/TopicPath";
import { DataStore } from "src/dataStore/data";
import { BlockUtils, debug, logExecutionTime } from "src/util/utils_recall";
import { CardInfo } from "./trackedFile";
import { Card } from "src/Card";
import { DataLocation } from "./dataLocation";
import { RPITEMTYPE } from "./repetitionItem";
import { RPITEMTYPE, RepetitionItem } from "./repetitionItem";
import { Tags } from "src/tags";
import { SRSettings } from "src/settings";
import { INoteEaseList } from "src/NoteEaseList";
import { algorithmNames } from "src/algorithms/algorithms";

export class ItemToDecks {
export class ItemTrans {
settings: SRSettings;

static create(settings: SRSettings) {
return new ItemToDecks(settings);
return new ItemTrans(settings);
}
constructor(settings: SRSettings) {
this.settings = settings;
Expand All @@ -39,7 +39,6 @@ export class ItemToDecks {
const store = DataStore.getInstance();
const settings = this.settings;
// store.data.queues.buildQueue();
const now = new Date().getTime();
notes.forEach(async (note) => {
let deckname = Tags.getNoteDeckName(note, this.settings);
if (deckname == null) {
Expand Down Expand Up @@ -74,27 +73,8 @@ export class ItemToDecks {
}
}
}
ItemToDecks.toRevDeck(reviewDecks[deckname], note);
ItemTrans._toRevDeck(reviewDecks[deckname], note);
}

// Add Recall reviewnote deck
// const dkname = DEFAULT_DECKNAME;
// if (!Object.prototype.hasOwnProperty.call(reviewDecks, dkname)) {
// reviewDecks[dkname] = new ReviewDeck(dkname);
// }

// store.data.trackedFiles
// .filter((trackedFile) => trackedFile?.noteID >= 0 && trackedFile.isTracked)
// .filter((trackedFile) => trackedFile.isDefault)
// .filter((trackedFile) => {
// // only add default deck.
// const note = app.vault.getAbstractFileByPath(trackedFile.path) as TFile;
// if (note instanceof TFile) {
// noteStats.updateStats(store.getItembyID(trackedFile.noteID));
// DataSyncer.syncRCDataToSRrevDeck(reviewDecks[deckName], note);
// return true;
// }
// });
});
return;
}
Expand All @@ -105,11 +85,9 @@ export class ItemToDecks {
* @param rdeck
* @returns
*/
static toRevDeck(rdeck: ReviewDeck, note: TFile, now?: number) {
private static _toRevDeck(rdeck: ReviewDeck, note: TFile, now?: number) {
// const plugin = plugin;
// const rdeck = reviewDecks[deckName];
const store = DataStore.getInstance();
// const queue = store.data.queues;
const ind = store.getFileIndex(note.path);
const trackedFile = store.getTrackedFile(note.path);
const item = store.getNoteItem(note.path);
Expand All @@ -125,13 +103,7 @@ export class ItemToDecks {
}

if (item.hasDue) {
rdeck.scheduledNotes.push({
note,
item,
dueUnix: item.nextReview,
interval: item.interval,
ease: item.ease,
});
rdeck.scheduledNotes.push(itemToShedNote(item, note));
} else {
rdeck.newNotes.push({ note, item });
}
Expand All @@ -146,7 +118,10 @@ export class ItemToDecks {
const store = DataStore.getInstance();
const settings = store.settings;
const noteFile: SrTFile = note.file as SrTFile;
if (topicPath.isEmptyPath || settings.dataLocation === DataLocation.SaveOnNoteFile) {
if (
note.questionList.length === 0 ||
settings.dataLocation === DataLocation.SaveOnNoteFile
) {
return;
}
if (store.getFileIndex(note.filePath) < 0) {
Expand Down Expand Up @@ -208,3 +183,13 @@ function updateCardObjs(cards: Card[], cardinfo: CardInfo, scheduling: RegExpMat
cardObj.Id = carditemIds[i];
}
}

export function itemToShedNote(item: RepetitionItem, note: TFile): SchedNote {
return {
note,
item,
dueUnix: item.nextReview,
interval: item.interval,
ease: item.ease,
};
}
7 changes: 5 additions & 2 deletions src/dataStore/trackedFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ export class TrackedFile implements ITrackedFile {
settings.convertBoldTextToClozes,
settings.convertCurlyBracketsToClozes,
);
if (!this.hasCards && parsedCards.length === 0) {
return false;
}

for (const parsedCard of parsedCards) {
// deckPath = noteDeckPath;
Expand Down Expand Up @@ -218,7 +221,7 @@ export class TrackedFile implements ITrackedFile {

// sync by total parsedCards.length
if (!this.hasCards) {
return;
return false;
}
const carditems = this?.cardItems;
if (lines.length === carditems.length && negIndFlag) {
Expand All @@ -233,7 +236,7 @@ export class TrackedFile implements ITrackedFile {
}
}
// store.save();
return;
return true;
}

get lastTag() {
Expand Down
4 changes: 2 additions & 2 deletions src/gui/FlashcardReviewView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ export class FlashcardReviewView {

private _processReviewbyAlgo(response: ReviewResponse) {
const algo = this.plugin.algorithm;
setDueDates(this.plugin.noteStats.delayedDays.dict, this.plugin.noteStats.delayedDays.dict);
setDueDates(this.plugin.cardStats.delayedDays.dict, this.plugin.cardStats.delayedDays.dict);
const opt = algo.srsOptions()[response];
const store = this.plugin.store;
const id = this._currentCard.Id;
Expand Down Expand Up @@ -506,7 +506,7 @@ export class FlashcardReviewView {
const srfile = this._currentNote.file as SrTFile;
const store = this.plugin.store;
const id = this._currentCard.Id;
const infoM = new ItemInfoModal(this.settings, srfile.file, store.getItembyID(id));
const infoM = new ItemInfoModal(this.plugin, srfile.file, store.getItembyID(id));
infoM.open();
});
}
Expand Down
Loading

0 comments on commit 2bb88ae

Please sign in to comment.