Never allow undefined values in me model
parent
474c4f9b5d
commit
8d3d26134f
|
@ -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 = ''
|
||||||
|
|
Loading…
Reference in New Issue