Skip to content

Commit

Permalink
Исправил баг с шерингом заметки
Browse files Browse the repository at this point in the history
  • Loading branch information
YarikMix committed May 19, 2024
1 parent 4974728 commit b94a5f7
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 47 deletions.
34 changes: 23 additions & 11 deletions public/src/components/NoteEditor/NoteEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,20 @@ export class NoteEditor extends ScReact.Component<NoteEditorProps, NoteEditorTyp
const isSubNote = this.state.selectedNote?.parent != "00000000-0000-0000-0000-000000000000" ? "hidden" : ""
const isOwner = this.state.selectedNote?.owner_id == AppUserStore.state.user_id

// TODO: скелетон для эдитора
// console.log("render")
// console.log(this.state.selectedNote)
//
// if (!this.state.selectedNote) {
// return (
// <div>
//
// </div>
// )
// }
//
// console.log("123")

return (
<div className={'note-editor-wrapper ' + (this.props.open ? ' active ' : '') + (this.state.fullScreen ? ' fullscreen ' : '') }>

Expand Down Expand Up @@ -393,17 +407,15 @@ export class NoteEditor extends ScReact.Component<NoteEditorProps, NoteEditorTyp
/>
</div>

{isOwner ?
<NoteMenu
note={this.state.selectedNote}
deleteNote={this.openDeleteNoteModal}
inviteUser={this.openInviteUserModal}
openTagList={this.openTagsModal}
openEmojiList={this.openEmojiModal}
openBackgroundList={this.openBackgroundModal}
openSharePanel={this.openShareModal}
/> : ""
}
<NoteMenu
note={this.state.selectedNote}
deleteNote={this.openDeleteNoteModal}
openTagList={this.openTagsModal}
openEmojiList={this.openEmojiModal}
openBackgroundList={this.openBackgroundModal}
openSharePanel={this.openShareModal}
/>


{!this.state.fullScreen ?
<Tooltip
Expand Down
76 changes: 47 additions & 29 deletions public/src/components/NoteMenu/NoteMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {Img} from "../Image/Image";
import {AppNotesStore, NotesActions} from "../../modules/stores/NotesStore";
import {isSubNote} from "../../modules/utils";
import {AppDispatcher} from "../../modules/dispatcher";
import {AppUserStore} from "../../modules/stores/UserStore";

export class NoteMenu extends ScReact.Component<any, any> {
state = {
Expand Down Expand Up @@ -39,11 +40,6 @@ export class NoteMenu extends ScReact.Component<any, any> {
this.props.deleteNote()
}

inviteUser = () => {
this.toggleMenu()
this.props.inviteUser()
}

tagList = () => {
this.toggleMenu()
this.props.openTagList()
Expand Down Expand Up @@ -77,6 +73,8 @@ export class NoteMenu extends ScReact.Component<any, any> {
}

render() {
const isOwner = this.props.note?.owner_id == AppUserStore.state.user_id

return (
<div className={"note-menu " + (this.state.open ? "open" : "")}>
<div className="dots-wrapper" onclick={this.toggleMenu} ref={ref => this.dotsRef = ref}>
Expand All @@ -85,10 +83,14 @@ export class NoteMenu extends ScReact.Component<any, any> {
</div>
</div>
<div className="options" ref={ref => this.noteMenuRef = ref}>
<div className="options-item" onclick={this.sharePanel}>
<Img src="link.svg" className="icon"/>
<span>Поделиться</span>
</div>

{isOwner ?
<div className="options-item" onClick={this.sharePanel}>
<Img src="link.svg" className="icon"/>
<span>Поделиться</span>
</div> : ""
}

<div className="options-item" onclick={this.exportToPdf}>
<Img src="pdf.svg" className="icon"/>
<span>Скачать в pdf</span>
Expand All @@ -97,26 +99,42 @@ export class NoteMenu extends ScReact.Component<any, any> {
<Img src="zip.svg" className="icon"/>
<span>Скачать в zip</span>
</div>
<div className="options-item mobile-option">
<Img src={this.props.note.favorite ? "star-filled.svg" : "star.svg"} className="icon"/>
<span>{this.props.note.favorite ? "Удалить из избранного" : "В избранное"}</span>
</div>
<div className="options-item mobile-option" onclick={this.tagList}>
<Img src="tag.svg" className="icon"/>
<span>Изменить тэги</span>
</div>
<div className="options-item mobile-option" onclick={this.emojiList}>
<Img src="emoji.svg" className="icon"/>
<span>Изменить иконку</span>
</div>
<div className="options-item mobile-option" onclick={this.backgroundList}>
<Img src="image.svg" className="icon"/>
<span>Изменить шапку</span>
</div>
<div className="options-item" onclick={this.deleteNote}>
<Img src="trash.svg" className="icon"/>
<span>Удалить заметку</span>
</div>

{isOwner ?
<div className="options-item mobile-option">
<Img src={this.props.note?.favorite ? "star-filled.svg" : "star.svg"} className="icon"/>
<span>{this.props.note?.favorite ? "Удалить из избранного" : "В избранное"}</span>
</div> : ""
}

{isOwner ?
<div className="options-item mobile-option" onClick={this.tagList}>
<Img src="tag.svg" className="icon"/>
<span>Изменить тэги</span>
</div> : ""
}

{isOwner ?
<div className="options-item mobile-option" onClick={this.emojiList}>
<Img src="emoji.svg" className="icon"/>
<span>Изменить иконку</span>
</div> : ""
}

{isOwner ?
<div className="options-item mobile-option" onclick={this.backgroundList}>
<Img src="image.svg" className="icon"/>
<span>Изменить шапку</span>
</div> : ""
}

{isOwner ?
<div className="options-item" onClick={this.deleteNote}>
<Img src="trash.svg" className="icon"/>
<span>Удалить заметку</span>
</div> : ""
}

</div>
</div>
)
Expand Down
12 changes: 6 additions & 6 deletions public/src/components/SharePanel/SharePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ export class SharePanel extends ScReact.Component<any, any> {
}

shareToVK = () => {
const url = "https://vk.com/share.php?url=" + window.location.href + "&title=" + parseNoteTitle(AppNotesStore.state.selectedNote.title)
const url = "https://vk.com/share.php?url=" + this.getNoteURL()+ "&title=" + parseNoteTitle(this.props.note.title)
this.openShareWindow(url)
}

shareToOK= () => {
const url = "https://connect.ok.ru/offer?url=" + window.location.href + "&title=" + parseNoteTitle(AppNotesStore.state.selectedNote.title)
const url = "https://connect.ok.ru/offer?url=" + this.getNoteURL() + "&title=" + parseNoteTitle(this.props.note.title)
this.openShareWindow(url)
}

shareToWhatsApp = () => {
const url = "https://wa.me/?text=" + window.location.href
const url = "https://wa.me/?text=" + this.getNoteURL()
this.openShareWindow(url)
}

Expand All @@ -43,9 +43,9 @@ export class SharePanel extends ScReact.Component<any, any> {
AppToasts.info("Ссылка на заметку скопирована")
}

render() {
const noteUrl = baseUrl + "/notes/" + this.props.note?.id
getNoteURL = () => baseUrl + "/notes/" + this.props.note?.id

render() {
return (
<div className="share_panel">
<div className="share_panel__invite-people-container">
Expand All @@ -61,7 +61,7 @@ export class SharePanel extends ScReact.Component<any, any> {
<span>Просматривать могут все, у кого есть ссылка</span>
<ToggleButton value={this.props.note?.public} onToggle={this.handleToggle}/>
</div>
<input type="text" disabled className="share_panel__share-link-container__input" value={noteUrl} />
<input type="text" disabled className="share_panel__share-link-container__input" value={this.getNoteURL()} />
<Button label="Скопировать" onClick={this.copyNoteURL} />
</div>
<div className="share_panel__social-btns-container">
Expand Down
2 changes: 1 addition & 1 deletion public/src/pages/SharedNote/style.sass
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
display: flex
justify-content: center
align-items: center
padding: 100px 10%
padding: 100px 20%

.note-editor
width: 100%
Expand Down

0 comments on commit b94a5f7

Please sign in to comment.