Skip to content

Commit

Permalink
Отключил кэширование подзаметок
Browse files Browse the repository at this point in the history
  • Loading branch information
YarikMix committed May 28, 2024
1 parent 3611099 commit 76f63ec
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 18 deletions.
37 changes: 27 additions & 10 deletions public/src/components/Editor/Plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,6 @@ export const defaultPlugins: EditorPlugin[] = [
img.dataset.imgid = id;
img.className = "img"



if (id in AppNoteStore.state.cache) {
img.src = AppNoteStore.state.cache[id]
} else {
Expand Down Expand Up @@ -1052,6 +1050,8 @@ const RenderAttach = (attach_filename:string, attach_id:string) => {
}

const RenderSubNote = (subNoteId:string) => {
console.log("RenderSubNote")

const subNoteWrapper = document.createElement("button")
subNoteWrapper.className = "subnote-wrapper"

Expand Down Expand Up @@ -1105,18 +1105,36 @@ const RenderSubNote = (subNoteId:string) => {

let loaded = false

if (subNoteId in AppNoteStore.state.cache) {
subNoteTitle.innerHTML = AppNoteStore.state.cache[subNoteId]
loaded = true
} else {

const request = pluginSettings.isEditable ? AppNoteRequests.Get(subNoteId, AppUserStore.state.JWT) : AppSharedNoteRequests.Get(subNoteId)
// if (subNoteId in AppNoteStore.state.cache) {
// subNoteTitle.innerHTML = AppNoteStore.state.cache[subNoteId]
// loaded = true
// } else {
//
// const request = pluginSettings.isEditable ? AppNoteRequests.Get(subNoteId, AppUserStore.state.JWT) : AppSharedNoteRequests.Get(subNoteId)
// request.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"
// });
// }

const request = pluginSettings.isEditable ? AppNoteRequests.Get(subNoteId, AppUserStore.state.JWT) : AppSharedNoteRequests.Get(subNoteId)
request.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)})
Expand All @@ -1127,7 +1145,6 @@ const RenderSubNote = (subNoteId:string) => {
subNoteTitle.innerHTML = "Заметка не найдена"
subNoteWrapper.dataset.deleted = "true"
});
}

subNoteWrapper.onclick = () => {
if (!subNoteWrapper.dataset.deleted && loaded) {
Expand Down
16 changes: 8 additions & 8 deletions public/src/components/NoteEditor/NoteEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -451,14 +451,14 @@ export class NoteEditor extends ScReact.Component<NoteEditorProps, NoteEditorTyp
/>
</div>

{
!isOwner ?
<Tooltip
hoverTooltip="Владелец: user91"
showHoverTooltip={true}
icon="info_circle.svg"
/> : ""
}
{/*{*/}
{/* !isOwner ?*/}
{/* <Tooltip*/}
{/* hoverTooltip="Владелец: user91"*/}
{/* showHoverTooltip={true}*/}
{/* icon="info_circle.svg"*/}
{/* /> : ""*/}
{/*}*/}

<NoteMenu
note={this.state.selectedNote}
Expand Down

0 comments on commit 76f63ec

Please sign in to comment.