Changeset View
Changeset View
Standalone View
Standalone View
src/client/actions/paginate.cpp
| /* | /* | ||||
| * This file is part of libkazv. | * This file is part of libkazv. | ||||
| * SPDX-FileCopyrightText: 2020 Tusooa Zhu | * SPDX-FileCopyrightText: 2020-2026 tusooa <tusooa@kazv.moe> | ||||
| * SPDX-License-Identifier: AGPL-3.0-or-later | * SPDX-License-Identifier: AGPL-3.0-or-later | ||||
| */ | */ | ||||
| #include <libkazv-config.hpp> | #include <libkazv-config.hpp> | ||||
| // eager requires tuplify but did not include it. | // eager requires tuplify but did not include it. | ||||
| // This is a bug. | // This is a bug. | ||||
| #include <zug/tuplify.hpp> | #include <zug/tuplify.hpp> | ||||
| Show All 39 Lines | namespace Kazv | ||||
| ClientResult processResponse(ClientModel m, GetRoomEventsResponse r) | ClientResult processResponse(ClientModel m, GetRoomEventsResponse r) | ||||
| { | { | ||||
| auto roomId = r.dataStr("roomId"); | auto roomId = r.dataStr("roomId"); | ||||
| auto gapEventId = r.dataStr("gapEventId"); | auto gapEventId = r.dataStr("gapEventId"); | ||||
| if (! r.success()) { | if (! r.success()) { | ||||
| kzo.client.dbg() << "Get room events failed" << std::endl; | kzo.client.dbg() << "Get room events failed" << std::endl; | ||||
| m.addTrigger(PaginateFailed{roomId}); | |||||
| return { m, failWithResponse(r) }; | return { m, failWithResponse(r) }; | ||||
| } | } | ||||
| auto paginateBackToken = r.end(); | auto paginateBackToken = r.end(); | ||||
| auto chunk = r.chunk(); | auto chunk = r.chunk(); | ||||
| try { | try { | ||||
| // kzo.client.dbg() << "We got " << chunk.size() << " events here" << std::endl; | // kzo.client.dbg() << "We got " << chunk.size() << " events here" << std::endl; | ||||
| Show All 20 Lines | ClientResult processResponse(ClientModel m, GetRoomEventsResponse r) | ||||
| // r.state() contains state events prior to the timeline | // r.state() contains state events prior to the timeline | ||||
| // we add them later than the timeline, so the states in the | // we add them later than the timeline, so the states in the | ||||
| // timeline takes priority | // timeline takes priority | ||||
| m.roomList = RoomListModel::update( | m.roomList = RoomListModel::update( | ||||
| std::move(m.roomList), | std::move(m.roomList), | ||||
| UpdateRoomAction{roomId, MaybeAddStateEventsAction{ | UpdateRoomAction{roomId, MaybeAddStateEventsAction{ | ||||
| r.state() | r.state() | ||||
| }}); | }}); | ||||
| m.addTrigger(PaginateSuccessful{roomId}); | |||||
| return { std::move(m), lager::noop }; | return { std::move(m), lager::noop }; | ||||
| } catch (const std::out_of_range &e) { | } catch (const std::out_of_range &e) { | ||||
| // Ignore it, the client model is modified | // Ignore it, the client model is modified | ||||
| // such that it knows nothing about this room. | // such that it knows nothing about this room. | ||||
| // May happen in debugger. | // May happen in debugger. | ||||
| return { std::move(m), simpleFail }; | return { std::move(m), simpleFail }; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||