diff --git a/src/app/mainview/components/SmartListItemDelegate.qml b/src/app/mainview/components/SmartListItemDelegate.qml index 6b6904c204446198cd5ec3d41a811e90f1127372..fe1a4e06003b2f0b182d65dfbce6befbba637c83 100644 --- a/src/app/mainview/components/SmartListItemDelegate.qml +++ b/src/app/mainview/components/SmartListItemDelegate.qml @@ -80,8 +80,8 @@ ItemDelegate { imageId: UID showPresenceIndicator: Presence !== undefined ? Presence : false - showSharePositionIndicator: PositionManager.isPositionSharedToConv(accountId, UID) - showSharedPositionIndicator: PositionManager.isConvSharingPosition(accountId, UID) + showSharePositionIndicator: PositionManager.isPositionSharedToConv(CurrentAccount.id, UID) + showSharedPositionIndicator: PositionManager.isConvSharingPosition(CurrentAccount.id, UID) Layout.preferredWidth: JamiTheme.smartListAvatarSize Layout.preferredHeight: JamiTheme.smartListAvatarSize @@ -89,10 +89,10 @@ ItemDelegate { Connections { target: PositionManager function onPositionShareConvIdsCountChanged () { - avatar.showSharePositionIndicator = PositionManager.isPositionSharedToConv(accountId, UID) + avatar.showSharePositionIndicator = PositionManager.isPositionSharedToConv(CurrentAccount.id, UID) } function onSharingUrisCountChanged () { - avatar.showSharedPositionIndicator = PositionManager.isConvSharingPosition(accountId, UID) + avatar.showSharedPositionIndicator = PositionManager.isConvSharingPosition(CurrentAccount.id, UID) } } diff --git a/src/app/positionmanager.cpp b/src/app/positionmanager.cpp index 7c1a204a3c1ef112a38f7fe76149275986ade06a..15416da5bf4e0d0b567e8271a6bea5298b9d8305 100644 --- a/src/app/positionmanager.cpp +++ b/src/app/positionmanager.cpp @@ -199,6 +199,7 @@ void PositionManager::stopSharingPosition(QString accountId, const QString convId) { QString stopMsg; + PositionKey key = qMakePair(accountId, convId); stopMsg = "{\"type\":\"Stop\"}"; if (accountId == "") { sendPosition(stopMsg, false); @@ -206,15 +207,17 @@ PositionManager::stopSharingPosition(QString accountId, const QString convId) positionShareConvIds_.clear(); } else { if (convId == "") { - stopPositionTimers(accountId); for (auto it = positionShareConvIds_.begin(); it != positionShareConvIds_.end();) { if (it->first == accountId) { + key = qMakePair(accountId, it->second); + stopPositionTimers(key); sendStopMessage(accountId, it->second); it = positionShareConvIds_.erase(it); } else ++it; } } else { + stopPositionTimers(key); sendStopMessage(accountId, convId); auto iter = std::find(positionShareConvIds_.begin(), positionShareConvIds_.end(), @@ -356,19 +359,22 @@ PositionManager::parseJsonPosition(const QString& accountId, void PositionManager::startPositionTimers(int timeSharing) { - mapTimerCountDown_[lrcInstance_->get_currentAccountId()] = timeSharing; + PositionKey key; + key.first = lrcInstance_->get_currentAccountId(); + key.second = lrcInstance_->get_selectedConvUid(); + mapTimerCountDown_[key] = timeSharing; countdownUpdate(); countdownTimer_->start(1000); } void -PositionManager::stopPositionTimers(QString accountId) +PositionManager::stopPositionTimers(PositionKey key) { // reset all timers - if (accountId == nullptr) { + if (key == PositionKey()) { mapTimerCountDown_.clear(); } else { - auto it = mapTimerCountDown_.find(accountId); + auto it = mapTimerCountDown_.find(key); if (it != mapTimerCountDown_.end()) { mapTimerCountDown_.erase(it); } @@ -457,13 +463,13 @@ PositionManager::countdownUpdate() mapTimerCountDown_.end(), [](const auto& end) { return end == 0; }); if (end != mapTimerCountDown_.end()) { - Q_EMIT sendCountdownUpdate(end.key(), end.value()); - stopSharingPosition(end.key()); + Q_EMIT sendCountdownUpdate(end.key().first + "_" + end.key().second, end.value()); + stopSharingPosition(end.key().first, end.key().second); } // When removals are done, countdown can be updated for (auto it = mapTimerCountDown_.begin(); it != mapTimerCountDown_.end(); it++) { if (it.value() != 0) { - Q_EMIT sendCountdownUpdate(it.key(), it.value()); + Q_EMIT sendCountdownUpdate(it.key().first + "_" + it.key().second, it.value()); it.value() -= 1000; } } diff --git a/src/app/positionmanager.h b/src/app/positionmanager.h index e54d0dac9bb9f39d5fa3588bb4aef99dfbfcf158..43910f0a8cb7009a2eac53bc8f3dc25ac02b9889 100644 --- a/src/app/positionmanager.h +++ b/src/app/positionmanager.h @@ -54,7 +54,7 @@ Q_SIGNALS: void unPinMapSignal(const QString& key); void localPositionReceived(const QString& accountId, const QString& peerId, const QString& body); void makeVisibleSharingButton(const QString& accountId); - void sendCountdownUpdate(const QString& accountId, const int remainingTime); + void sendCountdownUpdate(const QString key, const int remainingTime); protected: QString getAvatar(const QString& accountId, const QString& peerId); @@ -67,7 +67,7 @@ protected: void removePositionFromMemory(PositionKey key, QVariantMap positionReceived); void positionWatchDog(); void startPositionTimers(int timeSharing); - void stopPositionTimers(QString accountId = {}); + void stopPositionTimers(PositionKey key = {}); bool isNewMessageTriggersMap(bool endSharing, const QString& uri, const QString& accountId); void countdownUpdate(); void sendStopMessage(QString accountId = "", const QString convId = ""); @@ -105,7 +105,7 @@ private Q_SLOTS: private: SystemTray* systemTray_; std::unique_ptr<Positioning> localPositioning_; - QMap<QString, int> mapTimerCountDown_; + QMap<PositionKey, int> mapTimerCountDown_; QTimer* countdownTimer_ = nullptr; // map of all shared position by peers QMap<PositionKey, PositionObject*> objectListSharingUris_; diff --git a/src/app/webengine/map/MapPositionSharingControl.qml b/src/app/webengine/map/MapPositionSharingControl.qml index 5e578cdfcae3dde6f1d023a609ace95b230333fa..22d2efe7ea00c93f46f3bd66e2294b0696672d47 100644 --- a/src/app/webengine/map/MapPositionSharingControl.qml +++ b/src/app/webengine/map/MapPositionSharingControl.qml @@ -39,11 +39,7 @@ ColumnLayout { Layout.preferredWidth: textTimer.width + 15 Layout.preferredHeight: textTimer.height + 15 color: JamiTheme.mapButtonsOverlayColor - visible: textTimer.remainingTimeMs === 0 - ? false - : isUnpin - ? isSharing - : isSharingToCurrentConversation + visible: textTimer.remainingTimeMs !== 0 && !isUnpin && webView.isLoaded && isSharingToCurrentConversation Text { id: textTimer @@ -76,8 +72,8 @@ ColumnLayout { property int remainingTimeMs: 0 Connections { target: PositionManager - function onSendCountdownUpdate(accountId, remainingTime) { - if (accountId === attachedAccountId) { + function onSendCountdownUpdate(key, remainingTime) { + if (key === attachedAccountId + "_" + currentConvId) { textTimer.remainingTimeMs = remainingTime } }