Skip to content

Commit

Permalink
Добавил в вебсокет проверку на socket_id
Browse files Browse the repository at this point in the history
  • Loading branch information
YarikMix committed May 15, 2024
1 parent a7bea25 commit 5cb9989
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
6 changes: 3 additions & 3 deletions public/src/modules/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ class NoteRequests {
throw new Error(response.body.message);
};

Update = async({id, note}, jwt: string, csrf:string)=> {
Update = async({id, note}, socket_id:string, jwt: string, csrf:string)=> {


const response = await Ajax.Post(this.baseUrl + '/' + id + '/edit', {
Expand All @@ -338,11 +338,11 @@ class NoteRequests {
data: {
title: note.title,
content: note.blocks
}
},
socket_id: socket_id
}
});



return {
status: response.status,
Expand Down
8 changes: 1 addition & 7 deletions public/src/modules/stores/NotesStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,16 +425,10 @@ class NotesStore extends BaseStore<NotesStoreState> {
async saveNote(data) {
try {

const {csrf} = await AppNoteRequests.Update(data, AppUserStore.state.JWT, AppUserStore.state.csrf);
const {csrf} = await AppNoteRequests.Update(data, this.socket_id, AppUserStore.state.JWT, AppUserStore.state.csrf);

AppDispatcher.dispatch(UserActions.UPDATE_CSRF, csrf);

this.ws.sendMessage(JSON.stringify({
type: "edit",
data: data.note,
socket_id: this.socket_id
}))

} catch {
AppToasts.error('Что-то пошло не так');
}
Expand Down

0 comments on commit 5cb9989

Please sign in to comment.