diff --git a/src/apiclient.d.ts b/src/apiclient.d.ts index d46bd29f4c..48cc65df0d 100644 --- a/src/apiclient.d.ts +++ b/src/apiclient.d.ts @@ -93,7 +93,7 @@ declare module 'jellyfin-apiclient' { deleteItemImage(itemId: string, imageType: ImageType, imageIndex?: number): Promise; deleteItem(itemId: string): Promise; deleteLiveTvRecording(id: string): Promise; - deleteUserImage(userId: string, imageType: string, imageIndex?: number): Promise; + deleteUserImage(userId: string, imageType: ImageType, imageIndex?: number): Promise; deleteUser(userId: string): Promise; detectBitrate(force: boolean): Promise; deviceId(): string; @@ -299,7 +299,7 @@ declare module 'jellyfin-apiclient' { updateVirtualFolderOptions(id: string, libraryOptions?: any): Promise; uploadItemImage(itemId: string, imageType: ImageType, file: File): Promise; uploadItemSubtitle(itemId: string, language: string, isForced: boolean, file: File): Promise; - uploadUserImage(userId: string, imageType: string, file: File): Promise; + uploadUserImage(userId: string, imageType: ImageType, file: File): Promise; } class AppStore { diff --git a/src/components/dashboard/users/UserPasswordForm.tsx b/src/components/dashboard/users/UserPasswordForm.tsx index 2ccaa17d75..6b64953569 100644 --- a/src/components/dashboard/users/UserPasswordForm.tsx +++ b/src/components/dashboard/users/UserPasswordForm.tsx @@ -26,25 +26,16 @@ const UserPasswordForm: FunctionComponent = ({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 = ({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'); diff --git a/src/components/pages/UserImagePage.tsx b/src/components/pages/UserProfilePage.tsx similarity index 94% rename from src/components/pages/UserImagePage.tsx rename to src/components/pages/UserProfilePage.tsx index 702bb36855..dd39f523cc 100644 --- a/src/components/pages/UserImagePage.tsx +++ b/src/components/pages/UserProfilePage.tsx @@ -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 = ({userId}: IProps) => { +const UserProfilePage: FunctionComponent = ({userId}: IProps) => { const [ userName, setUserName ] = useState(''); const element = useRef(null); @@ -111,7 +112,7 @@ const UserImagePage: FunctionComponent = ({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 = ({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 = ({userId}: IProps) => { ); }; -export default UserImagePage; +export default UserProfilePage; diff --git a/src/controllers/user/profile/index.html b/src/controllers/user/profile/index.html index 91c3f7d7d9..c8fb3ae19d 100644 --- a/src/controllers/user/profile/index.html +++ b/src/controllers/user/profile/index.html @@ -1,3 +1,3 @@ -
+
diff --git a/src/scripts/routes.js b/src/scripts/routes.js index f2e0507521..62bd82e0b4 100644 --- a/src/scripts/routes.js +++ b/src/scripts/routes.js @@ -81,7 +81,7 @@ import { appRouter } from '../components/appRouter'; alias: '/myprofile.html', path: 'user/profile/index.html', autoFocus: false, - pageComponent: 'UserImagePage' + pageComponent: 'UserProfilePage' }); defineRoute({