aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core/users
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/core/users')
-rw-r--r--client/src/app/core/users/user-local-storage.service.ts7
-rw-r--r--client/src/app/core/users/user.model.ts6
2 files changed, 8 insertions, 5 deletions
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'
4import { AuthService, AuthStatus } from '@app/core/auth' 4import { AuthService, AuthStatus } from '@app/core/auth'
5import { getBoolOrDefault } from '@root-helpers/local-storage-utils' 5import { getBoolOrDefault } from '@root-helpers/local-storage-utils'
6import { logger } from '@root-helpers/logger' 6import { logger } from '@root-helpers/logger'
7import { UserLocalStorageKeys, OAuthUserTokens } from '@root-helpers/users' 7import { OAuthUserTokens, UserLocalStorageKeys } from '@root-helpers/users'
8import { objectKeysTyped } from '@shared/core-utils'
8import { UserRole, UserUpdateMe } from '@shared/models' 9import { UserRole, UserUpdateMe } from '@shared/models'
9import { NSFWPolicyType } from '@shared/models/videos' 10import { NSFWPolicyType } from '@shared/models/videos'
10import { ServerService } from '../server' 11import { 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 @@
1import { Account } from '@app/shared/shared-main/account/account.model' 1import { Account } from '@app/shared/shared-main/account/account.model'
2import { objectKeysTyped } from '@shared/core-utils'
2import { hasUserRight } from '@shared/core-utils/users' 3import { hasUserRight } from '@shared/core-utils/users'
3import { 4import {
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) {