Skip to content

Commit

Permalink
Fix cell focus when chat reload
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonflylee committed May 21, 2024
1 parent d121ec8 commit 4f546db
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions wiliwili/source/fragment/inbox_chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ void InboxChat::onMsgList(const bilibili::InboxMessageResultWrapper& result, boo
datasource = new DataSourceMsgList(result, this->talkerId);
recyclingGrid->setDefaultCellFocus(datasource->getItemCount() - 1);
recyclingGrid->setDataSource(datasource);
brls::sync([this]() { recyclingGrid->selectRowAt(recyclingGrid->getDefaultCellFocus(), true); });
}
});
}
Expand Down
5 changes: 4 additions & 1 deletion wiliwili/source/fragment/inbox_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ class DataSourceChatList : public RecyclingGridDataSource {

void onItemSelected(RecyclingGrid* recycler, size_t index) override {
auto& r = this->list[index];
auto* view = new InboxChat(r, [recycler]() { recycler->refresh(); });
auto* view = new InboxChat(r, [recycler, index]() {
recycler->setDefaultCellFocus(index);
recycler->refresh();
});
recycler->present(view);
}

Expand Down
2 changes: 1 addition & 1 deletion wiliwili/source/view/recycling_grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ void RecyclingGrid::reloadData() {
}

// 在前面的操作中,列表增加了一项,通过 selectRowAt 再精确地显示出具体选中项
selectRowAt(cellFocusIndex, this->isFlowMode);
selectRowAt(cellFocusIndex, false);
}

void RecyclingGrid::notifyDataChanged() {
Expand Down

0 comments on commit 4f546db

Please sign in to comment.