bsky-app/src/state/models/session.ts
2023-11-10 09:59:04 -06:00

39 lines
936 B
TypeScript

import {makeAutoObservable} from 'mobx'
import {
BskyAgent,
ComAtprotoServerDescribeServer as DescribeServer,
} from '@atproto/api'
import {RootStoreModel} from './root-store'
export type ServiceDescription = DescribeServer.OutputSchema
export class SessionModel {
constructor(public rootStore: RootStoreModel) {
makeAutoObservable(this, {
rootStore: false,
hasSession: false,
})
}
get currentSession(): any {
return undefined
}
get hasSession() {
return false
}
/**
* Helper to fetch the accounts config settings from an account.
*/
async describeService(service: string): Promise<ServiceDescription> {
const agent = new BskyAgent({service})
const res = await agent.com.atproto.server.describeServer({})
return res.data
}
/**
* Reloads the session from the server. Useful when account details change, like the handle.
*/
async reloadFromServer() {}
}