Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2023-03-24 11:25:33 +08:00
commit 71a6158f61
5 changed files with 572 additions and 347 deletions

View file

@ -206,11 +206,13 @@ const boot = () => {
height: defaultHeight,
}, oldWindowState);
// writeLog("windowStat [width=" + windowState.width + ", height=" + windowState.height + "], default [width=" + defaultWidth + ", height=" + defaultHeight + "], workArea [width=" + workArea.width + ", height=" + workArea.height + "]");
let x = windowState.x;
let y = windowState.y;
if (workArea) {
// 窗口大小等同于或大于 workArea 时缩小会隐藏到左下角
if (windowState.width >= workArea.width || windowState.height >= workArea.height) {
// 窗口大于 workArea 时缩小会隐藏到左下角,这里使用最小值重置
if (windowState.width > workArea.width || windowState.height > workArea.height) { // 重启后窗口大小恢复默认问题 https://github.com/siyuan-note/siyuan/issues/7755
windowState.width = Math.min(defaultWidth, workArea.width);
windowState.height = Math.min(defaultHeight, workArea.height);
}
@ -221,11 +223,11 @@ const boot = () => {
y = 0;
}
}
if (windowState.width < 400) {
windowState.width = 400;
if (windowState.width < 493) {
windowState.width = 493;
}
if (windowState.height < 300) {
windowState.height = 300;
if (windowState.height < 376) {
windowState.height = 376;
}
if (x < 0) {
x = 0;

View file

@ -5,7 +5,7 @@
"Properties": {
"id": "20221223221636-ms2b4w9",
"title": "Flashcards",
"updated": "20230304000717"
"updated": "20230324111319"
},
"Children": [
{
@ -192,116 +192,34 @@
]
},
{
"ID": "20230219092249-l3b55a9",
"Type": "NodeHeading",
"HeadingLevel": 3,
"Properties": {
"id": "20230219092249-l3b55a9",
"updated": "20230219092431"
},
"Children": [
{
"Type": "NodeText",
"Data": "Based on card deck"
}
]
},
{
"ID": "20230219092249-4f5q0yn",
"ID": "20230324110955-eznqs9u",
"Type": "NodeParagraph",
"Properties": {
"id": "20230219092249-4f5q0yn",
"updated": "20230219092602"
"id": "20230324110955-eznqs9u",
"updated": "20230324111043"
},
"Children": [
{
"Type": "NodeText",
"Data": "Based on the use of card deck, the content blocks in different documents can be carded and put into a unified card pack for review."
}
]
},
{
"ID": "20230219092249-adkmzaf",
"Type": "NodeList",
"ListData": {},
"Properties": {
"id": "20230219092249-adkmzaf",
"updated": "20230219092718"
},
"Children": [
{
"ID": "20230219092249-w4nnmee",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20230219092249-w4nnmee",
"updated": "20230219092718"
},
"Children": [
{
"ID": "20230219092249-3h4zeve",
"Type": "NodeParagraph",
"Properties": {
"id": "20230219092249-3h4zeve",
"updated": "20230219092718"
},
"Children": [
{
"Type": "NodeText",
"Data": "Select "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "Add to card deck..."
},
{
"Type": "NodeText",
"Data": " in the block label menu, and then add the content block to a card deck to complete the card making"
}
]
}
]
"Data": "Among them, if you dont need the super block card and list or list item card, you can turn it off in "
},
{
"ID": "20230219092249-cf49472",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20230219092249-cf49472",
"updated": "20230219092643"
},
"Children": [
{
"ID": "20230219092249-gtv3hbr",
"Type": "NodeParagraph",
"Properties": {
"id": "20230219092249-gtv3hbr",
"updated": "20230219092643"
},
"Children": [
{
"Type": "NodeText",
"Data": "Access review by clicking "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "Flashcard"
},
{
"Type": "NodeText",
"Data": " in the top bar menu"
}
]
}
]
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "Settings"
},
{
"Type": "NodeText",
"Data": " - "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "Flashcard"
},
{
"Type": "NodeText",
"Data": "."
}
]
},
@ -311,7 +229,7 @@
"HeadingLevel": 3,
"Properties": {
"id": "20230219092249-3oeqj8o",
"updated": "20230219092505"
"updated": "20230324110951"
},
"Children": [
{
@ -325,7 +243,7 @@
"Type": "NodeParagraph",
"Properties": {
"id": "20230219092249-9l69wsr",
"updated": "20230219092712"
"updated": "20230324110951"
},
"Children": [
{
@ -340,7 +258,7 @@
"ListData": {},
"Properties": {
"id": "20230219092249-wbyos2h",
"updated": "20230219092822"
"updated": "20230324110951"
},
"Children": [
{
@ -419,6 +337,169 @@
}
]
},
{
"ID": "20230219092249-l3b55a9",
"Type": "NodeHeading",
"HeadingLevel": 3,
"Properties": {
"id": "20230219092249-l3b55a9",
"updated": "20230219092431"
},
"Children": [
{
"Type": "NodeText",
"Data": "Based on card deck"
}
]
},
{
"ID": "20230219092249-4f5q0yn",
"Type": "NodeParagraph",
"Properties": {
"id": "20230219092249-4f5q0yn",
"updated": "20230219092602"
},
"Children": [
{
"Type": "NodeText",
"Data": "Based on the use of card deck, the content blocks in different documents can be carded and put into a unified card pack for review."
}
]
},
{
"ID": "20230219092249-adkmzaf",
"Type": "NodeList",
"ListData": {},
"Properties": {
"id": "20230219092249-adkmzaf",
"updated": "20230219092718"
},
"Children": [
{
"ID": "20230219092249-w4nnmee",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20230219092249-w4nnmee",
"updated": "20230219092718"
},
"Children": [
{
"ID": "20230219092249-3h4zeve",
"Type": "NodeParagraph",
"Properties": {
"id": "20230219092249-3h4zeve",
"updated": "20230219092718"
},
"Children": [
{
"Type": "NodeText",
"Data": "Select "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "Add to card deck..."
},
{
"Type": "NodeText",
"Data": " in the block label menu, and then add the "
},
{
"Type": "NodeText",
"Data": "content block"
},
{
"Type": "NodeText",
"Data": " to a card deck to complete the card making"
}
]
}
]
},
{
"ID": "20230219092249-cf49472",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20230219092249-cf49472",
"updated": "20230219092643"
},
"Children": [
{
"ID": "20230219092249-gtv3hbr",
"Type": "NodeParagraph",
"Properties": {
"id": "20230219092249-gtv3hbr",
"updated": "20230219092643"
},
"Children": [
{
"Type": "NodeText",
"Data": "Access review by clicking "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "Flashcard"
},
{
"Type": "NodeText",
"Data": " in the top bar menu"
}
]
}
]
}
]
},
{
"ID": "20230324111120-9sfynhi",
"Type": "NodeParagraph",
"Properties": {
"id": "20230324111120-9sfynhi",
"updated": "20230324111319"
},
"Children": [
{
"Type": "NodeText",
"Data": "This mode of use is disabled by default. If necessary, it can be enabled in "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "Settings"
},
{
"Type": "NodeText",
"Data": " - "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "Flashcard"
},
{
"Type": "NodeText",
"Data": " - "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "Deck"
},
{
"Type": "NodeText",
"Data": ". However, it is not recommended to use flashcards based on card deck, because the card deck are fixed and not as flexible as using flashcards based on documents."
}
]
},
{
"ID": "20221223221639-djlafd4",
"Type": "NodeHeading",

View file

@ -5,7 +5,7 @@
"Properties": {
"id": "20221223215557-o6gfsoy",
"title": "闪卡",
"updated": "20230304000800"
"updated": "20230324110708"
},
"Children": [
{
@ -200,116 +200,34 @@
]
},
{
"ID": "20230219084417-qgvd9bn",
"Type": "NodeHeading",
"HeadingLevel": 3,
"Properties": {
"id": "20230219084417-qgvd9bn",
"updated": "20230219090057"
},
"Children": [
{
"Type": "NodeText",
"Data": "基于卡包"
}
]
},
{
"ID": "20230219090359-1b55hzy",
"ID": "20230324105957-puvmnur",
"Type": "NodeParagraph",
"Properties": {
"id": "20230219090359-1b55hzy",
"updated": "20230219092526"
"id": "20230324105957-puvmnur",
"updated": "20230324110110"
},
"Children": [
{
"Type": "NodeText",
"Data": "基于卡包的使用方式可以将不同文档中的内容块制卡后放到统一的卡包中复习。"
}
]
},
{
"ID": "20221223215834-z8ny593",
"Type": "NodeList",
"ListData": {},
"Properties": {
"id": "20221223215834-z8ny593",
"updated": "20230219091828"
},
"Children": [
{
"ID": "20221229111046-50w42e3",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20221229111046-50w42e3",
"updated": "20230219091828"
},
"Children": [
{
"ID": "20221229111046-fh0iyx1",
"Type": "NodeParagraph",
"Properties": {
"id": "20221229111046-fh0iyx1",
"updated": "20230219091828"
},
"Children": [
{
"Type": "NodeText",
"Data": "在块标菜单中选择 "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "添加到卡包..."
},
{
"Type": "NodeText",
"Data": "​,然后将该内容块添加到一个卡包中完成制卡"
}
]
}
]
"Data": "其中超级块制卡和列表或者列表项制卡如果不需要的话可以在 "
},
{
"ID": "20221223220710-o4y8jae",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20221223220710-o4y8jae",
"updated": "20230219085236"
},
"Children": [
{
"ID": "20221223220710-n98j2n8",
"Type": "NodeParagraph",
"Properties": {
"id": "20221223220710-n98j2n8",
"updated": "20230219085236"
},
"Children": [
{
"Type": "NodeText",
"Data": "通过点击顶栏菜单中的 "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "闪卡"
},
{
"Type": "NodeText",
"Data": " 进入复习"
}
]
}
]
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "设置"
},
{
"Type": "NodeText",
"Data": " - "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "闪卡"
},
{
"Type": "NodeText",
"Data": " 中关闭。"
}
]
},
@ -333,7 +251,7 @@
"Type": "NodeParagraph",
"Properties": {
"id": "20230219090448-88z0ib9",
"updated": "20230219090740"
"updated": "20230324110211"
},
"Children": [
{
@ -427,6 +345,161 @@
}
]
},
{
"ID": "20230219084417-qgvd9bn",
"Type": "NodeHeading",
"HeadingLevel": 3,
"Properties": {
"id": "20230219084417-qgvd9bn",
"updated": "20230324110146"
},
"Children": [
{
"Type": "NodeText",
"Data": "基于卡包"
}
]
},
{
"ID": "20230219090359-1b55hzy",
"Type": "NodeParagraph",
"Properties": {
"id": "20230219090359-1b55hzy",
"updated": "20230324110447"
},
"Children": [
{
"Type": "NodeText",
"Data": "基于卡包的使用方式可以将不同文档中的内容块制卡后放到统一的卡包中复习。"
}
]
},
{
"ID": "20221223215834-z8ny593",
"Type": "NodeList",
"ListData": {},
"Properties": {
"id": "20221223215834-z8ny593",
"updated": "20230219091828"
},
"Children": [
{
"ID": "20221229111046-50w42e3",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20221229111046-50w42e3",
"updated": "20230219091828"
},
"Children": [
{
"ID": "20221229111046-fh0iyx1",
"Type": "NodeParagraph",
"Properties": {
"id": "20221229111046-fh0iyx1",
"updated": "20230219091828"
},
"Children": [
{
"Type": "NodeText",
"Data": "在块标菜单中选择 "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "添加到卡包..."
},
{
"Type": "NodeText",
"Data": "​​,然后将该内容块添加到一个卡包中完成制卡"
}
]
}
]
},
{
"ID": "20221223220710-o4y8jae",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20221223220710-o4y8jae",
"updated": "20230219085236"
},
"Children": [
{
"ID": "20221223220710-n98j2n8",
"Type": "NodeParagraph",
"Properties": {
"id": "20221223220710-n98j2n8",
"updated": "20230219085236"
},
"Children": [
{
"Type": "NodeText",
"Data": "通过点击顶栏菜单中的 "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "闪卡"
},
{
"Type": "NodeText",
"Data": " 进入复习"
}
]
}
]
}
]
},
{
"ID": "20230324110448-ows59fl",
"Type": "NodeParagraph",
"Properties": {
"id": "20230324110448-ows59fl",
"updated": "20230324110708"
},
"Children": [
{
"Type": "NodeText",
"Data": "该使用方式默认关闭,如果需要可以在 "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "设置"
},
{
"Type": "NodeText",
"Data": " - "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "闪卡"
},
{
"Type": "NodeText",
"Data": " - "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "卡包"
},
{
"Type": "NodeText",
"Data": " 中开启。但建议不要基于卡包使用闪卡,因为卡包是固定的,没有基于文档使用闪卡灵活。"
}
]
},
{
"ID": "20221223221214-wr48h8b",
"Type": "NodeHeading",

View file

@ -5,7 +5,7 @@
"Properties": {
"id": "20221223221501-mops33i",
"title": "閃卡",
"updated": "20230304000916"
"updated": "20230324110901"
},
"Children": [
{
@ -196,116 +196,34 @@
]
},
{
"ID": "20230219092911-wh5sgd8",
"Type": "NodeHeading",
"HeadingLevel": 3,
"Properties": {
"id": "20230219092911-wh5sgd8",
"updated": "20230219092911"
},
"Children": [
{
"Type": "NodeText",
"Data": "基於卡包"
}
]
},
{
"ID": "20230219092911-ol65uqs",
"ID": "20230324110806-8rbbppa",
"Type": "NodeParagraph",
"Properties": {
"id": "20230219092911-ol65uqs",
"updated": "20230219092911"
"id": "20230324110806-8rbbppa",
"updated": "20230324110821"
},
"Children": [
{
"Type": "NodeText",
"Data": "基於卡包的使用方式可以將不同文檔中的內容塊制卡後放到統一的卡包中復習。"
}
]
},
{
"ID": "20230219092911-u7jucj7",
"Type": "NodeList",
"ListData": {},
"Properties": {
"id": "20230219092911-u7jucj7",
"updated": "20230219092928"
},
"Children": [
{
"ID": "20230219092911-s4dh6g1",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20230219092911-s4dh6g1",
"updated": "20230219092922"
},
"Children": [
{
"ID": "20230219092911-9cn6n81",
"Type": "NodeParagraph",
"Properties": {
"id": "20230219092911-9cn6n81",
"updated": "20230219092922"
},
"Children": [
{
"Type": "NodeText",
"Data": "在塊標菜單中選擇 "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "添加到卡包..."
},
{
"Type": "NodeText",
"Data": "​,然後將該內容塊添加到一個卡包中完成製卡"
}
]
}
]
"Data": "其中超級塊制卡和列表或者列表項製卡如果不需要的話可以在 "
},
{
"ID": "20230219092911-lxrxhy6",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20230219092911-lxrxhy6",
"updated": "20230219092928"
},
"Children": [
{
"ID": "20230219092911-05ghbty",
"Type": "NodeParagraph",
"Properties": {
"id": "20230219092911-05ghbty",
"updated": "20230219092928"
},
"Children": [
{
"Type": "NodeText",
"Data": "通過點擊頂欄菜單中的 "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "閃卡"
},
{
"Type": "NodeText",
"Data": " 進入複習"
}
]
}
]
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "設置"
},
{
"Type": "NodeText",
"Data": " - "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "閃卡"
},
{
"Type": "NodeText",
"Data": " 中關閉。"
}
]
},
@ -315,7 +233,7 @@
"HeadingLevel": 3,
"Properties": {
"id": "20230219092911-kawl9n2",
"updated": "20230219092911"
"updated": "20230324110737"
},
"Children": [
{
@ -329,7 +247,7 @@
"Type": "NodeParagraph",
"Properties": {
"id": "20230219092911-vfi7z5z",
"updated": "20230219092911"
"updated": "20230324110737"
},
"Children": [
{
@ -344,7 +262,7 @@
"ListData": {},
"Properties": {
"id": "20230219092911-jluw0db",
"updated": "20230219092941"
"updated": "20230324110737"
},
"Children": [
{
@ -423,6 +341,161 @@
}
]
},
{
"ID": "20230219092911-wh5sgd8",
"Type": "NodeHeading",
"HeadingLevel": 3,
"Properties": {
"id": "20230219092911-wh5sgd8",
"updated": "20230219092911"
},
"Children": [
{
"Type": "NodeText",
"Data": "基於卡包"
}
]
},
{
"ID": "20230219092911-ol65uqs",
"Type": "NodeParagraph",
"Properties": {
"id": "20230219092911-ol65uqs",
"updated": "20230219092911"
},
"Children": [
{
"Type": "NodeText",
"Data": "基於卡包的使用方式可以將不同文檔中的內容塊制卡後放到統一的卡包中復習。"
}
]
},
{
"ID": "20230219092911-u7jucj7",
"Type": "NodeList",
"ListData": {},
"Properties": {
"id": "20230219092911-u7jucj7",
"updated": "20230219092928"
},
"Children": [
{
"ID": "20230219092911-s4dh6g1",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20230219092911-s4dh6g1",
"updated": "20230219092922"
},
"Children": [
{
"ID": "20230219092911-9cn6n81",
"Type": "NodeParagraph",
"Properties": {
"id": "20230219092911-9cn6n81",
"updated": "20230219092922"
},
"Children": [
{
"Type": "NodeText",
"Data": "在塊標菜單中選擇 "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "添加到卡包..."
},
{
"Type": "NodeText",
"Data": "​​,然後將該內容塊添加到一個卡包中完成製卡"
}
]
}
]
},
{
"ID": "20230219092911-lxrxhy6",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20230219092911-lxrxhy6",
"updated": "20230219092928"
},
"Children": [
{
"ID": "20230219092911-05ghbty",
"Type": "NodeParagraph",
"Properties": {
"id": "20230219092911-05ghbty",
"updated": "20230219092928"
},
"Children": [
{
"Type": "NodeText",
"Data": "通過點擊頂欄菜單中的 "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "閃卡"
},
{
"Type": "NodeText",
"Data": " 進入複習"
}
]
}
]
}
]
},
{
"ID": "20230324110844-nhwgtq3",
"Type": "NodeParagraph",
"Properties": {
"id": "20230324110844-nhwgtq3",
"updated": "20230324110901"
},
"Children": [
{
"Type": "NodeText",
"Data": "該使用方式默認關閉,如果需要可以在 "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "設置"
},
{
"Type": "NodeText",
"Data": " - "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "閃卡"
},
{
"Type": "NodeText",
"Data": " - "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "卡包"
},
{
"Type": "NodeText",
"Data": " 中開啟。但建議不要基於卡包使用閃卡,因為卡包是固定的,沒有基於文檔使用閃卡靈活。"
}
]
},
{
"ID": "20221223221502-cqcjal6",
"Type": "NodeHeading",

View file

@ -64,13 +64,14 @@ func GetNotebookFlashcards(boxID string, page int) (blocks []*Block, total, page
rootIDs = append(rootIDs, strings.TrimSuffix(entry.Name(), ".sy"))
}
treeBlockIDs := map[string]bool{}
var treeBlockIDs []string
for _, rootID := range rootIDs {
blockIDs := getTreeSubTreeChildBlocks(rootID)
for blockID, _ := range blockIDs {
treeBlockIDs[blockID] = true
for _, blockID := range blockIDs {
treeBlockIDs = append(treeBlockIDs, blockID)
}
}
treeBlockIDs = gulu.Str.RemoveDuplicatedElem(treeBlockIDs)
deck := Decks[builtinDeckID]
if nil == deck {
@ -80,7 +81,7 @@ func GetNotebookFlashcards(boxID string, page int) (blocks []*Block, total, page
var allBlockIDs []string
deckBlockIDs := deck.GetBlockIDs()
for _, blockID := range deckBlockIDs {
if treeBlockIDs[blockID] {
if gulu.Str.Contains(blockID, treeBlockIDs) {
allBlockIDs = append(allBlockIDs, blockID)
}
}
@ -102,7 +103,7 @@ func GetTreeFlashcards(rootID string, page int) (blocks []*Block, total, pageCou
deckBlockIDs := deck.GetBlockIDs()
treeBlockIDs := getTreeSubTreeChildBlocks(rootID)
for _, blockID := range deckBlockIDs {
if treeBlockIDs[blockID] {
if gulu.Str.Contains(blockID, treeBlockIDs) {
allBlockIDs = append(allBlockIDs, blockID)
}
}
@ -302,13 +303,14 @@ func GetNotebookDueFlashcards(boxID string, reviewedCardIDs []string) (ret []*Fl
rootIDs = append(rootIDs, strings.TrimSuffix(entry.Name(), ".sy"))
}
treeBlockIDs := map[string]bool{}
var treeBlockIDs []string
for _, rootID := range rootIDs {
blockIDs := getTreeSubTreeChildBlocks(rootID)
for blockID, _ := range blockIDs {
treeBlockIDs[blockID] = true
for _, blockID := range blockIDs {
treeBlockIDs = append(treeBlockIDs, blockID)
}
}
treeBlockIDs = gulu.Str.RemoveDuplicatedElem(treeBlockIDs)
deck := Decks[builtinDeckID]
if nil == deck {
@ -316,14 +318,10 @@ func GetNotebookDueFlashcards(boxID string, reviewedCardIDs []string) (ret []*Fl
return
}
cards := getDeckDueCards(deck, reviewedCardIDs)
cards := getDeckDueCards(deck, reviewedCardIDs, treeBlockIDs)
now := time.Now()
for _, card := range cards {
blockID := card.BlockID()
if !treeBlockIDs[blockID] {
continue
}
ret = append(ret, newFlashcard(card, blockID, builtinDeckID, now))
}
if 1 > len(ret) {
@ -347,14 +345,10 @@ func GetTreeDueFlashcards(rootID string, reviewedCardIDs []string) (ret []*Flash
}
treeBlockIDs := getTreeSubTreeChildBlocks(rootID)
cards := getDeckDueCards(deck, reviewedCardIDs)
cards := getDeckDueCards(deck, reviewedCardIDs, treeBlockIDs)
now := time.Now()
for _, card := range cards {
blockID := card.BlockID()
if !treeBlockIDs[blockID] {
continue
}
ret = append(ret, newFlashcard(card, blockID, builtinDeckID, now))
}
if 1 > len(ret) {
@ -363,9 +357,7 @@ func GetTreeDueFlashcards(rootID string, reviewedCardIDs []string) (ret []*Flash
return
}
func getTreeSubTreeChildBlocks(rootID string) (treeBlockIDs map[string]bool) {
treeBlockIDs = map[string]bool{}
func getTreeSubTreeChildBlocks(rootID string) (treeBlockIDs []string) {
tree, err := loadTreeByBlockID(rootID)
if nil != err {
return
@ -394,7 +386,7 @@ func getTreeSubTreeChildBlocks(rootID string) (treeBlockIDs map[string]bool) {
return ast.WalkContinue
}
treeBlockIDs[n.ID] = true
treeBlockIDs = append(treeBlockIDs, n.ID)
return ast.WalkContinue
})
}
@ -426,7 +418,7 @@ func getDueFlashcards(deckID string, reviewedCardIDs []string) (ret []*Flashcard
return
}
cards := getDeckDueCards(deck, reviewedCardIDs)
cards := getDeckDueCards(deck, reviewedCardIDs, nil)
now := time.Now()
for _, card := range cards {
blockID := card.BlockID()
@ -446,7 +438,7 @@ func getDueFlashcards(deckID string, reviewedCardIDs []string) (ret []*Flashcard
func getAllDueFlashcards(reviewedCardIDs []string) (ret []*Flashcard) {
now := time.Now()
for _, deck := range Decks {
cards := getDeckDueCards(deck, reviewedCardIDs)
cards := getDeckDueCards(deck, reviewedCardIDs, nil)
for _, card := range cards {
blockID := card.BlockID()
if nil == treenode.GetBlockTree(blockID) {
@ -895,7 +887,7 @@ func getDeckIDs() (deckIDs []string) {
return
}
func getDeckDueCards(deck *riff.Deck, reviewedCardIDs []string) (ret []riff.Card) {
func getDeckDueCards(deck *riff.Deck, reviewedCardIDs, blockIDs []string) (ret []riff.Card) {
ret = []riff.Card{}
dues := deck.Dues()
@ -906,6 +898,10 @@ func getDeckDueCards(deck *riff.Deck, reviewedCardIDs []string) (ret []riff.Card
continue
}
if 0 < len(blockIDs) && !gulu.Str.Contains(c.BlockID(), blockIDs) {
continue
}
fsrsCard := c.Impl().(*fsrs.Card)
if fsrs.New == fsrsCard.State {
newCount++