mirror of
https://github.com/nextcloud/server.git
synced 2026-04-22 14:50:17 -04:00
Retrieve user status only once when displaying page
We don't need to inject it in the template if the data is already available in the initial state. This is also a bit cleaner. Signed-off-by: Carl Schwan <carl@carlschwan.eu>
This commit is contained in:
parent
9c84aa5870
commit
ddc739b5ac
5 changed files with 9 additions and 24 deletions
|
|
@ -27,6 +27,7 @@ import { getRequestToken } from '@nextcloud/auth'
|
|||
import UserStatus from './UserStatus'
|
||||
import store from './store'
|
||||
import Avatar from '@nextcloud/vue/dist/Components/Avatar'
|
||||
import { loadState } from '@nextcloud/initial-state'
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
__webpack_nonce__ = btoa(getRequestToken())
|
||||
|
|
@ -35,11 +36,12 @@ Vue.prototype.t = t
|
|||
Vue.prototype.$t = t
|
||||
|
||||
const avatarDiv = document.getElementById('avatardiv-menu')
|
||||
const userStatusData = loadState('user_status', 'status')
|
||||
const propsData = {
|
||||
preloadedUserStatus: {
|
||||
message: avatarDiv.dataset.userstatus_message,
|
||||
icon: avatarDiv.dataset.userstatus_icon,
|
||||
status: avatarDiv.dataset.userstatus,
|
||||
message: userStatusData.message,
|
||||
icon: userStatusData.icon,
|
||||
status: userStatusData.status
|
||||
},
|
||||
user: avatarDiv.dataset.user,
|
||||
displayName: avatarDiv.dataset.displayname,
|
||||
|
|
|
|||
|
|
@ -153,11 +153,7 @@ $getUserAvatar = static function (int $size) use ($_): string {
|
|||
} ?>"
|
||||
data-user="<?php p($_['user_uid']); ?>"
|
||||
data-displayname="<?php p($_['user_displayname']); ?>"
|
||||
<?php if ($_['userStatus'] !== false) { ?>
|
||||
data-userstatus="<?php p($_['userStatus']->getStatus()); ?>"
|
||||
data-userstatus_message="<?php p($_['userStatus']->getMessage()); ?>"
|
||||
data-userstatus_icon="<?php p($_['userStatus']->getIcon()); ?>"
|
||||
<?php }
|
||||
<?php
|
||||
if ($_['userAvatarSet']) {
|
||||
$avatar32 = $getUserAvatar(32); ?> data-avatar="<?php p($avatar32); ?>"
|
||||
<?php
|
||||
|
|
|
|||
4
dist/user_status-menu.js
vendored
4
dist/user_status-menu.js
vendored
File diff suppressed because one or more lines are too long
2
dist/user_status-menu.js.map
vendored
2
dist/user_status-menu.js.map
vendored
File diff suppressed because one or more lines are too long
|
|
@ -47,7 +47,6 @@ use OC\Search\SearchQuery;
|
|||
use OC\Template\JSCombiner;
|
||||
use OC\Template\JSConfigHelper;
|
||||
use OC\Template\SCSSCacher;
|
||||
use OCP\App\IAppManager;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\Defaults;
|
||||
use OCP\IConfig;
|
||||
|
|
@ -55,7 +54,6 @@ use OCP\IInitialStateService;
|
|||
use OCP\INavigationManager;
|
||||
use OCP\IUserSession;
|
||||
use OCP\Support\Subscription\IRegistry;
|
||||
use OCP\UserStatus\IManager as IUserStatusManager;
|
||||
use OCP\Util;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
|
|
@ -140,17 +138,6 @@ class TemplateLayout extends \OC_Template {
|
|||
} else {
|
||||
$this->assign('userAvatarSet', true);
|
||||
$this->assign('userAvatarVersion', $this->config->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0));
|
||||
if (\OC::$server->get(IAppManager::class)->isEnabledForUser('user_status')) {
|
||||
$userStatusManager = \OC::$server->get(IUserStatusManager::class);
|
||||
$userStatuses = $userStatusManager->getUserStatuses([$user->getUID()]);
|
||||
if (array_key_exists($user->getUID(), $userStatuses)) {
|
||||
$this->assign('userStatus', $userStatuses[$user->getUID()]);
|
||||
} else {
|
||||
$this->assign('userStatus', false);
|
||||
}
|
||||
} else {
|
||||
$this->assign('userStatus', false);
|
||||
}
|
||||
}
|
||||
|
||||
// check if app menu icons should be inverted
|
||||
|
|
|
|||
Loading…
Reference in a new issue