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() @ArgsType()
export default class UpdateUserInfosArgs { export default class UpdateUserInfosArgs {
@Field(() => String)
email!: string
@Field({ nullable: true }) @Field({ nullable: true })
firstName?: string firstName?: string

View File

@ -183,12 +183,14 @@ export class UserResolver {
if (!result.success) throw new Error(result.data) if (!result.success) throw new Error(result.data)
response = new UpdateUserInfosResponse(result.data) response = new UpdateUserInfosResponse(result.data)
} }
console.log("before coinaimation, coinanimation: %o", coinanimation)
if (coinanimation) { if (coinanimation !== undefined) {
// load user and balance // load user and balance
const userRepository = getCustomRepository(UserRepository) 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) const userSettingRepository = getCustomRepository(UserSettingRepository)
userSettingRepository userSettingRepository
.setOrUpdate(userEntity.id, Setting.COIN_ANIMATION, coinanimation.toString()) .setOrUpdate(userEntity.id, Setting.COIN_ANIMATION, coinanimation.toString())
@ -197,14 +199,17 @@ export class UserResolver {
}) })
if (!response) { if (!response) {
console.log("new response")
response = new UpdateUserInfosResponse({ valid_values: 1 }) response = new UpdateUserInfosResponse({ valid_values: 1 })
} else { } else {
response.validValues++ response.validValues++
} }
console.log("response should be set")
} }
if (!response) { if (!response) {
throw new Error('no valid response') throw new Error('no valid response')
} }
console.log(response)
return response return response
} }

View File

@ -27,7 +27,7 @@ export class UserSettingRepository extends Repository<UserSetting> {
async readBoolean(userId: number, key: Setting): Promise<boolean> { async readBoolean(userId: number, key: Setting): Promise<boolean> {
const 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 true
} }
return entity.value.toLowerCase() === 'true' return entity.value.toLowerCase() === 'true'
} }

View File

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