Skip to content

Commit

Permalink
Сделал отображение подзаметок в пошереной заметке
Browse files Browse the repository at this point in the history
  • Loading branch information
YarikMix committed May 26, 2024
1 parent 5aafc74 commit 6b60247
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
22 changes: 13 additions & 9 deletions public/src/components/Editor/Plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {AppNoteRequests, AppSharedNoteRequests} from '../../modules/api';
import {AppDispatcher} from "../../modules/dispatcher";
import {AppToasts} from "../../modules/toasts";
import {AppNoteStore, NoteStoreActions} from "../../modules/stores/NoteStore";
import {AppRouter} from '../../modules/router';

interface EditorPlugin {
pluginName: string;
Expand Down Expand Up @@ -1072,11 +1073,9 @@ const RenderSubNote = (subNoteId:string) => {
subNoteContainer.appendChild(subNoteTitle)

const isOwner= AppNotesStore.state.selectedNote?.owner_id == AppUserStore.state.user_id
const isAuth = AppUserStore.state.isAuth

console.log(1)
console.log(isOwner)
if (isOwner && pluginSettings.isEditable) {
console.log(2)
if (isAuth && isOwner && pluginSettings.isEditable) {
const deleteSubNoteBtnContainer = document.createElement("div")
deleteSubNoteBtnContainer.className = "delete-subnote-btn-container"

Expand All @@ -1085,7 +1084,6 @@ const RenderSubNote = (subNoteId:string) => {
deleteSubNoteBtn.className = "delete-subnote-btn"

if (pluginSettings.isEditable) {
console.log(3)
deleteSubNoteBtnContainer.onclick = (e) => {
e.stopPropagation()
subNoteWrapper.remove();
Expand Down Expand Up @@ -1132,13 +1130,19 @@ const RenderSubNote = (subNoteId:string) => {
});
}

if (pluginSettings.isEditable) {
subNoteWrapper.onclick = () => {
if (!subNoteWrapper.dataset.deleted && loaded) {
subNoteWrapper.onclick = () => {
if (!subNoteWrapper.dataset.deleted && loaded) {
if (isAuth) {
AppDispatcher.dispatch(NotesActions.OPEN_NOTE, subNoteId)
} else {
AppToasts.error("Заметка не найдена")
AppSharedNoteRequests.Get(subNoteId).then(result => {
AppRouter.openSharedNotePage(result)
}).catch((e) => {
AppToasts.error("Заметка не найдена")
});
}
} else {
AppToasts.error("Заметка не найдена")
}
}

Expand Down
5 changes: 1 addition & 4 deletions public/src/modules/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,6 @@ export class Router extends ScReact.Component<any, routerState> {
page = this.pages['/notes'];
}

console.log("history.pushState")
console.log(path)
console.log(raw)
history.pushState(null, null, path);

if (page === undefined) {
Expand Down Expand Up @@ -182,7 +179,7 @@ export class Router extends ScReact.Component<any, routerState> {
}

public openSharedNotePage (note:NoteType) {
history.pushState(null, null, "/notes/" + note.id);
// history.pushState(null, null, "/notes/" + note.id);

this.setState(s => ({
...s,
Expand Down
8 changes: 0 additions & 8 deletions public/src/pages/SharedNote/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import {ScReact} from "@veglem/screact";
import "./style.sass"
import "../../components/Editor/Editor.sass"
import {ViewerWrapper} from "../../components/ViewerWrapper/ViewerWrapper";
import {AppNotesStore} from "../../modules/stores/NotesStore";
import {NoteStoreActions} from "../../modules/stores/NoteStore";

export class SharedNotePage extends ScReact.Component<any, any> {
state = {
Expand All @@ -15,19 +13,13 @@ export class SharedNotePage extends ScReact.Component<any, any> {
...state,
fullScreen: true
}))
document.getElementById("header").classList.add("fullscreen")
}

closeFullScreen = () => {
this.setState(state => ({
...state,
fullScreen: false
}))
document.getElementById("header").classList.remove("fullscreen")
}

componentWillUnmount() {
console.log("asdfasdfas")
}

render () {
Expand Down

0 comments on commit 6b60247

Please sign in to comment.