save profile photos on profile view state (wip)

This commit is contained in:
João Ferreiro
2022-12-06 11:12:13 +00:00
parent a067312f19
commit 8d98c99705
5 changed files with 68 additions and 59 deletions
+21
View File
@@ -6,6 +6,7 @@ import {extractEntities} from '../../lib/strings'
import {Declaration} from './_common'
import {RootStoreModel} from './root-store'
import * as apilib from '../lib/api'
import {Image} from 'react-native-image-crop-picker'
export const ACTOR_TYPE_USER = 'app.bsky.system.actorUser'
export const ACTOR_TYPE_SCENE = 'app.bsky.system.actorScene'
@@ -46,6 +47,10 @@ export class ProfileViewModel {
// added data
descriptionEntities?: Entity[]
// temp state while imagery is not supported by the protocol
userAvatar: Image | null = null
userBanner: Image | null = null
constructor(
public rootStore: RootStoreModel,
params: GetProfile.QueryParams,
@@ -81,6 +86,14 @@ export class ProfileViewModel {
return this.declaration.actorType === ACTOR_TYPE_SCENE
}
get userAvatarPath() {
return this.userAvatar?.path
}
get userBannerPath() {
return this.userBanner?.path
}
// public api
// =
@@ -123,6 +136,14 @@ export class ProfileViewModel {
// state transitions
// =
updateUserAvatar(img: Image) {
this.userAvatar = img
}
updateUserBanner(img: Image) {
this.userBanner = img
}
private _xLoading(isRefreshing = false) {
this.isLoading = true
this.isRefreshing = isRefreshing