Improvements for linking to events

- Fixes scrolling to an event not being reliable
- Adds new /goto command that can open URLs, go to events, or go to message indexes.
- Refactored ChatPage::handleMatrixUri() to contain the handling originally in Nheko::openLink(), and makes it return a boolean based on whether the URL was handled internally or not.
This commit is contained in:
Thulinma 2021-09-16 01:41:55 +02:00
parent 5bff9df4ae
commit 1d5bf56cf9
6 changed files with 101 additions and 56 deletions

View file

@ -1534,11 +1534,25 @@ void
TimelineModel::showEvent(QString eventId)
{
using namespace std::chrono_literals;
if (idToIndex(eventId) != -1) {
// Direct to eventId
if (eventId[0] == '$') {
int idx = idToIndex(eventId);
if (idx == -1) {
nhlog::ui()->warn("Scrolling to event id {}, failed - no known index",
eventId.toStdString());
return;
}
eventIdToShow = eventId;
emit scrollTargetChanged();
showEventTimer.start(50ms);
return;
}
// to message index
eventId = indexToId(eventId.toInt());
eventIdToShow = eventId;
emit scrollTargetChanged();
showEventTimer.start(50ms);
return;
}
void