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 e828e48 commit 9a7d7d0
Showing 1 changed file with 34 additions and 18 deletions.
52 changes: 34 additions & 18 deletions public/src/components/Editor/Plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1073,28 +1073,44 @@ 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)
// 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 = 'Подзаметка'
}

AppDispatcher.dispatch(NoteStoreActions.PUT_TO_CACHE, {key: subNoteId, value: parseNoteTitle(result.data.title)})
//subNoteWrapper.dataset.title = parseNoteTitle(result.data.title)
subNoteTitle.innerHTML = parseNoteTitle(result.data.title)

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

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

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

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

0 comments on commit 9a7d7d0

Please sign in to comment.