fix saving coin animation

This commit is contained in:
einhorn_b 2021-10-02 14:25:36 +02:00
parent f51664807a
commit 7acda32c7d
4 changed files with 16 additions and 13 deletions

View File

@ -2,9 +2,6 @@ import { ArgsType, Field } from 'type-graphql'
@ArgsType()
export default class UpdateUserInfosArgs {
@Field(() => String)
email!: string
@Field({ nullable: true })
firstName?: string

View File

@ -183,12 +183,14 @@ export class UserResolver {
if (!result.success) throw new Error(result.data)
response = new UpdateUserInfosResponse(result.data)
}
if (coinanimation) {
console.log("before coinaimation, coinanimation: %o", coinanimation)
if (coinanimation !== undefined) {
// load user and balance
const userRepository = getCustomRepository(UserRepository)
const userEntity = await userRepository.findByPubkeyHex(context.pubkey)
console.log("get user repository")
console.log("try to find: %o", context.pubKey)
const userEntity = await userRepository.findByPubkeyHex(context.pubKey)
console.log("user entity: %o", userEntity )
const userSettingRepository = getCustomRepository(UserSettingRepository)
userSettingRepository
.setOrUpdate(userEntity.id, Setting.COIN_ANIMATION, coinanimation.toString())
@ -197,14 +199,17 @@ export class UserResolver {
})
if (!response) {
console.log("new response")
response = new UpdateUserInfosResponse({ valid_values: 1 })
} else {
response.validValues++
}
console.log("response should be set")
}
if (!response) {
throw new Error('no valid response')
}
console.log(response)
return response
}

View File

@ -27,7 +27,7 @@ export class UserSettingRepository extends Repository<UserSetting> {
async readBoolean(userId: number, key: Setting): Promise<boolean> {
const entity = await this.findOne({ userId: userId, key: key })
if (!entity || !isStringBoolean(entity.value)) {
return false
return true
}
return entity.value.toLowerCase() === 'true'
}

View File

@ -48,14 +48,15 @@ export default {
.mutate({
mutation: updateUserInfos,
variables: {
coinanimation: this.$store.state.coinanimation,
coinanimation: this.CoinAnimationStatus,
},
})
.then(() => {
this.$store.state.coinanimation = this.CoinAnimationStatus
this.$toasted.success(
this.CoinAnimationStatus
? this.$t('setting.coinanimationTrue')
: this.$t('setting.coinanimationFalse'),
? this.$t('settings.coinanimation.True')
: this.$t('settings.coinanimation.False'),
)
})
.catch((error) => {