summaryrefslogtreecommitdiffhomepage
path: root/whiteboard.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2023-01-29 17:54:14 +0100
committerRoland Reichwein <mail@reichwein.it>2023-01-29 17:54:14 +0100
commitb2f3b566c0c0edd41b0314fcbf516a3d7876e14b (patch)
tree1cebf349b746ae606354733e9464581d530fb5e7 /whiteboard.cpp
parent32b5b50dacb1bfc02a0baef0eda47df8d5f2be37 (diff)
Fix concurrent edit, tests
Diffstat (limited to 'whiteboard.cpp')
-rw-r--r--whiteboard.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/whiteboard.cpp b/whiteboard.cpp
index fcfdca8..8736726 100644
--- a/whiteboard.cpp
+++ b/whiteboard.cpp
@@ -167,12 +167,14 @@ std::string Whiteboard::handle_request(Whiteboard::connection& c, const std::str
pt::ptree ptree;
ptree.put_child("diff", xml.get_child("request.diff"));
Diff d{ptree};
- std::string data {m_storage->getDocument(id)};
- data = d.apply(data);
+ if (!d.empty()) {
+ std::string data {m_storage->getDocument(id)};
+ data = d.apply(data);
- m_storage->setDocument(id, data);
- m_registry.setId(c, id);
- notify_other_connections_diff(c, id, d);
+ m_storage->setDocument(id, data);
+ m_registry.setId(c, id);
+ notify_other_connections_diff(c, id, d);
+ }
int pos {xml.get<int>("request.pos")};
if (m_storage->getCursorPos(id) != pos) {