Never allow undefined values in me model

zio/stable
Paul Frazee 2022-12-06 10:11:45 -06:00
parent 474c4f9b5d
commit 8d3d26134f
1 changed files with 12 additions and 12 deletions

View File

@ -5,10 +5,10 @@ import {NotificationsViewModel} from './notifications-view'
import {isObj, hasProp} from '../lib/type-guards' import {isObj, hasProp} from '../lib/type-guards'
export class MeModel { export class MeModel {
did?: string did: string = ''
handle?: string handle: string = ''
displayName?: string displayName: string = ''
description?: string description: string = ''
notificationCount: number = 0 notificationCount: number = 0
memberships?: MembershipsViewModel memberships?: MembershipsViewModel
notifications: NotificationsViewModel notifications: NotificationsViewModel
@ -23,10 +23,10 @@ export class MeModel {
} }
clear() { clear() {
this.did = undefined this.did = ''
this.handle = undefined this.handle = ''
this.displayName = undefined this.displayName = ''
this.description = undefined this.description = ''
this.notificationCount = 0 this.notificationCount = 0
this.memberships = undefined this.memberships = undefined
} }
@ -58,8 +58,8 @@ export class MeModel {
if (did && handle) { if (did && handle) {
this.did = did this.did = did
this.handle = handle this.handle = handle
this.displayName = displayName this.displayName = displayName || ''
this.description = description this.description = description || ''
} }
} }
} }
@ -74,8 +74,8 @@ export class MeModel {
}) })
runInAction(() => { runInAction(() => {
if (profile?.data) { if (profile?.data) {
this.displayName = profile.data.displayName this.displayName = profile.data.displayName || ''
this.description = profile.data.description this.description = profile.data.description || ''
} else { } else {
this.displayName = '' this.displayName = ''
this.description = '' this.description = ''