Changeset View
Changeset View
Standalone View
Standalone View
src/client/room/room-model.cpp
| Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | RoomModel RoomModel::update(RoomModel r, Action a) | ||||
| // If m.room.encryption state event appears, | // If m.room.encryption state event appears, | ||||
| // configure the room to use encryption. | // configure the room to use encryption. | ||||
| if (r.stateEvents.find(KeyOfState{"m.room.encryption", ""})) { | if (r.stateEvents.find(KeyOfState{"m.room.encryption", ""})) { | ||||
| auto newRoom = update(std::move(r), SetRoomEncryptionAction{}); | auto newRoom = update(std::move(r), SetRoomEncryptionAction{}); | ||||
| r = std::move(newRoom); | r = std::move(newRoom); | ||||
| } | } | ||||
| return r; | return r; | ||||
| }, | }, | ||||
| [&](AppendTimelineAction a) { | |||||
| auto eventIds = intoImmer(immer::flex_vector<std::string>(), | |||||
| zug::map(keyOfTimeline), a.events); | |||||
| r.timeline = r.timeline + eventIds; | |||||
| r.messages = merge(std::move(r.messages), a.events, keyOfTimeline); | |||||
| return r; | |||||
| }, | |||||
| [&](PrependTimelineAction a) { | |||||
| auto eventIds = intoImmer(immer::flex_vector<std::string>(), | |||||
| zug::map(keyOfTimeline), a.events); | |||||
| r.timeline = eventIds + r.timeline; | |||||
| r.messages = merge(std::move(r.messages), a.events, keyOfTimeline); | |||||
| r.paginateBackToken = a.paginateBackToken; | |||||
| // if there are no more events we should not allow further paginating | |||||
| r.canPaginateBack = a.events.size() != 0; | |||||
| return r; | |||||
| }, | |||||
| [&](AddToTimelineAction a) { | [&](AddToTimelineAction a) { | ||||
| auto eventIds = intoImmer(immer::flex_vector<std::string>(), | auto eventIds = intoImmer(immer::flex_vector<std::string>(), | ||||
| zug::map(keyOfTimeline), a.events); | zug::map(keyOfTimeline), a.events); | ||||
| auto oldMessages = r.messages; | auto oldMessages = r.messages; | ||||
| r.messages = merge(std::move(r.messages), a.events, keyOfTimeline); | r.messages = merge(std::move(r.messages), a.events, keyOfTimeline); | ||||
| auto exists = | auto exists = | ||||
| [=](auto eventId) -> bool { | [=](auto eventId) -> bool { | ||||
| ▲ Show 20 Lines • Show All 477 Lines • Show Last 20 Lines | |||||