diff options
Diffstat (limited to 'client/src/app/core')
-rw-r--r-- | client/src/app/core/server/server.service.ts | 3 | ||||
-rw-r--r-- | client/src/app/core/users/user-local-storage.service.ts | 7 | ||||
-rw-r--r-- | client/src/app/core/users/user.model.ts | 6 |
3 files changed, 10 insertions, 6 deletions
diff --git a/client/src/app/core/server/server.service.ts b/client/src/app/core/server/server.service.ts index 9f191f0a6..fc269749b 100644 --- a/client/src/app/core/server/server.service.ts +++ b/client/src/app/core/server/server.service.ts | |||
@@ -193,7 +193,8 @@ export class ServerService { | |||
193 | } | 193 | } |
194 | 194 | ||
195 | private loadHTMLConfigLocally () { | 195 | private loadHTMLConfigLocally () { |
196 | const configString = window['PeerTubeServerConfig'] | 196 | // FIXME: typings |
197 | const configString = (window as any)['PeerTubeServerConfig'] | ||
197 | if (!configString) { | 198 | if (!configString) { |
198 | throw new Error('Could not find PeerTubeServerConfig in HTML') | 199 | throw new Error('Could not find PeerTubeServerConfig in HTML') |
199 | } | 200 | } |
diff --git a/client/src/app/core/users/user-local-storage.service.ts b/client/src/app/core/users/user-local-storage.service.ts index 1e629249a..a87f3b98a 100644 --- a/client/src/app/core/users/user-local-storage.service.ts +++ b/client/src/app/core/users/user-local-storage.service.ts | |||
@@ -4,7 +4,8 @@ import { Injectable } from '@angular/core' | |||
4 | import { AuthService, AuthStatus } from '@app/core/auth' | 4 | import { AuthService, AuthStatus } from '@app/core/auth' |
5 | import { getBoolOrDefault } from '@root-helpers/local-storage-utils' | 5 | import { getBoolOrDefault } from '@root-helpers/local-storage-utils' |
6 | import { logger } from '@root-helpers/logger' | 6 | import { logger } from '@root-helpers/logger' |
7 | import { UserLocalStorageKeys, OAuthUserTokens } from '@root-helpers/users' | 7 | import { OAuthUserTokens, UserLocalStorageKeys } from '@root-helpers/users' |
8 | import { objectKeysTyped } from '@shared/core-utils' | ||
8 | import { UserRole, UserUpdateMe } from '@shared/models' | 9 | import { UserRole, UserUpdateMe } from '@shared/models' |
9 | import { NSFWPolicyType } from '@shared/models/videos' | 10 | import { NSFWPolicyType } from '@shared/models/videos' |
10 | import { ServerService } from '../server' | 11 | import { ServerService } from '../server' |
@@ -122,7 +123,7 @@ export class UserLocalStorageService { | |||
122 | } | 123 | } |
123 | 124 | ||
124 | setUserInfo (profile: UserUpdateMe) { | 125 | setUserInfo (profile: UserUpdateMe) { |
125 | const localStorageKeys: { [ id in keyof UserUpdateMe ]: string } = { | 126 | const localStorageKeys = { |
126 | nsfwPolicy: UserLocalStorageKeys.NSFW_POLICY, | 127 | nsfwPolicy: UserLocalStorageKeys.NSFW_POLICY, |
127 | p2pEnabled: UserLocalStorageKeys.P2P_ENABLED, | 128 | p2pEnabled: UserLocalStorageKeys.P2P_ENABLED, |
128 | autoPlayVideo: UserLocalStorageKeys.AUTO_PLAY_VIDEO, | 129 | autoPlayVideo: UserLocalStorageKeys.AUTO_PLAY_VIDEO, |
@@ -132,7 +133,7 @@ export class UserLocalStorageService { | |||
132 | videoLanguages: UserLocalStorageKeys.VIDEO_LANGUAGES | 133 | videoLanguages: UserLocalStorageKeys.VIDEO_LANGUAGES |
133 | } | 134 | } |
134 | 135 | ||
135 | const obj = Object.keys(localStorageKeys) | 136 | const obj: [ string, string | boolean | string[] ][] = objectKeysTyped(localStorageKeys) |
136 | .filter(key => key in profile) | 137 | .filter(key => key in profile) |
137 | .map(key => ([ localStorageKeys[key], profile[key] ])) | 138 | .map(key => ([ localStorageKeys[key], profile[key] ])) |
138 | 139 | ||
diff --git a/client/src/app/core/users/user.model.ts b/client/src/app/core/users/user.model.ts index 2d783145f..d57608f1c 100644 --- a/client/src/app/core/users/user.model.ts +++ b/client/src/app/core/users/user.model.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | import { Account } from '@app/shared/shared-main/account/account.model' | 1 | import { Account } from '@app/shared/shared-main/account/account.model' |
2 | import { objectKeysTyped } from '@shared/core-utils' | ||
2 | import { hasUserRight } from '@shared/core-utils/users' | 3 | import { hasUserRight } from '@shared/core-utils/users' |
3 | import { | 4 | import { |
4 | ActorImage, | 5 | ActorImage, |
@@ -130,8 +131,9 @@ export class User implements UserServerModel { | |||
130 | } | 131 | } |
131 | 132 | ||
132 | patch (obj: UserServerModel) { | 133 | patch (obj: UserServerModel) { |
133 | for (const key of Object.keys(obj)) { | 134 | for (const key of objectKeysTyped(obj)) { |
134 | this[key] = obj[key] | 135 | // FIXME: typings |
136 | (this as any)[key] = obj[key] | ||
135 | } | 137 | } |
136 | 138 | ||
137 | if (obj.account !== undefined) { | 139 | if (obj.account !== undefined) { |