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

4
src/apiclient.d.ts vendored
View File

@ -93,7 +93,7 @@ declare module 'jellyfin-apiclient' {
deleteItemImage(itemId: string, imageType: ImageType, imageIndex?: number): Promise<void>;
deleteItem(itemId: string): Promise<void>;
deleteLiveTvRecording(id: string): Promise<void>;
deleteUserImage(userId: string, imageType: string, imageIndex?: number): Promise<void>;
deleteUserImage(userId: string, imageType: ImageType, imageIndex?: number): Promise<void>;
deleteUser(userId: string): Promise<void>;
detectBitrate(force: boolean): Promise<number>;
deviceId(): string;
@ -299,7 +299,7 @@ declare module 'jellyfin-apiclient' {
updateVirtualFolderOptions(id: string, libraryOptions?: any): Promise<void>;
uploadItemImage(itemId: string, imageType: ImageType, file: File): Promise<void>;
uploadItemSubtitle(itemId: string, language: string, isForced: boolean, file: File): Promise<void>;
uploadUserImage(userId: string, imageType: string, file: File): Promise<void>;
uploadUserImage(userId: string, imageType: ImageType, file: File): Promise<void>;
}
class AppStore {

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;

View File

@ -1,3 +1,3 @@
<div id="userImagePage" data-role="page" class="page libraryPage userPreferencesPage userPasswordPage noSecondaryNavPage" data-title="${Profile}" data-menubutton="false">
<div id="userProfilePage" data-role="page" class="page libraryPage userPreferencesPage userPasswordPage noSecondaryNavPage" data-title="${Profile}" data-menubutton="false">
</div>

View File

@ -81,7 +81,7 @@ import { appRouter } from '../components/appRouter';
alias: '/myprofile.html',
path: 'user/profile/index.html',
autoFocus: false,
pageComponent: 'UserImagePage'
pageComponent: 'UserProfilePage'
});
defineRoute({