Implement profile updates
This commit is contained in:
parent
fe52d19c48
commit
38ed9a7943
9 changed files with 24 additions and 33 deletions
|
@ -138,29 +138,17 @@ export async function unfollow(store: RootStoreModel, followUri: string) {
|
|||
|
||||
export async function updateProfile(
|
||||
store: RootStoreModel,
|
||||
did: string,
|
||||
modifyFn: (existing?: Profile.Record) => Profile.Record,
|
||||
) {
|
||||
// TODO NOW replaceme
|
||||
const res = await store.api.app.bsky.actor.profile.list({
|
||||
user: store.me.did || '',
|
||||
user: did || '',
|
||||
})
|
||||
const existing = res.records[0]
|
||||
if (existing) {
|
||||
await store.api.app.bsky.actor.profile.put(
|
||||
{
|
||||
did: store.me.did || '',
|
||||
rkey: new AtUri(existing.uri).rkey,
|
||||
},
|
||||
modifyFn(existing.value),
|
||||
)
|
||||
} else {
|
||||
await store.api.app.bsky.actor.profile.create(
|
||||
{
|
||||
did: store.me.did || '',
|
||||
},
|
||||
modifyFn(),
|
||||
)
|
||||
}
|
||||
await store.api.app.bsky.actor.updateProfile({
|
||||
did: did || '',
|
||||
...modifyFn(existing?.value),
|
||||
})
|
||||
}
|
||||
|
||||
export async function inviteToScene(
|
||||
|
|
|
@ -111,10 +111,7 @@ export class ProfileViewModel {
|
|||
}
|
||||
|
||||
async updateProfile(fn: (existing?: Profile.Record) => Profile.Record) {
|
||||
if (this.did !== this.rootStore.me.did) {
|
||||
throw new Error('Not your profile!')
|
||||
}
|
||||
await apilib.updateProfile(this.rootStore, fn)
|
||||
await apilib.updateProfile(this.rootStore, this.did, fn)
|
||||
await this.refresh()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue