From b09b620f7a413ee427ac7a910251fae0da29355b Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Thu, 16 May 2024 00:04:20 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=B2=20=D0=B2=D0=B5=D0=B1=D1=81=D0=BE=D0=BA=D0=B5=D1=82=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D1=83=20=D0=BD=D0=B0?= =?UTF-8?q?=20socket=5Fid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/TagsFilter/TagsFilter.sass | 2 ++ public/src/modules/stores/NotesStore.ts | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/public/src/components/TagsFilter/TagsFilter.sass b/public/src/components/TagsFilter/TagsFilter.sass index d5398fe1..e18a8984 100644 --- a/public/src/components/TagsFilter/TagsFilter.sass +++ b/public/src/components/TagsFilter/TagsFilter.sass @@ -51,12 +51,14 @@ z-index: 1000 width: 130px display: none + animation: closeAnim 0.3s border: 1px solid hsl(217.2 32.6% 25%) border-radius: 12px overflow: hidden &.open display: flex + animation: showAnim 0.3s &__option width: 100% diff --git a/public/src/modules/stores/NotesStore.ts b/public/src/modules/stores/NotesStore.ts index 6050c740..7108a117 100644 --- a/public/src/modules/stores/NotesStore.ts +++ b/public/src/modules/stores/NotesStore.ts @@ -38,6 +38,7 @@ class NotesStore extends BaseStore { }; private ws + private socket_id constructor() { super(); @@ -226,6 +227,7 @@ class NotesStore extends BaseStore { this.ws.close() this.ws = null + this.socket_id = null } } @@ -266,7 +268,13 @@ class NotesStore extends BaseStore { // TODO: синхронизация между девайсами (сверять id девайса / вебсокета) // А нужна ли вообще проверка ? // Нужна, иначе курсор скачет // С кем ты разговариваешь? - if (data.username == AppUserStore.state.username) { + console.log("onMessage") + console.log(data) + console.log(data.socket_id) + console.log(this.socket_id) + console.log(data.socket_id == this.socket_id) + if (data.socket_id == this.socket_id) { + console.log("return") return } @@ -284,6 +292,8 @@ class NotesStore extends BaseStore { })) } + } else if (data.type == "info") { + this.socket_id = data.socket_id } else if (data.type == "closed") { const collaborator = { id: data.user_id, @@ -419,6 +429,12 @@ class NotesStore extends BaseStore { AppDispatcher.dispatch(UserActions.UPDATE_CSRF, csrf); + this.ws.sendMessage(JSON.stringify({ + type: "edit", + data: data, + socket_id: this.socket_id + })) + } catch { AppToasts.error('Что-то пошло не так'); }