diff options
Diffstat (limited to 'src/state')
-rw-r--r-- | src/state/lib/api.ts | 24 | ||||
-rw-r--r-- | src/state/models/feed-view.ts | 8 | ||||
-rw-r--r-- | src/state/models/liked-by-view.ts | 4 | ||||
-rw-r--r-- | src/state/models/me.ts | 4 | ||||
-rw-r--r-- | src/state/models/notifications-view.ts | 10 | ||||
-rw-r--r-- | src/state/models/post-thread-view.ts | 4 | ||||
-rw-r--r-- | src/state/models/post.ts | 4 | ||||
-rw-r--r-- | src/state/models/profile-view.ts | 6 | ||||
-rw-r--r-- | src/state/models/reposted-by-view.ts | 4 | ||||
-rw-r--r-- | src/state/models/root-store.ts | 2 | ||||
-rw-r--r-- | src/state/models/session.ts | 12 | ||||
-rw-r--r-- | src/state/models/user-followers-view.ts | 4 | ||||
-rw-r--r-- | src/state/models/user-follows-view.ts | 6 |
13 files changed, 45 insertions, 47 deletions
diff --git a/src/state/lib/api.ts b/src/state/lib/api.ts index f2418ef31..1968eb291 100644 --- a/src/state/lib/api.ts +++ b/src/state/lib/api.ts @@ -5,7 +5,7 @@ // import {ReactNativeStore} from './auth' import AdxApi from '../../third-party/api' -import * as Profile from '../../third-party/api/src/types/todo/social/profile' +import * as Profile from '../../third-party/api/src/types/app/bsky/profile' import {AdxUri} from '../../third-party/uri' import {RootStoreModel} from '../models/root-store' import {extractEntities} from '../../view/lib/strings' @@ -22,7 +22,7 @@ export async function post( let reply if (replyToUri) { const replyToUrip = new AdxUri(replyToUri) - const parentPost = await store.api.todo.social.post.get({ + const parentPost = await store.api.app.bsky.post.get({ nameOrDid: replyToUrip.host, tid: replyToUrip.recordKey, }) @@ -34,7 +34,7 @@ export async function post( } } const entities = extractEntities(text) - return await store.api.todo.social.post.create( + return await store.api.app.bsky.post.create( {did: store.me.did || ''}, { text, @@ -46,7 +46,7 @@ export async function post( } export async function like(store: RootStoreModel, uri: string) { - return await store.api.todo.social.like.create( + return await store.api.app.bsky.like.create( {did: store.me.did || ''}, { subject: uri, @@ -57,14 +57,14 @@ export async function like(store: RootStoreModel, uri: string) { export async function unlike(store: RootStoreModel, likeUri: string) { const likeUrip = new AdxUri(likeUri) - return await store.api.todo.social.like.delete({ + return await store.api.app.bsky.like.delete({ did: likeUrip.hostname, tid: likeUrip.recordKey, }) } export async function repost(store: RootStoreModel, uri: string) { - return await store.api.todo.social.repost.create( + return await store.api.app.bsky.repost.create( {did: store.me.did || ''}, { subject: uri, @@ -75,14 +75,14 @@ export async function repost(store: RootStoreModel, uri: string) { export async function unrepost(store: RootStoreModel, repostUri: string) { const repostUrip = new AdxUri(repostUri) - return await store.api.todo.social.repost.delete({ + return await store.api.app.bsky.repost.delete({ did: repostUrip.hostname, tid: repostUrip.recordKey, }) } export async function follow(store: RootStoreModel, subject: string) { - return await store.api.todo.social.follow.create( + return await store.api.app.bsky.follow.create( {did: store.me.did || ''}, { subject, @@ -93,7 +93,7 @@ export async function follow(store: RootStoreModel, subject: string) { export async function unfollow(store: RootStoreModel, followUri: string) { const followUrip = new AdxUri(followUri) - return await store.api.todo.social.follow.delete({ + return await store.api.app.bsky.follow.delete({ did: followUrip.hostname, tid: followUrip.recordKey, }) @@ -103,12 +103,12 @@ export async function updateProfile( store: RootStoreModel, modifyFn: (existing?: Profile.Record) => Profile.Record, ) { - const res = await store.api.todo.social.profile.list({ + const res = await store.api.app.bsky.profile.list({ nameOrDid: store.me.did || '', }) const existing = res.records[0] if (existing) { - await store.api.todo.social.profile.put( + await store.api.app.bsky.profile.put( { did: store.me.did || '', tid: new AdxUri(existing.uri).recordKey, @@ -116,7 +116,7 @@ export async function updateProfile( modifyFn(existing.value), ) } else { - await store.api.todo.social.profile.create( + await store.api.app.bsky.profile.create( { did: store.me.did || '', }, diff --git a/src/state/models/feed-view.ts b/src/state/models/feed-view.ts index 3d618f91e..c8cff9ef2 100644 --- a/src/state/models/feed-view.ts +++ b/src/state/models/feed-view.ts @@ -1,6 +1,6 @@ import {makeAutoObservable, runInAction} from 'mobx' -import * as GetHomeFeed from '../../third-party/api/src/types/todo/social/getHomeFeed' -import * as GetAuthorFeed from '../../third-party/api/src/types/todo/social/getAuthorFeed' +import * as GetHomeFeed from '../../third-party/api/src/types/app/bsky/getHomeFeed' +import * as GetAuthorFeed from '../../third-party/api/src/types/app/bsky/getAuthorFeed' import {RootStoreModel} from './root-store' import * as apilib from '../lib/api' @@ -367,11 +367,11 @@ export class FeedModel { ): Promise<GetHomeFeed.Response | GetAuthorFeed.Response> { params = Object.assign({}, this.params, params) if (this.feedType === 'home') { - return this.rootStore.api.todo.social.getHomeFeed( + return this.rootStore.api.app.bsky.getHomeFeed( params as GetHomeFeed.QueryParams, ) } else { - return this.rootStore.api.todo.social.getAuthorFeed( + return this.rootStore.api.app.bsky.getAuthorFeed( params as GetAuthorFeed.QueryParams, ) } diff --git a/src/state/models/liked-by-view.ts b/src/state/models/liked-by-view.ts index 5c873b19a..51b20cf1c 100644 --- a/src/state/models/liked-by-view.ts +++ b/src/state/models/liked-by-view.ts @@ -1,6 +1,6 @@ import {makeAutoObservable, runInAction} from 'mobx' import {AdxUri} from '../../third-party/uri' -import * as GetLikedBy from '../../third-party/api/src/types/todo/social/getLikedBy' +import * as GetLikedBy from '../../third-party/api/src/types/app/bsky/getLikedBy' import {RootStoreModel} from './root-store' type LikedByItem = GetLikedBy.OutputSchema['likedBy'][number] @@ -113,7 +113,7 @@ export class LikedByViewModel { private async _fetch(isRefreshing = false) { this._xLoading(isRefreshing) try { - const res = await this.rootStore.api.todo.social.getLikedBy( + const res = await this.rootStore.api.app.bsky.getLikedBy( Object.assign({}, this.params, {uri: this.resolvedUri}), ) this._replaceAll(res) diff --git a/src/state/models/me.ts b/src/state/models/me.ts index 9e0c897ed..333cf5626 100644 --- a/src/state/models/me.ts +++ b/src/state/models/me.ts @@ -25,7 +25,7 @@ export class MeModel { if (sess.isAuthed && sess.data) { this.did = sess.data.userdid || '' this.name = sess.data.username - const profile = await this.rootStore.api.todo.social.getProfile({ + const profile = await this.rootStore.api.app.bsky.getProfile({ user: this.did, }) runInAction(() => { @@ -43,7 +43,7 @@ export class MeModel { } async fetchStateUpdate() { - const res = await this.rootStore.api.todo.social.getNotificationCount({}) + const res = await this.rootStore.api.app.bsky.getNotificationCount({}) runInAction(() => { this.notificationCount = res.data.count }) diff --git a/src/state/models/notifications-view.ts b/src/state/models/notifications-view.ts index 5528b9f08..387e095f7 100644 --- a/src/state/models/notifications-view.ts +++ b/src/state/models/notifications-view.ts @@ -1,5 +1,5 @@ import {makeAutoObservable} from 'mobx' -import * as GetNotifications from '../../third-party/api/src/types/todo/social/getNotifications' +import * as GetNotifications from '../../third-party/api/src/types/app/bsky/getNotifications' import {RootStoreModel} from './root-store' import {hasProp} from '../lib/type-guards' @@ -228,7 +228,7 @@ export class NotificationsViewModel { private async _initialLoad(isRefreshing = false) { this._xLoading(isRefreshing) try { - const res = await this.rootStore.api.todo.social.getNotifications( + const res = await this.rootStore.api.app.bsky.getNotifications( this.params, ) this._replaceAll(res) @@ -244,7 +244,7 @@ export class NotificationsViewModel { const params = Object.assign({}, this.params, { before: this.loadMoreCursor, }) - const res = await this.rootStore.api.todo.social.getNotifications(params) + const res = await this.rootStore.api.app.bsky.getNotifications(params) this._appendAll(res) this._xIdle() } catch (e: any) { @@ -259,7 +259,7 @@ export class NotificationsViewModel { try { do { const res: GetNotifications.Response = - await this.rootStore.api.todo.social.getNotifications({ + await this.rootStore.api.app.bsky.getNotifications({ before: cursor, limit: Math.min(numToFetch, 100), }) @@ -312,7 +312,7 @@ export class NotificationsViewModel { private async _updateReadState() { try { - await this.rootStore.api.todo.social.postNotificationsSeen( + await this.rootStore.api.app.bsky.postNotificationsSeen( {}, {seenAt: new Date().toISOString()}, ) diff --git a/src/state/models/post-thread-view.ts b/src/state/models/post-thread-view.ts index 4fb9e75f6..e10a43c43 100644 --- a/src/state/models/post-thread-view.ts +++ b/src/state/models/post-thread-view.ts @@ -1,5 +1,5 @@ import {makeAutoObservable, runInAction} from 'mobx' -import * as GetPostThread from '../../third-party/api/src/types/todo/social/getPostThread' +import * as GetPostThread from '../../third-party/api/src/types/app/bsky/getPostThread' import {AdxUri} from '../../third-party/uri' import _omit from 'lodash.omit' import {RootStoreModel} from './root-store' @@ -238,7 +238,7 @@ export class PostThreadViewModel { private async _load(isRefreshing = false) { this._xLoading(isRefreshing) try { - const res = await this.rootStore.api.todo.social.getPostThread( + const res = await this.rootStore.api.app.bsky.getPostThread( Object.assign({}, this.params, {uri: this.resolvedUri}), ) this._replaceAll(res) diff --git a/src/state/models/post.ts b/src/state/models/post.ts index 73708311f..3f7e9b3cf 100644 --- a/src/state/models/post.ts +++ b/src/state/models/post.ts @@ -1,5 +1,5 @@ import {makeAutoObservable} from 'mobx' -import * as Post from '../../third-party/api/src/types/todo/social/post' +import * as Post from '../../third-party/api/src/types/app/bsky/post' import {AdxUri} from '../../third-party/uri' import {RootStoreModel} from './root-store' @@ -77,7 +77,7 @@ export class PostModel implements RemoveIndex<Post.Record> { this._xLoading() try { const urip = new AdxUri(this.uri) - const res = await this.rootStore.api.todo.social.post.get({ + const res = await this.rootStore.api.app.bsky.post.get({ nameOrDid: urip.host, tid: urip.recordKey, }) diff --git a/src/state/models/profile-view.ts b/src/state/models/profile-view.ts index aa0040d65..db7fe407a 100644 --- a/src/state/models/profile-view.ts +++ b/src/state/models/profile-view.ts @@ -1,6 +1,6 @@ import {makeAutoObservable, runInAction} from 'mobx' -import * as GetProfile from '../../third-party/api/src/types/todo/social/getProfile' -import * as Profile from '../../third-party/api/src/types/todo/social/profile' +import * as GetProfile from '../../third-party/api/src/types/app/bsky/getProfile' +import * as Profile from '../../third-party/api/src/types/app/bsky/profile' import {RootStoreModel} from './root-store' import * as apilib from '../lib/api' @@ -118,7 +118,7 @@ export class ProfileViewModel { private async _load(isRefreshing = false) { this._xLoading(isRefreshing) try { - const res = await this.rootStore.api.todo.social.getProfile(this.params) + const res = await this.rootStore.api.app.bsky.getProfile(this.params) this._replaceAll(res) this._xIdle() } catch (e: any) { diff --git a/src/state/models/reposted-by-view.ts b/src/state/models/reposted-by-view.ts index 9b5b2ff51..2c8dcc17b 100644 --- a/src/state/models/reposted-by-view.ts +++ b/src/state/models/reposted-by-view.ts @@ -1,6 +1,6 @@ import {makeAutoObservable, runInAction} from 'mobx' import {AdxUri} from '../../third-party/uri' -import * as GetRepostedBy from '../../third-party/api/src/types/todo/social/getRepostedBy' +import * as GetRepostedBy from '../../third-party/api/src/types/app/bsky/getRepostedBy' import {RootStoreModel} from './root-store' type RepostedByItem = GetRepostedBy.OutputSchema['repostedBy'][number] @@ -113,7 +113,7 @@ export class RepostedByViewModel { private async _fetch(isRefreshing = false) { this._xLoading(isRefreshing) try { - const res = await this.rootStore.api.todo.social.getRepostedBy( + const res = await this.rootStore.api.app.bsky.getRepostedBy( Object.assign({}, this.params, {uri: this.resolvedUri}), ) this._replaceAll(res) diff --git a/src/state/models/root-store.ts b/src/state/models/root-store.ts index a6ef28166..1dc22fc2c 100644 --- a/src/state/models/root-store.ts +++ b/src/state/models/root-store.ts @@ -34,7 +34,7 @@ export class RootStoreModel { if (didOrName.startsWith('did:')) { return didOrName } - const res = await this.api.todo.adx.resolveName({name: didOrName}) + const res = await this.api.com.atproto.resolveName({name: didOrName}) return res.data.did } diff --git a/src/state/models/session.ts b/src/state/models/session.ts index ced7ceeb0..32d233315 100644 --- a/src/state/models/session.ts +++ b/src/state/models/session.ts @@ -1,6 +1,6 @@ import {makeAutoObservable} from 'mobx' import AdxApi from '../../third-party/api' -import type * as GetAccountsConfig from '../../third-party/api/src/types/todo/adx/getAccountsConfig' +import type * as GetAccountsConfig from '../../third-party/api/src/types/com/atproto/getAccountsConfig' import {isObj, hasProp} from '../lib/type-guards' import {RootStoreModel} from './root-store' @@ -122,7 +122,7 @@ export class SessionModel { } try { - const sess = await this.rootStore.api.todo.adx.getSession({}) + const sess = await this.rootStore.api.com.atproto.getSession({}) if (sess.success && this.data && this.data.userdid === sess.data.did) { this.rootStore.me.load().catch(e => { console.error('Failed to fetch local user information', e) @@ -136,7 +136,7 @@ export class SessionModel { async describeService(service: string): Promise<ServiceDescription> { const api = AdxApi.service(service) - const res = await api.todo.adx.getAccountsConfig({}) + const res = await api.com.atproto.getAccountsConfig({}) return res.data } @@ -150,7 +150,7 @@ export class SessionModel { password: string }) { const api = AdxApi.service(service) - const res = await api.todo.adx.createSession({}, {username, password}) + const res = await api.com.atproto.createSession({}, {username, password}) if (res.data.jwt) { this.setState({ service: service, @@ -179,7 +179,7 @@ export class SessionModel { inviteCode?: string }) { const api = AdxApi.service(service) - const res = await api.todo.adx.createAccount( + const res = await api.com.atproto.createAccount( {}, {username, password, email, inviteCode}, ) @@ -200,7 +200,7 @@ export class SessionModel { async logout() { if (this.isAuthed) { - this.rootStore.api.todo.adx.deleteSession({}).catch((e: any) => { + this.rootStore.api.com.atproto.deleteSession({}).catch((e: any) => { console.error('(Minor issue) Failed to delete session on the server', e) }) } diff --git a/src/state/models/user-followers-view.ts b/src/state/models/user-followers-view.ts index 21244c5c4..9ec5a42a6 100644 --- a/src/state/models/user-followers-view.ts +++ b/src/state/models/user-followers-view.ts @@ -1,5 +1,5 @@ import {makeAutoObservable} from 'mobx' -import * as GetUserFollowers from '../../third-party/api/src/types/todo/social/getUserFollowers' +import * as GetUserFollowers from '../../third-party/api/src/types/app/bsky/getUserFollowers' import {RootStoreModel} from './root-store' type Subject = GetUserFollowers.OutputSchema['subject'] @@ -82,7 +82,7 @@ export class UserFollowersViewModel { private async _fetch(isRefreshing = false) { this._xLoading(isRefreshing) try { - const res = await this.rootStore.api.todo.social.getUserFollowers( + const res = await this.rootStore.api.app.bsky.getUserFollowers( this.params, ) this._replaceAll(res) diff --git a/src/state/models/user-follows-view.ts b/src/state/models/user-follows-view.ts index d92effc0c..92f9b4bc4 100644 --- a/src/state/models/user-follows-view.ts +++ b/src/state/models/user-follows-view.ts @@ -1,5 +1,5 @@ import {makeAutoObservable} from 'mobx' -import * as GetUserFollows from '../../third-party/api/src/types/todo/social/getUserFollows' +import * as GetUserFollows from '../../third-party/api/src/types/app/bsky/getUserFollows' import {RootStoreModel} from './root-store' type Subject = GetUserFollows.OutputSchema['subject'] @@ -83,9 +83,7 @@ export class UserFollowsViewModel { private async _fetch(isRefreshing = false) { this._xLoading(isRefreshing) try { - const res = await this.rootStore.api.todo.social.getUserFollows( - this.params, - ) + const res = await this.rootStore.api.app.bsky.getUserFollows(this.params) this._replaceAll(res) this._xIdle() } catch (e: any) { |