Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/gui/tray/activitylistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,13 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
const auto fileName = activity._fileAction == QStringLiteral("file_renamed") ? activity._renamedFile
: activity._file;
if (!fileName.isEmpty()) {
const auto folder = FolderMan::instance()->folder(activity._folder);
auto *folderMan = FolderMan::instance();
const auto folder = folderMan->folder(activity._folder);
Comment on lines +153 to +154
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not make FolderMan::instance() an inline function if we think this is overused and may lead to overhead ?
would not increase code complexity


const QString relPath = folder ? folder->remotePathTrailingSlash() + fileName
: fileName;

const auto localFiles = FolderMan::instance()->findFileInLocalFolders(relPath, accountState->account());
const auto localFiles = folderMan->findFileInLocalFolders(relPath, accountState->account());

if (localFiles.isEmpty()) {
return QString();
Expand All @@ -180,11 +181,12 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const

const auto getDisplayPath = [&activity, &accountState]() {
if (!activity._file.isEmpty()) {
const auto folder = FolderMan::instance()->folder(activity._folder);
auto *folderMan = FolderMan::instance();
const auto folder = folderMan->folder(activity._folder);

QString relPath = folder ? folder->remotePathTrailingSlash() + activity._file : activity._file;

const auto localFiles = FolderMan::instance()->findFileInLocalFolders(relPath, accountState->account());
const auto localFiles = folderMan->findFileInLocalFolders(relPath, accountState->account());

if (localFiles.count() > 0) {
if (relPath.startsWith('/') || relPath.startsWith('\\')) {
Expand Down Expand Up @@ -904,11 +906,10 @@ QVariant ActivityListModel::convertLinkToActionButton(const OCC::ActivityLink &a

const auto isReplyIconApplicable = activityLink._verb == QStringLiteral("REPLY");

const QString replyButtonPath = QStringLiteral("image://svgimage-custom-color/reply.svg");

if (isReplyIconApplicable) {
activityLinkCopy._imageSource = QString(replyButtonPath + "/");
activityLinkCopy._imageSourceHovered = QString(replyButtonPath + "/");
const QString replyButtonPath = QStringLiteral("image://svgimage-custom-color/reply.svg/");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be much better to use a string literal to generate a proper QString

Suggested change
const QString replyButtonPath = QStringLiteral("image://svgimage-custom-color/reply.svg/");
using namespace Qt::StringLiterals;
const auto replyButtonPath = u"image://svgimage-custom-color/reply.svg/"_s;

activityLinkCopy._imageSource = replyButtonPath;
activityLinkCopy._imageSourceHovered = replyButtonPath;
}

return QVariant::fromValue(activityLinkCopy);
Expand Down
11 changes: 6 additions & 5 deletions src/gui/tray/usermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -724,25 +724,26 @@ void User::slotRefresh()
{
slotRefreshUserStatus();

auto *account = _account.data();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AccountPtr::data() is an inline method
your changes will not bring any difference from performance point of view
please revert the changes around _account.data() use

if (checkPushNotificationsAreReady()) {
// we are relying on WebSocket push notifications - ignore refresh attempts from UI
slotRefreshActivities();
_timeSinceLastCheck[_account.data()].invalidate();
_timeSinceLastCheck[account].invalidate();
return;
}

// QElapsedTimer isn't actually constructed as invalid.
if (!_timeSinceLastCheck.contains(_account.data())) {
_timeSinceLastCheck[_account.data()].invalidate();
if (!_timeSinceLastCheck.contains(account)) {
_timeSinceLastCheck[account].invalidate();
}
QElapsedTimer &timer = _timeSinceLastCheck[_account.data()];
QElapsedTimer &timer = _timeSinceLastCheck[account];

// Fetch Activities only if visible and if last check is longer than 15 secs ago
if (timer.isValid() && timer.elapsed() < NOTIFICATION_REQUEST_FREE_PERIOD) {
qCDebug(lcActivity) << "Do not check as last check is only secs ago: " << timer.elapsed() / 1000;
return;
}
if (_account.data() && _account.data()->isConnected()) {
if (account && account->isConnected()) {
slotRefreshActivities();
slotRefreshNotifications();
timer.start();
Expand Down