Page MenuHomePhorge

[Breaking] Add draftRel for room
Needs ReviewPublic

Authored by nannanko on Mar 25 2026, 9:25 AM.

Details

Reviewers
tusooa
Group Reviewers
O1: the Kazv Project
Summary

Sometimes certain events occupy the chat box, this diff makes the room remember this status as well as the old draft so that it can be restored when the time is right.

Breaking change:

  • RoomModel::localDraft is removed and applications should use RoomModel::localDrafts instead. To migrate, replace localDraft with localDrafts.at(0).text.
  • Room::localDraft() is removed and applications should use Room::localDrafts() instead. To migrate, replace localDraft() with localDraft()[0][lager::lenses::or_default][&LocalDraft::text].

Type: add

Test Plan

Verify unit tests passed.

Diff Detail

Repository
rL libkazv
Branch
nannanko/restore-draft
Lint
No Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 612
Build 1206: Invoke BuildbotBuildbot build #1708
Build 1205: arc lint + arc unit

Event Timeline

Harbormaster returned this revision to the author for changes because remote builds failed.Mar 25 2026, 9:37 AM
Harbormaster failed remote builds in B582: Diff 898!
nannanko edited the summary of this revision. (Show Details)

buildbot is broken

tusooa requested changes to this revision.Mar 27 2026, 9:41 AM
tusooa added inline comments.
src/client/room/room-model.hpp
284–287

I think it will be good to put this into its own type:

struct LocalDraft
{
    std::string text;
    std::string relType;
    std::string relatedEventId;
};

Then, instead of using a simple string of oldDraft, we can store all draft versions in a immer::flex_vector<LocalDraft>.

When the user clicks Reply or Edit, push a LocalDraft into the vector. When the user clicks Close and confirms, pop the last object from the vector. The current draft can be obtained by the last element from the vector (or a default-initialized LocalDraft when the vector is empty).

SaveLocalDraftAction will be changed to only modify the current draft.

This revision now requires changes to proceed.Mar 27 2026, 9:41 AM

Use Kazv::LocalDraft instead of three std::string.

nannanko marked an inline comment as done.

Add more action to edit localDraft

src/client/room/local-draft.hpp
32–33

you also don't need namespace boost::serialization because you can just modify the Kazv namespace

35–59

split_free is not needed because save and load functions are exactly same

62

you can start this with 0

src/client/room/room-model.hpp
483–542

This will cause problems with loading from an archive of earlier versions. The std::string (of the old localDraft) must still be read out from the archive if it is a version less than 10.

Compatible with older version sessions file.

tusooa requested changes to this revision.Sat, Apr 18, 7:22 PM
tusooa added inline comments.
src/client/room/room-model.cpp
279–315

need tests

src/client/room/room-model.hpp
284–286

unneeded

486–488
489–491
src/client/room/room.hpp
412–413

this is not source-compatible

This revision now requires changes to proceed.Sat, Apr 18, 7:22 PM

Add test, fix source incompatible, comments, remove unneeded RoomModel::oldVerLocalDraft.

tusooa requested changes to this revision.Sat, Apr 25, 6:55 PM
tusooa added inline comments.
src/client/room/room.cpp
324–358

missing tests

This revision now requires changes to proceed.Sat, Apr 25, 6:55 PM
tusooa retitled this revision from Add draftRel for room to [Breaking] Add draftRel for room.Fri, May 1, 1:35 PM
tusooa edited the summary of this revision. (Show Details)