Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2022-05-31 10:21:13 +0300
committerGitHub <noreply@github.com>2022-05-31 10:21:13 +0300
commit3638e65027afad9f51676ba7bb6feea2ea4a5c88 (patch)
tree7837e23a3876ce1375d3d7e3fbe37f0278d5c3c7 /apps
parent4b2bac30162004d89febbd86e5a3cd420c26e8f8 (diff)
parent2d34b55afabf4afb7fbfc8e34fbb1ae411d9bc17 (diff)
Merge pull request #32619 from nextcloud/backport/32618/stable24
[stable24] Fix status handling
Diffstat (limited to 'apps')
-rw-r--r--apps/user_status/lib/Listener/UserLiveStatusListener.php5
-rw-r--r--apps/user_status/src/components/SetStatusModal.vue4
-rw-r--r--apps/user_status/src/store/userStatus.js19
-rw-r--r--apps/user_status/tests/Unit/Listener/UserLiveStatusListenerTest.php11
4 files changed, 28 insertions, 11 deletions
diff --git a/apps/user_status/lib/Listener/UserLiveStatusListener.php b/apps/user_status/lib/Listener/UserLiveStatusListener.php
index c015e684142..3e05efa7118 100644
--- a/apps/user_status/lib/Listener/UserLiveStatusListener.php
+++ b/apps/user_status/lib/Listener/UserLiveStatusListener.php
@@ -43,11 +43,14 @@ use OCP\UserStatus\IUserStatus;
*/
class UserLiveStatusListener implements IEventListener {
private UserStatusMapper $mapper;
+ private StatusService $statusService;
private ITimeFactory $timeFactory;
public function __construct(UserStatusMapper $mapper,
+ StatusService $statusService,
ITimeFactory $timeFactory) {
$this->mapper = $mapper;
+ $this->statusService = $statusService;
$this->timeFactory = $timeFactory;
}
@@ -62,7 +65,7 @@ class UserLiveStatusListener implements IEventListener {
$user = $event->getUser();
try {
- $userStatus = $this->mapper->findByUserId($user->getUID());
+ $userStatus = $this->statusService->findByUserId($user->getUID());
} catch (DoesNotExistException $ex) {
$userStatus = new UserStatus();
$userStatus->setUserId($user->getUID());
diff --git a/apps/user_status/src/components/SetStatusModal.vue b/apps/user_status/src/components/SetStatusModal.vue
index df6858ca6ff..0c95128c8d2 100644
--- a/apps/user_status/src/components/SetStatusModal.vue
+++ b/apps/user_status/src/components/SetStatusModal.vue
@@ -55,14 +55,14 @@
<ClearAtSelect :clear-at="clearAt"
@select-clear-at="setClearAt" />
<div class="status-buttons">
- <ButtonVue wide="true"
+ <ButtonVue :wide="true"
type="tertiary"
:text="$t('user_status', 'Clear status message')"
:disabled="isSavingStatus"
@click="clearStatus">
{{ $t('user_status', 'Clear status message') }}
</ButtonVue>
- <ButtonVue wide="true"
+ <ButtonVue :wide="true"
type="primary"
:text="$t('user_status', 'Set status message')"
:disabled="isSavingStatus"
diff --git a/apps/user_status/src/store/userStatus.js b/apps/user_status/src/store/userStatus.js
index c54fbe5040b..6d8b5bd1e1f 100644
--- a/apps/user_status/src/store/userStatus.js
+++ b/apps/user_status/src/store/userStatus.js
@@ -130,12 +130,23 @@ const mutations = {
*/
loadStatusFromServer(state, { status, statusIsUserDefined, message, icon, clearAt, messageIsPredefined, messageId }) {
state.status = status
- state.statusIsUserDefined = statusIsUserDefined
state.message = message
state.icon = icon
- state.clearAt = clearAt
- state.messageIsPredefined = messageIsPredefined
- state.messageId = messageId
+
+ // Don't overwrite certain values if the refreshing comes in via short updates
+ // E.g. from talk participant list which only has the status, message and icon
+ if (typeof statusIsUserDefined !== 'undefined') {
+ state.statusIsUserDefined = statusIsUserDefined
+ }
+ if (typeof clearAt !== 'undefined') {
+ state.clearAt = clearAt
+ }
+ if (typeof messageIsPredefined !== 'undefined') {
+ state.messageIsPredefined = messageIsPredefined
+ }
+ if (typeof messageId !== 'undefined') {
+ state.messageId = messageId
+ }
},
}
diff --git a/apps/user_status/tests/Unit/Listener/UserLiveStatusListenerTest.php b/apps/user_status/tests/Unit/Listener/UserLiveStatusListenerTest.php
index 2e815073b5a..b2d446d912e 100644
--- a/apps/user_status/tests/Unit/Listener/UserLiveStatusListenerTest.php
+++ b/apps/user_status/tests/Unit/Listener/UserLiveStatusListenerTest.php
@@ -30,6 +30,7 @@ use OCA\UserStatus\Db\UserStatus;
use OCA\UserStatus\Db\UserStatusMapper;
use OCA\UserStatus\Listener\UserDeletedListener;
use OCA\UserStatus\Listener\UserLiveStatusListener;
+use OCA\UserStatus\Service\StatusService;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\EventDispatcher\GenericEvent;
@@ -41,7 +42,8 @@ class UserLiveStatusListenerTest extends TestCase {
/** @var UserStatusMapper|\PHPUnit\Framework\MockObject\MockObject */
private $mapper;
-
+ /** @var StatusService|\PHPUnit\Framework\MockObject\MockObject */
+ private $statusService;
/** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
private $timeFactory;
@@ -52,8 +54,9 @@ class UserLiveStatusListenerTest extends TestCase {
parent::setUp();
$this->mapper = $this->createMock(UserStatusMapper::class);
+ $this->statusService = $this->createMock(StatusService::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
- $this->listener = new UserLiveStatusListener($this->mapper, $this->timeFactory);
+ $this->listener = new UserLiveStatusListener($this->mapper, $this->statusService, $this->timeFactory);
}
/**
@@ -85,12 +88,12 @@ class UserLiveStatusListenerTest extends TestCase {
$userStatus->setStatusTimestamp($previousTimestamp);
$userStatus->setIsUserDefined($previousIsUserDefined);
- $this->mapper->expects($this->once())
+ $this->statusService->expects($this->once())
->method('findByUserId')
->with($userId)
->willReturn($userStatus);
} else {
- $this->mapper->expects($this->once())
+ $this->statusService->expects($this->once())
->method('findByUserId')
->with($userId)
->willThrowException(new DoesNotExistException(''));