Skip to content

Commit

Permalink
Initial comment updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nvrWhere committed Nov 20, 2024
1 parent 3f5914f commit f7b965d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Quotient/events/roommessageevent.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class QUOTIENT_API RoomMessageEvent : public RoomEvent {
//! \note This will return the ID of the event if it is the thread root.
//!
//! \note If the event is the thread root event and has not been updated with the server-side
//! the function will return and empty string as we can tell if the message
//! the function will return an empty string as we can't tell if the message
//! is threaded.
//!
//! \return The event ID of the thread root if threaded, an empty string otherwise.
Expand Down
6 changes: 4 additions & 2 deletions Quotient/room.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1776,7 +1776,7 @@ void Room::Private::updateThread(const RoomEvent* event)
return;
}

if (threads.exisits(rme->threadRootEventId())) {
if (threads.exists(rme->threadRootEventId())) {
auto thread = threads.getThread(rme->threadRootEventId());
const auto threadLatestIndex = eventsIndex.constFind(thread->latestEventId());
if (threadLatestIndex == eventsIndex.cend()) {
Expand All @@ -1796,7 +1796,9 @@ void Room::Private::updateThread(const RoomEvent* event)
threads.add(std::make_unique<Thread>(rme->threadRootEventId(),
// For pending events we can get the full correct details when the remote echo comes in.
rme->id().isEmpty() ? rme->threadRootEventId() : rme->id(),
rme->id().isEmpty() ? 1 : 2,
// When we can't find the root we assume its a historical event that will load later if
// we can find it we assume a new thread was just created.
rme->id().isEmpty() || q->findInTimeline(rme->threadRootEventId()) == historyEdge() ? 1 : 2,
rme->senderId() == connection->userId()));
}
}
Expand Down
23 changes: 12 additions & 11 deletions Quotient/threadview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,38 @@

using namespace Quotient;

namespace {
inline auto checkThreadRoot(const QString& threadRootId) {
return [threadRootId](const std::unique_ptr<Thread>& thread) { return threadRootId == thread->threadRootId(); };
}
}

void ThreadView::add(std::unique_ptr<Thread> thread)
{
_threads.push_back(std::move(thread));
}

bool ThreadView::erase(const QString& threadRootId)
{
auto threadIt = std::find_if(_threads.begin(), _threads.end(), [threadRootId](const auto& thread) { return thread->threadRootId() == threadRootId; });
if (threadIt == _threads.end()) {
return false;
}
_threads.erase(threadIt);
return true;
return std::erase_if(_threads, checkThreadRoot(threadRootId)) > 0;
}

bool ThreadView::exisits(const QString& threadRootId) const
bool ThreadView::exists(const QString& threadRootId) const
{
return std::find_if(_threads.begin(), _threads.end(), [threadRootId](const auto& thread) { return thread->threadRootId() == threadRootId; }) != _threads.end();
return std::ranges::any_of(_threads, checkThreadRoot(threadRootId));
}

Thread* ThreadView::getThread(const QString& threadRootId) const
{
auto threadIt = std::find_if(_threads.begin(), _threads.end(), [threadRootId](const auto& thread) { return thread->threadRootId() == threadRootId; });
auto threadIt = std::ranges::find_if(_threads, checkThreadRoot(threadRootId));
if (threadIt == _threads.end()) {
return nullptr;
}
return threadIt->get();
}

Thread::Thread(QString threadRootId, QString latestEventId, int size, bool localUserParticipated)
: _threadRootId(threadRootId), _latestEventId(threadRootId), _size(size), _localUserParticipated(localUserParticipated)
: _threadRootId(threadRootId), _latestEventId(latestEventId), _size(size), _localUserParticipated(localUserParticipated)
{}

QString Thread::threadRootId() const
Expand Down Expand Up @@ -68,7 +69,7 @@ bool Thread::addEvent(const RoomMessageEvent* event, bool isLatest, bool isLocal
if (isLatest) {
_latestEventId = event->id();
}
_size++;
++_size;
if (!_localUserParticipated) {
_localUserParticipated = isLocalUser;
}
Expand Down
2 changes: 1 addition & 1 deletion Quotient/threadview.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class QUOTIENT_API ThreadView {

bool erase(const QString& threadRootId);

bool exisits(const QString& threadRootId) const;
bool exists(const QString& threadRootId) const;

Thread* getThread(const QString& threadRootId) const;

Expand Down
2 changes: 1 addition & 1 deletion gtad/gtad
Submodule gtad updated 17 files
+44 −99 .clang-format
+0 −173 .clang-tidy
+20 −14 CMakeLists.txt
+195 −218 README.md
+344 −465 analyzer.cpp
+32 −33 analyzer.h
+6 −7 main.cpp
+39 −30 model.cpp
+51 −89 model.h
+136 −110 printer.cpp
+5 −6 printer.h
+150 −176 translator.cpp
+11 −14 translator.h
+0 −2 util.h
+1 −1 yaml-cpp
+55 −91 yaml.cpp
+211 −356 yaml.h

0 comments on commit f7b965d

Please sign in to comment.