Lex refactor (#362)
* Remove the hackcheck for upgrades * Rename the PostEmbeds folder to match the codebase style * Updates to latest lex refactor * Update to use new bsky agent * Update to use api package's richtext library * Switch to upsertProfile * Add TextEncoder/TextDecoder polyfill * Add Intl.Segmenter polyfill * Update composer to calculate lengths by grapheme * Fix detox * Fix login in e2e * Create account e2e passing * Implement an e2e mocking framework * Don't use private methods on mobx models as mobx can't track them * Add tooling for e2e-specific builds and add e2e media-picker mock * Add some tests and fix some bugs around profile editing * Add shell tests * Add home screen tests * Add thread screen tests * Add tests for other user profile screens * Add search screen tests * Implement profile imagery change tools and tests * Update to new embed behaviors * Add post tests * Fix to profile-screen test * Fix session resumption * Update web composer to new api * 1.11.0 * Fix pagination cursor parameters * Add quote posts to notifications * Fix embed layouts * Remove youtube inline player and improve tap handling on link cards * Reset minimal shell mode on all screen loads and feed swipes (close #299) * Update podfile.lock * Improve post notfound UI (close #366) * Bump atproto packages
This commit is contained in:
parent
19f3a2fa92
commit
a3334a01a2
133 changed files with 3103 additions and 2839 deletions
|
@ -1,9 +1,9 @@
|
|||
import {makeAutoObservable, runInAction} from 'mobx'
|
||||
import {
|
||||
AtpAgent,
|
||||
BskyAgent,
|
||||
AtpSessionEvent,
|
||||
AtpSessionData,
|
||||
ComAtprotoServerGetAccountsConfig as GetAccountsConfig,
|
||||
ComAtprotoServerDescribeServer as DescribeServer,
|
||||
} from '@atproto/api'
|
||||
import normalizeUrl from 'normalize-url'
|
||||
import {isObj, hasProp} from 'lib/type-guards'
|
||||
|
@ -11,7 +11,7 @@ import {networkRetry} from 'lib/async/retry'
|
|||
import {z} from 'zod'
|
||||
import {RootStoreModel} from './root-store'
|
||||
|
||||
export type ServiceDescription = GetAccountsConfig.OutputSchema
|
||||
export type ServiceDescription = DescribeServer.OutputSchema
|
||||
|
||||
export const activeSession = z.object({
|
||||
service: z.string(),
|
||||
|
@ -40,7 +40,7 @@ export class SessionModel {
|
|||
// emergency log facility to help us track down this logout issue
|
||||
// remove when resolved
|
||||
// -prf
|
||||
private _log(message: string, details?: Record<string, any>) {
|
||||
_log(message: string, details?: Record<string, any>) {
|
||||
details = details || {}
|
||||
details.state = {
|
||||
data: this.data,
|
||||
|
@ -73,6 +73,7 @@ export class SessionModel {
|
|||
rootStore: false,
|
||||
serialize: false,
|
||||
hydrate: false,
|
||||
hasSession: false,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -154,7 +155,7 @@ export class SessionModel {
|
|||
/**
|
||||
* Sets the active session
|
||||
*/
|
||||
async setActiveSession(agent: AtpAgent, did: string) {
|
||||
async setActiveSession(agent: BskyAgent, did: string) {
|
||||
this._log('SessionModel:setActiveSession')
|
||||
this.data = {
|
||||
service: agent.service.toString(),
|
||||
|
@ -166,7 +167,7 @@ export class SessionModel {
|
|||
/**
|
||||
* Upserts a session into the accounts
|
||||
*/
|
||||
private persistSession(
|
||||
persistSession(
|
||||
service: string,
|
||||
did: string,
|
||||
event: AtpSessionEvent,
|
||||
|
@ -225,7 +226,7 @@ export class SessionModel {
|
|||
/**
|
||||
* Clears any session tokens from the accounts; used on logout.
|
||||
*/
|
||||
private clearSessionTokens() {
|
||||
clearSessionTokens() {
|
||||
this._log('SessionModel:clearSessionTokens')
|
||||
this.accounts = this.accounts.map(acct => ({
|
||||
service: acct.service,
|
||||
|
@ -239,10 +240,8 @@ export class SessionModel {
|
|||
/**
|
||||
* Fetches additional information about an account on load.
|
||||
*/
|
||||
private async loadAccountInfo(agent: AtpAgent, did: string) {
|
||||
const res = await agent.api.app.bsky.actor
|
||||
.getProfile({actor: did})
|
||||
.catch(_e => undefined)
|
||||
async loadAccountInfo(agent: BskyAgent, did: string) {
|
||||
const res = await agent.getProfile({actor: did}).catch(_e => undefined)
|
||||
if (res) {
|
||||
return {
|
||||
dispayName: res.data.displayName,
|
||||
|
@ -255,8 +254,8 @@ export class SessionModel {
|
|||
* Helper to fetch the accounts config settings from an account.
|
||||
*/
|
||||
async describeService(service: string): Promise<ServiceDescription> {
|
||||
const agent = new AtpAgent({service})
|
||||
const res = await agent.api.com.atproto.server.getAccountsConfig({})
|
||||
const agent = new BskyAgent({service})
|
||||
const res = await agent.com.atproto.server.describeServer({})
|
||||
return res.data
|
||||
}
|
||||
|
||||
|
@ -272,7 +271,7 @@ export class SessionModel {
|
|||
return false
|
||||
}
|
||||
|
||||
const agent = new AtpAgent({
|
||||
const agent = new BskyAgent({
|
||||
service: account.service,
|
||||
persistSession: (evt: AtpSessionEvent, sess?: AtpSessionData) => {
|
||||
this.persistSession(account.service, account.did, evt, sess)
|
||||
|
@ -321,7 +320,7 @@ export class SessionModel {
|
|||
password: string
|
||||
}) {
|
||||
this._log('SessionModel:login')
|
||||
const agent = new AtpAgent({service})
|
||||
const agent = new BskyAgent({service})
|
||||
await agent.login({identifier, password})
|
||||
if (!agent.session) {
|
||||
throw new Error('Failed to establish session')
|
||||
|
@ -355,7 +354,7 @@ export class SessionModel {
|
|||
inviteCode?: string
|
||||
}) {
|
||||
this._log('SessionModel:createAccount')
|
||||
const agent = new AtpAgent({service})
|
||||
const agent = new BskyAgent({service})
|
||||
await agent.createAccount({
|
||||
handle,
|
||||
password,
|
||||
|
@ -389,7 +388,7 @@ export class SessionModel {
|
|||
// need to evaluate why deleting the session has caused errors at times
|
||||
// -prf
|
||||
/*if (this.hasSession) {
|
||||
this.rootStore.api.com.atproto.session.delete().catch((e: any) => {
|
||||
this.rootStore.agent.com.atproto.session.delete().catch((e: any) => {
|
||||
this.rootStore.log.warn(
|
||||
'(Minor issue) Failed to delete session on the server',
|
||||
e,
|
||||
|
@ -415,7 +414,7 @@ export class SessionModel {
|
|||
if (!sess) {
|
||||
return
|
||||
}
|
||||
const res = await this.rootStore.api.app.bsky.actor
|
||||
const res = await this.rootStore.agent
|
||||
.getProfile({actor: sess.did})
|
||||
.catch(_e => undefined)
|
||||
if (res?.success) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue