mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
fix linting
This commit is contained in:
parent
f77de6ff5b
commit
68f8896ed3
@ -47,9 +47,11 @@ export class UserResolver {
|
||||
// read additional settings from settings table
|
||||
const userSettingRepository = getCustomRepository(UserSettingRepository)
|
||||
const userEntity = await dbUser.findByPubkeyHex(user.pubkey)
|
||||
const coinanimation = await userSettingRepository.readBoolean(userEntity.id, Setting.COIN_ANIMATION).catch((error) => {
|
||||
throw new Error(error)
|
||||
})
|
||||
const coinanimation = await userSettingRepository
|
||||
.readBoolean(userEntity.id, Setting.COIN_ANIMATION)
|
||||
.catch((error) => {
|
||||
throw new Error(error)
|
||||
})
|
||||
user.coinanimation = coinanimation
|
||||
return user
|
||||
}
|
||||
@ -191,13 +193,11 @@ export class UserResolver {
|
||||
const userEntity = await userRepository.findByPubkeyHex(result.data.user.public_hex)
|
||||
|
||||
const userSettingRepository = getCustomRepository(UserSettingRepository)
|
||||
userSettingRepository.setOrUpdate(
|
||||
userEntity.id,
|
||||
Setting.COIN_ANIMATION,
|
||||
coinanimation.toString(),
|
||||
).catch((error) => {
|
||||
throw new Error(error)
|
||||
})
|
||||
userSettingRepository
|
||||
.setOrUpdate(userEntity.id, Setting.COIN_ANIMATION, coinanimation.toString())
|
||||
.catch((error) => {
|
||||
throw new Error(error)
|
||||
})
|
||||
|
||||
if (!response) {
|
||||
response = new UpdateUserInfosResponse({ valid_values: 1 })
|
||||
|
||||
@ -2,7 +2,8 @@ import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, ManyToOne } from 't
|
||||
import { User } from './User'
|
||||
|
||||
@Entity()
|
||||
export class UserSetting { //extends BaseEntity {
|
||||
export class UserSetting {
|
||||
// extends BaseEntity {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number
|
||||
|
||||
|
||||
@ -5,7 +5,6 @@ import { isStringBoolean } from '../../util/validate'
|
||||
|
||||
@EntityRepository(UserSetting)
|
||||
export class UserSettingRepository extends Repository<UserSetting> {
|
||||
|
||||
async setOrUpdate(userId: number, key: Setting, value: string): Promise<UserSetting> {
|
||||
switch (key) {
|
||||
case Setting.COIN_ANIMATION:
|
||||
@ -26,8 +25,8 @@ export class UserSettingRepository extends Repository<UserSetting> {
|
||||
}
|
||||
|
||||
async readBoolean(userId: number, key: Setting): Promise<boolean> {
|
||||
let entity = await this.findOne({ userId: userId, key: key })
|
||||
if(!entity || !isStringBoolean(entity.value)) {
|
||||
const entity = await this.findOne({ userId: userId, key: key })
|
||||
if (!entity || !isStringBoolean(entity.value)) {
|
||||
return false
|
||||
}
|
||||
return entity.value.toLowerCase() === 'true'
|
||||
|
||||
@ -10,19 +10,17 @@
|
||||
*/
|
||||
|
||||
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
|
||||
|
||||
await queryFn(`
|
||||
await queryFn(`
|
||||
CREATE TABLE IF NOT EXISTS \`user_setting\` (
|
||||
\`id\` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
\`userId\` int(11) NOT NULL,
|
||||
\`key\` varchar(255) NOT NULL,
|
||||
\`value\` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (\`id\`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;`)
|
||||
}
|
||||
|
||||
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
|
||||
// write downgrade logic as parameter of queryFn
|
||||
await queryFn(`DROP TABLE IF EXISTS \`user_setting\`;`)
|
||||
}
|
||||
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;`)
|
||||
}
|
||||
|
||||
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
|
||||
// write downgrade logic as parameter of queryFn
|
||||
await queryFn(`DROP TABLE IF EXISTS \`user_setting\`;`)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user