Stream: Update notes when edited (with web socket) (#2483)

* note edit websocket

* fix note update input
This commit is contained in:
Yuri Kuznetsov
2022-10-28 11:39:56 +03:00
committed by GitHub
parent 09d8bc5a36
commit 4c209aaa86
3 changed files with 27 additions and 12 deletions

View File

@@ -56,10 +56,6 @@ class WebSocketSubmit
return;
}
if (!$entity->isNew()) {
return;
}
$parentId = $entity->get('parentId');
$parentType = $entity->get('parentType');
@@ -75,6 +71,10 @@ class WebSocketSubmit
'createdById' => $entity->get('createdById'),
];
if (!$entity->isNew()) {
$data->noteId = $entity->getId();
}
$topic = "streamUpdate.{$parentType}.{$parentId}";
$this->webSocketSubmission->submit($topic, null, $data);

View File

@@ -170,6 +170,19 @@ class Note extends Record
}
}
public function filterUpdateInput(stdClass $data): void
{
parent::filterUpdateInput($data);
unset($data->parentId);
unset($data->parentType);
unset($data->targetType);
unset($data->usersIds);
unset($data->teamsIds);
unset($data->portalsIds);
unset($data->isGlobal);
}
/**
* @param NoteEntity $entity
* @param stdClass $data
@@ -186,14 +199,6 @@ class Note extends Record
if (!$entity->isPost() && !$this->user->isAdmin()) {
throw new ForbiddenSilent("Only 'Post' type allowed.");
}
$entity->clear('parentId');
$entity->clear('parentType');
$entity->clear('targetType');
$entity->clear('usersIds');
$entity->clear('teamsIds');
$entity->clear('portalsIds');
$entity->clear('isGlobal');
}
protected function handlePostText(NoteEntity $entity): void

View File

@@ -298,6 +298,16 @@ define('views/stream/panel', ['views/record/panels/relationship', 'lib!Textcompl
return;
}
if (data.noteId) {
let model = this.collection.get(data.noteId);
if (model) {
model.fetch();
}
return;
}
this.collection.fetchNew();
});
},