MCPcopy Create free account
hub / github.com/dajie111/nodeseek-userscript / selectRestoredNote

Function selectRestoredNote

notes.js:3867–3896  ·  view source on GitHub ↗
(restoredId, previousNoteId, previousCategoryId)

Source from the content-addressed store, hash-verified

3865
3866 // 选中恢复笔记的辅助函数
3867 function selectRestoredNote(restoredId, previousNoteId, previousCategoryId) {
3868 // 首先尝试恢复之前选中的笔记
3869 if (previousNoteId && previousCategoryId) {
3870 const map = readJSON(LS_KEYS.notes, {});
3871 const list = map[previousCategoryId] || [];
3872 const noteExists = list.some(n => n.id === previousNoteId);
3873
3874 if (noteExists && previousCategoryId === targetCategoryId) {
3875 // 如果之前选中的笔记存在且在当前分类中,恢复选中它
3876 const noteItems = document.querySelectorAll('.nsn-note-item');
3877 for (let item of noteItems) {
3878 const noteData = item.noteData;
3879 if (noteData && noteData.id === previousNoteId) {
3880 item.click();
3881 return;
3882 }
3883 }
3884 }
3885 }
3886
3887 // 否则选中刚恢复的笔记
3888 const noteItems = document.querySelectorAll('.nsn-note-item');
3889 for (let item of noteItems) {
3890 const noteData = item.noteData;
3891 if (noteData && noteData.id === restoredId) {
3892 item.click();
3893 return;
3894 }
3895 }
3896 }
3897
3898 // 使用更长的延迟确保DOM完全渲染
3899 setTimeout(() => {

Callers 1

showTrashDialogFunction · 0.85

Calls 1

readJSONFunction · 0.85

Tested by

no test coverage detected