Skip to content

Commit

Permalink
Добавил кэширование фоток в заметке
Browse files Browse the repository at this point in the history
  • Loading branch information
YarikMix committed May 16, 2024
1 parent 9a7d7d0 commit 3ee6cb0
Showing 1 changed file with 17 additions and 34 deletions.
51 changes: 17 additions & 34 deletions public/src/components/Editor/Plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1073,44 +1073,27 @@ const RenderSubNote = (subNoteId:string) => {

let loaded = false

// if (subNoteId in AppNoteStore.state.cache) {
// subNoteTitle.innerHTML = AppNoteStore.state.cache[subNoteId]
// loaded = true
// } else {
// AppNoteRequests.Get(subNoteId, AppUserStore.state.JWT).then(result => {
// if (result.data.title == null) {
// subNoteTitle.innerHTML = 'Подзаметка'
// }
//
// //subNoteWrapper.dataset.title = parseNoteTitle(result.data.title)
// subNoteTitle.innerHTML = parseNoteTitle(result.data.title)
//
// AppDispatcher.dispatch(NoteStoreActions.PUT_TO_CACHE, {key: subNoteId, value: parseNoteTitle(result.data.title)})
//
// loaded = true
//
// }).catch((e) => {
// subNoteTitle.innerHTML = "Заметка не найдена"
// subNoteWrapper.dataset.deleted = "true"
// });
// }

AppNoteRequests.Get(subNoteId, AppUserStore.state.JWT).then(result => {
if (result.data.title == null) {
subNoteTitle.innerHTML = 'Подзаметка'
}
if (subNoteId in AppNoteStore.state.cache) {
subNoteTitle.innerHTML = AppNoteStore.state.cache[subNoteId]
loaded = true
} else {
AppNoteRequests.Get(subNoteId, AppUserStore.state.JWT).then(result => {
if (result.data.title == null) {
subNoteTitle.innerHTML = 'Подзаметка'
}

//subNoteWrapper.dataset.title = parseNoteTitle(result.data.title)
subNoteTitle.innerHTML = parseNoteTitle(result.data.title)
//subNoteWrapper.dataset.title = parseNoteTitle(result.data.title)
subNoteTitle.innerHTML = parseNoteTitle(result.data.title)

AppDispatcher.dispatch(NoteStoreActions.PUT_TO_CACHE, {key: subNoteId, value: parseNoteTitle(result.data.title)})
AppDispatcher.dispatch(NoteStoreActions.PUT_TO_CACHE, {key: subNoteId, value: parseNoteTitle(result.data.title)})

loaded = true
loaded = true

}).catch((e) => {
subNoteTitle.innerHTML = "Заметка не найдена"
subNoteWrapper.dataset.deleted = "true"
});
}).catch((e) => {
subNoteTitle.innerHTML = "Заметка не найдена"
subNoteWrapper.dataset.deleted = "true"
});
}

subNoteWrapper.onclick = () => {
if (!subNoteWrapper.dataset.deleted && loaded) {
Expand Down

0 comments on commit 3ee6cb0

Please sign in to comment.