Skip to content

Commit

Permalink
bump version 1.10.5.2
Browse files Browse the repository at this point in the history
    close #25 add reset
    fix stats
    update docs
    fix last tag
    directly
    await
  • Loading branch information
Newdea committed Dec 3, 2023
1 parent 0d73be6 commit 3da233c
Show file tree
Hide file tree
Showing 13 changed files with 103 additions and 50 deletions.
6 changes: 6 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ 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.10.5.2]

- close #25, 笔记复习增加重来命令
- 修复查看数据时卡死的问题;
- 正常不会用到的命令放入了调试命令时;

## [1.10.5.1]

- 合并主分支;
Expand Down
4 changes: 2 additions & 2 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Suggestions:

1. Close the original plugin first to avoid conflict.
2. backup the note vault (because after changing the DataLocation in the settings, the review information in the note content will be deleted and saved to a separate file tracked_files.json.)

If you want to use FSRS algorithm, you need to set it as recommended [above CASE1]().
3. close Obsidan.md, copy `obsidian-spaced-repetition/data.json` to `obsidian-spaced-repetition-recall/data.json`, then start Obsidan.md.
4. If you want to use FSRS algorithm, you need to set it as recommended [above CASE1]().

---

Expand Down
4 changes: 2 additions & 2 deletions docs/使用教程.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

1. 先关闭原插件,避免冲突。
2. 备份笔记库(因在设置中修改DataLocation后,会删除笔记内容中的复习信息,另存到 单独文件 tracked_files.json。 )

如果是想用FSRS算法,需要按上述CASE1推荐设置。
3. 关闭Obsidian.md,复制原插件的`obsidian-spaced-repetition/data.json``obsidian-spaced-repetition-recall/data.json`,再打开Obsidan.md。
4. 如果是想用FSRS算法,需要按上述CASE1推荐设置。

---

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.10.5.1",
"version": "1.10.5.2",
"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.10.5.1",
"version": "1.10.5.2",
"description": "Fight the forgetting curve by reviewing flashcards & entire notes.",
"main": "main.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/Events/trackFileEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import SRPlugin from "src/main";

