Skip to content

Commit

Permalink
1.12.5.11 (#80)
Browse files Browse the repository at this point in the history
## [1.12.5.11]

-   feat #78 fsrs v5 setting support enable_short_term and enable_fuzz (by @ishiko732).
-   fix #77 codeblock render error;
-   fix #76 sidebar note didn't show;
-   fix note random review;
  • Loading branch information
Newdea authored Sep 4, 2024
1 parent daf7a12 commit 99a54d1
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 29 deletions.
7 changes: 7 additions & 0 deletions docs/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.5.11]

- feat #78 fsrs v5 setting support enable_short_term and enable_fuzz (by @ishiko732).
- fix #77 codeblock render error;
- fix #76 sidebar note didn't show;
- fix note random review;

## [1.12.5.10]

- 同步原插件最新分支sync upsteam branch;
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.5.10",
"version": "1.12.5.11",
"minAppVersion": "1.2.8",
"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.5.10",
"version": "1.12.5.11",
"description": "Fight the forgetting curve by reviewing flashcards & entire notes.",
"main": "main.js",
"scripts": {
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

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

11 changes: 8 additions & 3 deletions src/generateParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ main
/* The input text to the parser contains arbitrary text, not just card definitions.
Hence we fallback to matching on loose_line. The result from loose_line is filtered out by filterBlocks() */
block
= html_comment / inline_rev_card / inline_card / multiline_rev_card / multiline_card / close_card / loose_line
= html_comment / inline_rev_card / inline_card / multiline_rev_card / multiline_card / close_card / backprime_code_line / loose_line
html_comment
= $("<!--" (!"-->" (html_comment / .))* "-->" newline?) {
Expand Down Expand Up @@ -127,7 +127,7 @@ multiline
}
multiline_before
= $(!multiline_mark nonempty_text_line)+
= $(!multiline_mark (tilde_code / backprime_code / nonempty_text_line ))+
multiline_after
= $(!separator_line (tilde_code / backprime_code / text_line))+
Expand All @@ -143,6 +143,11 @@ tilde_code
tilde_marker
= "~~~" "~"*
backprime_code_line
= $(backprime_code) {
return createParsedQuestionInfo(CardType.Ignore,"",location().start.line-1,location().end.line-2);
}
backprime_code
= $(
left:$backprime_marker text_line
Expand Down Expand Up @@ -177,7 +182,7 @@ close_line
= ((!close_text non_newline)* close_text) text_line_nonterminated?
multiline_before_close
= (!close_line nonempty_text_line)+
= (!close_line !backprime_marker nonempty_text_line)+
multiline_after_close
= e:(!(newline separator_line) text_line1)+
Expand Down
9 changes: 5 additions & 4 deletions src/gui/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,12 @@ export class ReviewQueueListView extends ItemView {
deck: ReviewDeck,
plugin: SRPlugin,
): void {
const navFileEl: HTMLElement = folderEl
.getElementsByClassName("tree-item-children nav-folder-children")[0]
.createDiv("nav-file");
const childrenEl: HTMLElement = folderEl.getElementsByClassName(
"tree-item-children nav-folder-children",
)[0] as HTMLElement;
const navFileEl: HTMLElement = childrenEl.createDiv("nav-file");
if (hidden) {
navFileEl.style.display = "none";
childrenEl.style.display = "none";
}

const navFileTitle: HTMLElement = navFileEl.createDiv("tree-item-self nav-file-title");
Expand Down
29 changes: 19 additions & 10 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export default class SRPlugin extends Plugin {

async onload(): Promise<void> {
SRPlugin._instance = this;
Iadapter.create(this.app);
await this.loadPluginData();
this.easeByPath = new NoteEaseList(this.data.settings);
this.questionPostponementList = new QuestionPostponementList(
Expand All @@ -157,7 +158,6 @@ export default class SRPlugin extends Plugin {
if (isVersionNewerThanOther(PLUGIN_VERSION, this.data.settings.previousRelease)) {
new ReleaseNotes(this.app, this, obsidianJustInstalled ? null : PLUGIN_VERSION).open();
}
Iadapter.create(this.app);

const settings = this.data.settings;
this.algorithm = algorithms[settings.algorithm];
Expand Down Expand Up @@ -188,7 +188,15 @@ export default class SRPlugin extends Plugin {
registerTrackFileEvents(this);

if (this.data.settings.dataLocation !== DataLocation.SaveOnNoteFile) {
this.registerInterval(window.setInterval(() => this.store.save(), 5 * 60 * 1000));
this.registerInterval(
window.setInterval(
async () => {
await this.sync();
this.store.save();
},
5 * 60 * 1000,
),
);
}

this.statusBar = this.addStatusBarItem();
Expand Down Expand Up @@ -867,11 +875,11 @@ export default class SRPlugin extends Plugin {
}
};

index = IReviewNote.getNextDueNoteIndex(
deck.dueNotesCount,
this.data.settings.openRandomNote,
);
if (mqs.isDue && index >= 0) {
if (mqs.isDue && deck.dueNotesCount > 0) {
index = IReviewNote.getNextNoteIndex(
deck.dueNotesCount,
this.data.settings.openRandomNote,
);
await this.app.workspace.getLeaf().openFile(deck.scheduledNotes[index].note);
item = deck.scheduledNotes[index].item;
fShowItemInfo(item, "scheduledNoes index: " + index);
Expand All @@ -891,9 +899,10 @@ export default class SRPlugin extends Plugin {
}
}
if (!mqs.isDue && deck.newNotes.length > 0) {
const index = this.data.settings.openRandomNote
? Math.floor(Math.random() * deck.newNotes.length)
: 0;
const index = IReviewNote.getNextNoteIndex(
deck.newNotes.length,
this.data.settings.openRandomNote,
);
await this.app.workspace.getLeaf().openFile(deck.newNotes[index].note);
item = deck.newNotes[index].item;
fShowItemInfo(item, "newNotes index:" + index);
Expand Down
9 changes: 3 additions & 6 deletions src/reviewNote/review-note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,13 @@ export abstract class IReviewNote {
}
}

static getNextDueNoteIndex(NotesCount: number, openRandomNote: boolean = false) {
let index = -1;
static getNextNoteIndex(NotesCount: number, openRandomNote: boolean = false) {
let index = 0;

if (NotesCount < 1) {
return -1;
}
if (!openRandomNote) {
return 0;
} else {
index = Math.floor(Math.random() * NotesCount);
index = Math.floor(Math.random() * (NotesCount - 0.1)); // avoid conner case: index == notesCount;
}
return index;
}
Expand Down

0 comments on commit 99a54d1

Please sign in to comment.