Skip to content

Commit

Permalink
Сделал уведомление о приглашении в заметку
Browse files Browse the repository at this point in the history
  • Loading branch information
YarikMix committed May 25, 2024
1 parent 8396660 commit a4f0cdf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 42 deletions.
52 changes: 11 additions & 41 deletions public/src/modules/stores/NotesStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,52 +95,22 @@ class NotesStore extends BaseStore<NotesStoreState> {

this.invitesWS = new WebSocketConnection(`note/subscribe/on_invites`)

this.invitesWS.onOpen(() => {
console.log("invitesWS.onOpen")
// this.editorWS.sendMessage(JSON.stringify({
// type: "opened",
// note_id: note.id,
// user_id: AppUserStore.state.user_id,
// username: AppUserStore.state.username,
// image_path: AppUserStore.state.avatarUrl
// }))
})

this.invitesWS.onMessage((event) => {
console.log("invitesWS.onMessage")

this.invitesWS.onMessage(async (event) => {
let data = JSON.parse(event.data)

console.log(data)

if (data.type == "invite") {
const owner = data.owner
AppToasts.info(owner + " пригласил вас в свою заметку!")

const note:NoteType = {
"id": data.note_id,
"data": {
"title": data.note_title.replace('"', ""),
"content": []
},
"update_time": data.created,
"owner_id": null,
"parent": "00000000-0000-0000-0000-000000000000",
"children": [],
"tags": [],
"collaborators": [],
"icon": "",
"header": "",
"favorite": false,
"public": false
}
try {
const note = await AppNoteRequests.Get(data.note_id, AppUserStore.state.JWT)

this.SetState(state => ({
...state,
// offset: state.offset + 1, ?
notes: [note, ...state.notes]
}));
AppToasts.info(data.owner + " пригласил вас в свою заметку!")

this.SetState(state => ({
...state,
notes: [note, ...state.notes]
}));
} catch {
AppToasts.error("Что-то пошло не так")
}
}
})

Expand Down
2 changes: 1 addition & 1 deletion public/src/utils/variables.sass
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ $xs: 320px
$sm: 576px
$md: 768px
$lg: 992px
$xl: 1240px
$xl: 1275px
$xxl: 1650px

0 comments on commit a4f0cdf

Please sign in to comment.