mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 04:58:49 +03:00
parent
21fdb26bd4
commit
937caddacd
4 changed files with 23 additions and 30 deletions
|
@ -44,11 +44,12 @@ public:
|
||||||
|
|
||||||
void setInitialRooms(const QMap<QString, QSharedPointer<RoomSettings>> &settings,
|
void setInitialRooms(const QMap<QString, QSharedPointer<RoomSettings>> &settings,
|
||||||
const QMap<QString, RoomState> &states);
|
const QMap<QString, RoomState> &states);
|
||||||
void sync(const QMap<QString, RoomState> &states);
|
void sync(const QMap<QString, RoomState> &states,
|
||||||
|
QMap<QString, QSharedPointer<RoomSettings>> &settings);
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
void addRoom(const QSharedPointer<RoomSettings> &settings,
|
void addRoom(const QMap<QString, QSharedPointer<RoomSettings>> &settings,
|
||||||
const RoomState &state,
|
const RoomState &state,
|
||||||
const QString &room_id);
|
const QString &room_id);
|
||||||
void removeRoom(const QString &room_id, bool reset);
|
void removeRoom(const QString &room_id, bool reset);
|
||||||
|
|
|
@ -362,7 +362,7 @@ ChatPage::syncCompleted(const SyncResponse &response)
|
||||||
auto stateDiff = generateMembershipDifference(response.rooms().join(), state_manager_);
|
auto stateDiff = generateMembershipDifference(response.rooms().join(), state_manager_);
|
||||||
QtConcurrent::run(cache_.data(), &Cache::setState, response.nextBatch(), stateDiff);
|
QtConcurrent::run(cache_.data(), &Cache::setState, response.nextBatch(), stateDiff);
|
||||||
|
|
||||||
room_list_->sync(state_manager_);
|
room_list_->sync(state_manager_, settingsManager_);
|
||||||
view_manager_->sync(response.rooms());
|
view_manager_->sync(response.rooms());
|
||||||
|
|
||||||
client_->setNextBatchToken(response.nextBatch());
|
client_->setNextBatchToken(response.nextBatch());
|
||||||
|
@ -570,7 +570,7 @@ ChatPage::addRoom(const QString &room_id)
|
||||||
settingsManager_.insert(room_id,
|
settingsManager_.insert(room_id,
|
||||||
QSharedPointer<RoomSettings>(new RoomSettings(room_id)));
|
QSharedPointer<RoomSettings>(new RoomSettings(room_id)));
|
||||||
|
|
||||||
room_list_->addRoom(settingsManager_[room_id], state_manager_[room_id], room_id);
|
room_list_->addRoom(settingsManager_, state_manager_[room_id], room_id);
|
||||||
room_list_->highlightSelectedRoom(room_id);
|
room_list_->highlightSelectedRoom(room_id);
|
||||||
|
|
||||||
changeTopRoomInfo(room_id);
|
changeTopRoomInfo(room_id);
|
||||||
|
@ -710,7 +710,6 @@ ChatPage::updateJoinedRooms(const QMap<QString, JoinedRoom> &rooms)
|
||||||
|
|
||||||
state_manager_.insert(it.key(), room_state);
|
state_manager_.insert(it.key(), room_state);
|
||||||
|
|
||||||
// TODO Doesn't work on the sidebar.
|
|
||||||
settingsManager_.insert(
|
settingsManager_.insert(
|
||||||
it.key(), QSharedPointer<RoomSettings>(new RoomSettings(it.key())));
|
it.key(), QSharedPointer<RoomSettings>(new RoomSettings(it.key())));
|
||||||
|
|
||||||
|
|
|
@ -72,19 +72,22 @@ RoomList::clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
RoomList::addRoom(const QSharedPointer<RoomSettings> &settings,
|
RoomList::addRoom(const QMap<QString, QSharedPointer<RoomSettings>> &settings,
|
||||||
const RoomState &state,
|
const RoomState &state,
|
||||||
const QString &room_id)
|
const QString &room_id)
|
||||||
{
|
{
|
||||||
RoomInfoListItem *room_item = new RoomInfoListItem(settings, state, room_id, scrollArea_);
|
RoomInfoListItem *room_item =
|
||||||
|
new RoomInfoListItem(settings[room_id], state, room_id, scrollArea_);
|
||||||
connect(room_item, &RoomInfoListItem::clicked, this, &RoomList::highlightSelectedRoom);
|
connect(room_item, &RoomInfoListItem::clicked, this, &RoomList::highlightSelectedRoom);
|
||||||
connect(room_item, &RoomInfoListItem::leaveRoom, this, &RoomList::openLeaveRoomDialog);
|
connect(room_item, &RoomInfoListItem::leaveRoom, this, &RoomList::openLeaveRoomDialog);
|
||||||
|
|
||||||
rooms_.insert(room_id, QSharedPointer<RoomInfoListItem>(room_item));
|
rooms_.insert(room_id, QSharedPointer<RoomInfoListItem>(room_item));
|
||||||
|
|
||||||
client_->fetchRoomAvatar(room_id, state.getAvatar());
|
if (!state.getAvatar().toString().isEmpty())
|
||||||
|
client_->fetchRoomAvatar(room_id, state.getAvatar());
|
||||||
|
|
||||||
contentsLayout_->insertWidget(0, room_item);
|
int pos = contentsLayout_->count() - 1;
|
||||||
|
contentsLayout_->insertWidget(pos, room_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -138,23 +141,10 @@ RoomList::setInitialRooms(const QMap<QString, QSharedPointer<RoomSettings>> &set
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto it = states.constBegin(); it != states.constEnd(); ++it) {
|
for (auto it = states.constBegin(); it != states.constEnd(); ++it) {
|
||||||
auto room_id = it.key();
|
const auto room_id = it.key();
|
||||||
auto state = it.value();
|
const auto state = it.value();
|
||||||
|
|
||||||
if (!state.getAvatar().toString().isEmpty())
|
addRoom(settings, state, room_id);
|
||||||
client_->fetchRoomAvatar(room_id, state.getAvatar());
|
|
||||||
|
|
||||||
RoomInfoListItem *room_item =
|
|
||||||
new RoomInfoListItem(settings[room_id], state, room_id, scrollArea_);
|
|
||||||
connect(
|
|
||||||
room_item, &RoomInfoListItem::clicked, this, &RoomList::highlightSelectedRoom);
|
|
||||||
connect(
|
|
||||||
room_item, &RoomInfoListItem::leaveRoom, this, &RoomList::openLeaveRoomDialog);
|
|
||||||
|
|
||||||
rooms_.insert(room_id, QSharedPointer<RoomInfoListItem>(room_item));
|
|
||||||
|
|
||||||
int pos = contentsLayout_->count() - 1;
|
|
||||||
contentsLayout_->insertWidget(pos, room_item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rooms_.isEmpty())
|
if (rooms_.isEmpty())
|
||||||
|
@ -189,15 +179,18 @@ RoomList::openLeaveRoomDialog(const QString &room_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
RoomList::sync(const QMap<QString, RoomState> &states)
|
RoomList::sync(const QMap<QString, RoomState> &states,
|
||||||
|
QMap<QString, QSharedPointer<RoomSettings>> &settings)
|
||||||
|
|
||||||
{
|
{
|
||||||
for (auto it = states.constBegin(); it != states.constEnd(); ++it) {
|
for (auto it = states.constBegin(); it != states.constEnd(); ++it) {
|
||||||
auto room_id = it.key();
|
auto room_id = it.key();
|
||||||
auto state = it.value();
|
auto state = it.value();
|
||||||
|
|
||||||
if (!rooms_.contains(room_id)) {
|
if (!rooms_.contains(room_id)) {
|
||||||
addRoom(
|
settings.insert(room_id,
|
||||||
QSharedPointer<RoomSettings>(new RoomSettings(room_id)), state, room_id);
|
QSharedPointer<RoomSettings>(new RoomSettings(room_id)));
|
||||||
|
addRoom(settings, state, room_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto room = rooms_[room_id];
|
auto room = rooms_[room_id];
|
||||||
|
|
|
@ -133,8 +133,8 @@ FilteredTextEdit::minimumSizeHint() const
|
||||||
void
|
void
|
||||||
FilteredTextEdit::submit()
|
FilteredTextEdit::submit()
|
||||||
{
|
{
|
||||||
if (toPlainText().trimmed().isEmpty())
|
if (toPlainText().trimmed().isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (true_history_.size() == INPUT_HISTORY_SIZE)
|
if (true_history_.size() == INPUT_HISTORY_SIZE)
|
||||||
true_history_.pop_back();
|
true_history_.pop_back();
|
||||||
|
|
Loading…
Reference in a new issue