export function registerTrackFileEvents(plugin: SRPlugin) {
plugin.registerEvent(
plugin.app.vault.on("rename", (file, old) => {
plugin.app.vault.on("rename", async (file, old) => {
const trackFile = plugin.store.getTrackedFile(old);
if (trackFile != null) {
trackFile.rename(file.path);
plugin.store.save();
await plugin.store.save();
}
}),
);
Expand Down
24 changes: 12 additions & 12 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ export default class Commands {
// return false;
// },
// });
}

addDebugCommands() {
console.log("Injecting debug commands...");
const plugin = this.plugin;

plugin.addCommand({
id: "build-queue",
Expand All @@ -104,11 +109,6 @@ export default class Commands {
ReviewNote.recallReviewNote(this.plugin.data.settings);
},
});
}

addDebugCommands() {
console.log("Injecting debug commands...");
const plugin = this.plugin;

plugin.addCommand({
id: "debug-print-view-state",
Expand Down Expand Up @@ -141,13 +141,13 @@ export default class Commands {
// },
// });

// plugin.addCommand({
// id: "debug-clear-queue",
// name: "Clear Queue",
// callback: () => {
// Queue.getInstance().clearQueue();
// },
// });
plugin.addCommand({
id: "debug-clear-queue",
name: "Clear Queue",
callback: () => {
Queue.getInstance().clearQueue();
},
});

plugin.addCommand({
id: "debug-queue-all",
Expand Down
8 changes: 4 additions & 4 deletions src/dataStore/dataSyncer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ export class DataSyncer {
const ind = store.getFileIndex(note.path);
const trackedFile = store.getTrackedFile(note.path);
const fileid = store.getFileId(note.path);
let item = store.getItembyID(fileid);
const item = store.getItembyID(fileid);
let now_number: number = now;
const nowToday: number = DateUtils.EndofToday;

if (item == null || !item.isTracked) {
store._updateItem(fileid, ind, RPITEMTYPE.NOTE, rdeck.deckName);
item = store.getItembyID(fileid);
// store._updateItem(fileid, ind, RPITEMTYPE.NOTE, rdeck.deckName);
// item = store.getItembyID(fileid);
console.debug("syncRCDataToSRrevDeck update null item:", item, trackedFile);
// return;
return;
}
if (now == null) {
now_number = nowToday;
Expand Down
21 changes: 17 additions & 4 deletions src/dataStore/location_switch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import SRPlugin from "src/main";
import { isIgnoredPath } from "src/reviewNote/review-note";
import { SRSettings } from "src/settings";
import { escapeRegexString } from "src/util/utils";
import { DataStore } from "./data";
import { DataStore, RPITEMTYPE } from "./data";
import { Tags } from "src/tags";
import { DataSyncer } from "./dataSyncer";

Expand Down Expand Up @@ -342,9 +342,22 @@ export class LocationSwitch {
} else if (item?.isNew) {
plugin.noteStats.incrementNew();
}
if (item?.deckName === store.defaultDackName) {
fileText = addDefaultTagtoNote(fileText, this.revTag);
fileChanged = true;
//update tag to note
if (item?.itemType === RPITEMTYPE.NOTE) {
const noteTag = Tags.getNoteDeckName(note, this.settings);
if (item.deckName === store.defaultDackName) {
fileText = addDefaultTagtoNote(fileText, this.revTag);
fileChanged = true;
} else if (
noteTag == null &&
this.settings.tagsToReview.includes(item.deckName)
) {
const tag = [this.settings.tagsToReview[0], item.deckName.substring(1)]
.join("/")
.substring(1);
fileText = addDefaultTagtoNote(fileText, tag);
fileChanged = true;
}
}
if (!dryrun && fileChanged) {
if (fileText == null) {
Expand Down
21 changes: 21 additions & 0 deletions src/dataStore/repetitionItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,27 @@ export class RepetitionItem {
this.data = data;
}

/**
* @param {ReviewResult} result
* @return {*}
*/
reviewUpdate(result: ReviewResult) {
this.nextReview = DateUtils.fromNow(result.nextReview).getTime();
this.timesReviewed += 1;
if (result.correct) {
this.timesCorrect += 1;
this.errorStreak = 0;
} else {
this.errorStreak += 1;
}
}

/**
*
* @param isFsrs
* @param isNumDue default is true.
* @returns
*/
getSched(isFsrs?: boolean, isNumDue = true): RegExpMatchArray | null {
if (this.nextReview === 0 || this.nextReview === null || this.timesReviewed === 0) {
return null; // new card doesn't need schedinfo
Expand Down
29 changes: 16 additions & 13 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default class SRPlugin extends Plugin {
private questionPostponementList: QuestionPostponementList;
public incomingLinks: Record<string, LinkStat[]> = {};
public pageranks: Record<string, number> = {};
public dueNotesCount = 0;
private dueNotesCount = 0;
public dueDatesNotes: Record<number, number> = {}; // Record<# of days in future, due count>

public deckTree: Deck = new Deck("root", null);
Expand Down Expand Up @@ -209,9 +209,9 @@ export default class SRPlugin extends Plugin {
const options = this.algorithm.srsOptions();
const algo = this.data.settings.algorithm;
const showtext = this.data.settings.responseOptionBtnsText;
for (let i = 1; i < options.length; i++) {
options.map((option, i) => {
this.addCommand({
id: "srs-note-review-" + options[i].toLowerCase(),
id: "srs-note-review-" + option.toLowerCase(),
name: "review as: " + showtext[algo][i],
callback: () => {
const openFile: TFile | null = this.app.workspace.getActiveFile();
Expand All @@ -220,7 +220,7 @@ export default class SRPlugin extends Plugin {
}
},
});
}
});

this.addCommand({
id: "srs-review-flashcards",
Expand Down Expand Up @@ -588,7 +588,14 @@ export default class SRPlugin extends Plugin {
}

const settings = this.data.settings;
const deckname = Tags.getNoteDeckName(noteFile, this.data.settings);
let deckname = Tags.getNoteDeckName(noteFile, this.data.settings);
if (deckname == null) {
const tf = store.getTrackedFile(noteFile.path);
const tag = tf?.lastTag;
if (tag != undefined && settings.tagsToReview.includes(tag)) {
deckname = tag;
}
}
if (deckname != null) {
if (!Object.prototype.hasOwnProperty.call(this.reviewDecks, deckname)) {
this.reviewDecks[deckname] = new ReviewDeck(deckname);
Expand Down Expand Up @@ -632,13 +639,6 @@ export default class SRPlugin extends Plugin {
}
}
}
} else {
const tf = store.getTrackedFile(noteFile.path);
const tag = tf?.tags?.last();
if (tag != undefined && settings.tagsToReview.includes(tag)) {
tf.tags.remove(tag);
tf.updateTags(store.defaultDackName);
}
}
}

Expand Down Expand Up @@ -895,7 +895,10 @@ export default class SRPlugin extends Plugin {
async reviewNextNoteModal(): Promise<void> {
const reviewDeckNames: string[] = Object.keys(this.reviewDecks);
if (this.data.settings.reviewingNoteDirectly) {
const rdname = ReviewNote.getDeckNameForReviewDirectly(this.reviewDecks);
const rdname =
this.lastSelectedReviewDeck ??
ReviewNote.getDeckNameForReviewDirectly(this.reviewDecks) ??
reviewDeckNames[0];
this.reviewNextNote(rdname);
} else if (reviewDeckNames.length === 1) {
this.reviewNextNote(reviewDeckNames[0]);
Expand Down
15 changes: 11 additions & 4 deletions src/reviewNote/review-note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,20 @@ export class ReviewNote {
[deckKey: string]: ReviewDeck;
}): string | null {
const reviewDeckNames: string[] = Object.keys(reviewDecks);

const rdname = reviewDeckNames.find((dkey: string) => {
const rdnames: string[] = [];
reviewDeckNames.some((dkey: string) => {
const ndeck = reviewDecks[dkey];
const ncount = ndeck.dueNotesCount + ndeck.newNotes.length;
return ncount > 0;
if (ncount > 0) {
rdnames.push(dkey);
}
});
return rdname;
if (rdnames.length > 0) {
const ind = Math.floor(Math.random() * rdnames.length);
return rdnames[ind];
} else {
return null;
}
}

static getNextDueNoteIndex(NotesCount: number, openRandomNote: boolean = false) {
Expand Down
13 changes: 8 additions & 5 deletions src/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,15 @@ export class Stats {
const interval: number = parseInt(scheduling[2]),
ease: number = parseFloat(scheduling[3]);
const delayedDays: number = Math.ceil(
(window
.moment(scheduling[1], ["YYYY-MM-DD", "DD-MM-YYYY", "ddd MMM DD YYYY"])
.valueOf() -
now) /
DateUtils.DAYS_TO_MILLIS,
(parseFloat(scheduling[1]) - now) / DateUtils.DAYS_TO_MILLIS,
);
// const delayedDays: number = Math.ceil(
// (window
// .moment(scheduling[1], ["YYYY-MM-DD", "DD-MM-YYYY", "ddd MMM DD YYYY"])
// .valueOf() -
// now) /
// DateUtils.DAYS_TO_MILLIS,
// );
this.update(delayedDays, interval, ease);
}

Expand Down

0 comments on commit 3da233c

Please sign in to comment.