1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

apply suggestion

This commit is contained in:
grafixeyehero 2022-03-09 19:36:22 +03:00 committed by Bill Thornton
parent 08807dca19
commit 3886b7da1f
5 changed files with 10 additions and 18 deletions

View file

@ -26,25 +26,16 @@ const UserPasswordForm: FunctionComponent<IProps> = ({userId}: IProps) => {
window.ApiClient.getUser(userId).then(function (user) {
Dashboard.getCurrentUser().then(function (loggedInUser: { Policy: { IsAdministrator: boolean; }; }) {
if (!user.Id) {
throw new Error('Unexpected null user.Id');
}
if (!user.Policy) {
throw new Error('Unexpected null user.Policy');
}
if (!user.Id) {
throw new Error('Unexpected null user.Id');
}
if (!user.Configuration) {
throw new Error('Unexpected null user.Configuration');
}
LibraryMenu.setTitle(user.Name);
const showPasswordSection = true;
let showLocalAccessSection = false;
if (user.HasConfiguredPassword) {
@ -56,7 +47,7 @@ const UserPasswordForm: FunctionComponent<IProps> = ({userId}: IProps) => {
(page.querySelector('#fldCurrentPassword') as HTMLDivElement).classList.add('hide');
}
if (showPasswordSection && (loggedInUser.Policy.IsAdministrator || user.Policy.EnableUserPreferenceAccess)) {
if (loggedInUser.Policy.IsAdministrator || user.Policy.EnableUserPreferenceAccess) {
(page.querySelector('.passwordSection') as HTMLDivElement).classList.remove('hide');
} else {
(page.querySelector('.passwordSection') as HTMLDivElement).classList.add('hide');

View file

@ -1,3 +1,4 @@
import { ImageType } from '@thornbill/jellyfin-sdk/dist/generated-client';
import React, { FunctionComponent, useEffect, useState, useRef, useCallback } from 'react';
import Dashboard from '../../scripts/clientUtils';
@ -14,7 +15,7 @@ type IProps = {
userId: string;
}
const UserImagePage: FunctionComponent<IProps> = ({userId}: IProps) => {
const UserProfilePage: FunctionComponent<IProps> = ({userId}: IProps) => {
const [ userName, setUserName ] = useState('');
const element = useRef<HTMLDivElement>(null);
@ -111,7 +112,7 @@ const UserImagePage: FunctionComponent<IProps> = ({userId}: IProps) => {
reader.onabort = onFileReaderAbort;
reader.onload = () => {
userImage.style.backgroundImage = 'url(' + reader.result + ')';
window.ApiClient.uploadUserImage(userId, 'Primary', file).then(function () {
window.ApiClient.uploadUserImage(userId, ImageType.Primary, file).then(function () {
loading.hide();
reloadUser();
});
@ -126,7 +127,7 @@ const UserImagePage: FunctionComponent<IProps> = ({userId}: IProps) => {
globalize.translate('DeleteImage')
).then(function () {
loading.show();
window.ApiClient.deleteUserImage(userId, 'Primary').then(function () {
window.ApiClient.deleteUserImage(userId, ImageType.Primary).then(function () {
loading.hide();
reloadUser();
});
@ -188,4 +189,4 @@ const UserImagePage: FunctionComponent<IProps> = ({userId}: IProps) => {
);
};
export default UserImagePage;
export default UserProfilePage;