blob: 1ec418b78780e9460e82017509b8daac1061de46 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
import {makeAutoObservable, runInAction} from 'mobx'
import {RootStoreModel} from './root-store'
export class MeModel {
did?: string
name?: string
displayName?: string
description?: string
constructor(public rootStore: RootStoreModel) {
makeAutoObservable(this, {rootStore: false}, {autoBind: true})
}
async load() {
const sess = this.rootStore.session
if (sess.isAuthed) {
// TODO
this.did = 'did:test:alice'
this.name = 'alice.todo'
const profile = await this.rootStore.api.todo.social.getProfile({
user: this.did,
})
runInAction(() => {
if (profile?.data) {
this.displayName = profile.data.displayName
this.description = profile.data.description
} else {
this.displayName = ''
this.description = ''
}
})
} else {
this.did = undefined
this.name = undefined
this.displayName = undefined
this.description = undefined
}
}
}
|