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 149417e commit a8e3434
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 47 deletions.
14 changes: 7 additions & 7 deletions public/src/components/Editor/Plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1071,8 +1071,11 @@ const RenderSubNote = (subNoteId:string) => {

subNoteWrapper.appendChild(subNoteContainer)

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) {
Expand All @@ -1084,21 +1087,18 @@ const RenderSubNote = (subNoteId:string) => {

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

loaded = true

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

let loading = true

setTimeout(() => {
loading = false
}, 1000)

subNoteWrapper.onclick = () => {
if (!subNoteWrapper.dataset.deleted) {
!loading && AppDispatcher.dispatch(NotesActions.OPEN_NOTE, subNoteId)
if (!subNoteWrapper.dataset.deleted && loaded) {
AppDispatcher.dispatch(NotesActions.OPEN_NOTE, subNoteId)
} else {
AppToasts.error("Заметка не найдена")
}
Expand Down
78 changes: 39 additions & 39 deletions public/src/components/NoteEditor/NoteEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -297,46 +297,46 @@ export class NoteEditor extends ScReact.Component<NoteEditorProps, NoteEditorTyp

</div>

{this.state.noteStatus == "sync" ?
<div
className={"note-save-indicator " + (this.state.noteStatus == "sync" ? "active" : "hidden")}>
<Tooltip icon={"sync.svg"}
showHoverTooltip={true}
hoverTooltip={"Синхронизированно"}/>
</div>
:
<div
className={"note-save-indicator " + (this.state.noteStatus == "saved" ? "active" : "hidden")}>
<Tooltip icon={"check.svg"}
showHoverTooltip={true}
hoverTooltip={"Сохранено"}/>
</div>
}

{/*{this.state.noteStatus == "sync" ?*/}
{/* <div*/}
{/* className={"note-save-indicator " + (this.state.noteStatus == "sync" ? "active" : "hidden")}>*/}
{/* <Tooltip icon={"sync.svg"}*/}
{/* showHoverTooltip={true}*/}
{/* hoverTooltip={"Синхронизированно"}/>*/}
{/* </div>*/}
{/* :*/}
{/* <div*/}
{/* className={"note-save-indicator " + (this.state.noteStatus == "saved" ? "active" : "hidden")}>*/}
{/* <Tooltip icon={"check.svg"}*/}
{/* showHoverTooltip={true}*/}
{/* hoverTooltip={"Сохранено"}/>*/}
{/* </div>*/}
{/*}*/}


<div>
{
this.state.noteStatus == "saved" ?
<div className={"note-save-indicator " + (this.state.noteStatus ? "active" : "")}>
<Tooltip icon={"check.svg"}
showHoverTooltip={true}
hoverTooltip={"Сохранено"}/>
</div>
:
""
}

{/*<div>*/}
{/* {*/}
{/* this.state.noteStatus == "saved" ?*/}
{/* <div className={"note-save-indicator " + (this.state.noteStatus ? "active" : "")}>*/}
{/* <Tooltip icon={"check.svg"}*/}
{/* showHoverTooltip={true}*/}
{/* hoverTooltip={"Сохранено"}/>*/}
{/* </div>*/}
{/* :*/}
{/* ""*/}
{/* }*/}

{/* {*/}
{/* this.state.noteStatus == "sync" ?*/}
{/* <div className={"note-save-indicator " + (this.state.noteStatus ? "active" : "")}>*/}
{/* <Tooltip icon={"sync.svg"}*/}
{/* showHoverTooltip={true}*/}
{/* hoverTooltip={"Синхронизированно"}/>*/}
{/* </div>*/}
{/* :*/}
{/* ""*/}
{/* }*/}
{/*</div>*/}
{
this.state.noteStatus == "sync" ?
<div className={"note-save-indicator " + (this.state.noteStatus ? "active" : "")}>
<Tooltip icon={"sync.svg"}
showHoverTooltip={true}
hoverTooltip={"Синхронизированно"}/>
</div>
:
""
}
</div>


<div className="collaborators-container">
Expand Down
3 changes: 2 additions & 1 deletion public/src/modules/stores/NotesStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ class NotesStore extends BaseStore<NotesStoreState> {
...state,
selectedNote: note,
selectedNoteChildren: note.children,
selectedNoteCollaborators: []
selectedNoteCollaborators: [],
selectedNoteSynced: null
}));

AppDispatcher.dispatch(NoteStoreActions.SET_NOTE, {
Expand Down

0 comments on commit a8e3434

Please sign in to comment.