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