Update to new get*Feed xrpc methods
parent
236c908058
commit
5631c2d2e6
|
@ -1,9 +1,10 @@
|
|||
import {makeAutoObservable, runInAction} from 'mobx'
|
||||
import * as GetFeedView from '../../third-party/api/src/types/todo/social/getFeed'
|
||||
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 {RootStoreModel} from './root-store'
|
||||
import * as apilib from '../lib/api'
|
||||
|
||||
export class FeedViewItemMyStateModel {
|
||||
export class FeedItemMyStateModel {
|
||||
repost?: string
|
||||
like?: string
|
||||
|
||||
|
@ -12,37 +13,37 @@ export class FeedViewItemMyStateModel {
|
|||
}
|
||||
}
|
||||
|
||||
export class FeedViewItemModel implements GetFeedView.FeedItem {
|
||||
export class FeedItemModel implements GetHomeFeed.FeedItem {
|
||||
// ui state
|
||||
_reactKey: string = ''
|
||||
|
||||
// data
|
||||
cursor: string = ''
|
||||
uri: string = ''
|
||||
author: GetFeedView.User = {did: '', name: '', displayName: ''}
|
||||
repostedBy?: GetFeedView.User
|
||||
author: GetHomeFeed.User = {did: '', name: '', displayName: ''}
|
||||
repostedBy?: GetHomeFeed.User
|
||||
record: Record<string, unknown> = {}
|
||||
embed?:
|
||||
| GetFeedView.RecordEmbed
|
||||
| GetFeedView.ExternalEmbed
|
||||
| GetFeedView.UnknownEmbed
|
||||
| GetHomeFeed.RecordEmbed
|
||||
| GetHomeFeed.ExternalEmbed
|
||||
| GetHomeFeed.UnknownEmbed
|
||||
replyCount: number = 0
|
||||
repostCount: number = 0
|
||||
likeCount: number = 0
|
||||
indexedAt: string = ''
|
||||
myState = new FeedViewItemMyStateModel()
|
||||
myState = new FeedItemMyStateModel()
|
||||
|
||||
constructor(
|
||||
public rootStore: RootStoreModel,
|
||||
reactKey: string,
|
||||
v: GetFeedView.FeedItem,
|
||||
v: GetHomeFeed.FeedItem,
|
||||
) {
|
||||
makeAutoObservable(this, {rootStore: false})
|
||||
this._reactKey = reactKey
|
||||
this.copy(v)
|
||||
}
|
||||
|
||||
copy(v: GetFeedView.FeedItem) {
|
||||
copy(v: GetHomeFeed.FeedItem) {
|
||||
this.cursor = v.cursor
|
||||
this.uri = v.uri
|
||||
this.author = v.author
|
||||
|
@ -92,25 +93,26 @@ export class FeedViewItemModel implements GetFeedView.FeedItem {
|
|||
}
|
||||
}
|
||||
|
||||
export class FeedViewModel {
|
||||
export class FeedModel {
|
||||
// state
|
||||
isLoading = false
|
||||
isRefreshing = false
|
||||
hasLoaded = false
|
||||
hasReachedEnd = false
|
||||
error = ''
|
||||
params: GetFeedView.QueryParams
|
||||
params: GetHomeFeed.QueryParams | GetAuthorFeed.QueryParams
|
||||
_loadPromise: Promise<void> | undefined
|
||||
_loadMorePromise: Promise<void> | undefined
|
||||
_loadLatestPromise: Promise<void> | undefined
|
||||
_updatePromise: Promise<void> | undefined
|
||||
|
||||
// data
|
||||
feed: FeedViewItemModel[] = []
|
||||
feed: FeedItemModel[] = []
|
||||
|
||||
constructor(
|
||||
public rootStore: RootStoreModel,
|
||||
params: GetFeedView.QueryParams,
|
||||
public feedType: 'home' | 'author',
|
||||
params: GetHomeFeed.QueryParams | GetAuthorFeed.QueryParams,
|
||||
) {
|
||||
makeAutoObservable(
|
||||
this,
|
||||
|
@ -245,7 +247,7 @@ export class FeedViewModel {
|
|||
private async _initialLoad(isRefreshing = false) {
|
||||
this._xLoading(isRefreshing)
|
||||
try {
|
||||
const res = await this.rootStore.api.todo.social.getFeed(this.params)
|
||||
const res = await this._getFeed()
|
||||
this._replaceAll(res)
|
||||
this._xIdle()
|
||||
} catch (e: any) {
|
||||
|
@ -256,7 +258,7 @@ export class FeedViewModel {
|
|||
private async _loadLatest() {
|
||||
this._xLoading()
|
||||
try {
|
||||
const res = await this.rootStore.api.todo.social.getFeed(this.params)
|
||||
const res = await this._getFeed()
|
||||
this._prependAll(res)
|
||||
this._xIdle()
|
||||
} catch (e: any) {
|
||||
|
@ -267,10 +269,9 @@ export class FeedViewModel {
|
|||
private async _loadMore() {
|
||||
this._xLoading()
|
||||
try {
|
||||
const params = Object.assign({}, this.params, {
|
||||
const res = await this._getFeed({
|
||||
before: this.loadMoreCursor,
|
||||
})
|
||||
const res = await this.rootStore.api.todo.social.getFeed(params)
|
||||
if (res.data.feed.length === 0) {
|
||||
runInAction(() => {
|
||||
this.hasReachedEnd = true
|
||||
|
@ -290,8 +291,7 @@ export class FeedViewModel {
|
|||
let cursor = undefined
|
||||
try {
|
||||
do {
|
||||
const res: GetFeedView.Response =
|
||||
await this.rootStore.api.todo.social.getFeed({
|
||||
const res: GetHomeFeed.Response = await this._getFeed({
|
||||
before: cursor,
|
||||
limit: Math.min(numToFetch, 100),
|
||||
})
|
||||
|
@ -309,25 +309,25 @@ export class FeedViewModel {
|
|||
}
|
||||
}
|
||||
|
||||
private _replaceAll(res: GetFeedView.Response) {
|
||||
private _replaceAll(res: GetHomeFeed.Response) {
|
||||
this.feed.length = 0
|
||||
this.hasReachedEnd = false
|
||||
this._appendAll(res)
|
||||
}
|
||||
|
||||
private _appendAll(res: GetFeedView.Response) {
|
||||
private _appendAll(res: GetHomeFeed.Response) {
|
||||
let counter = this.feed.length
|
||||
for (const item of res.data.feed) {
|
||||
this._append(counter++, item)
|
||||
}
|
||||
}
|
||||
|
||||
private _append(keyId: number, item: GetFeedView.FeedItem) {
|
||||
private _append(keyId: number, item: GetHomeFeed.FeedItem) {
|
||||
// TODO: validate .record
|
||||
this.feed.push(new FeedViewItemModel(this.rootStore, `item-${keyId}`, item))
|
||||
this.feed.push(new FeedItemModel(this.rootStore, `item-${keyId}`, item))
|
||||
}
|
||||
|
||||
private _prependAll(res: GetFeedView.Response) {
|
||||
private _prependAll(res: GetHomeFeed.Response) {
|
||||
let counter = this.feed.length
|
||||
for (const item of res.data.feed) {
|
||||
if (this.feed.find(item2 => item2.uri === item.uri)) {
|
||||
|
@ -337,14 +337,12 @@ export class FeedViewModel {
|
|||
}
|
||||
}
|
||||
|
||||
private _prepend(keyId: number, item: GetFeedView.FeedItem) {
|
||||
private _prepend(keyId: number, item: GetHomeFeed.FeedItem) {
|
||||
// TODO: validate .record
|
||||
this.feed.unshift(
|
||||
new FeedViewItemModel(this.rootStore, `item-${keyId}`, item),
|
||||
)
|
||||
this.feed.unshift(new FeedItemModel(this.rootStore, `item-${keyId}`, item))
|
||||
}
|
||||
|
||||
private _updateAll(res: GetFeedView.Response) {
|
||||
private _updateAll(res: GetHomeFeed.Response) {
|
||||
for (const item of res.data.feed) {
|
||||
const existingItem = this.feed.find(
|
||||
// this find function has a key subtley- the indexedAt comparison
|
||||
|
@ -357,4 +355,19 @@ export class FeedViewModel {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected _getFeed(
|
||||
params: GetHomeFeed.QueryParams | GetAuthorFeed.QueryParams = {},
|
||||
): Promise<GetHomeFeed.Response | GetAuthorFeed.Response> {
|
||||
params = Object.assign({}, this.params, params)
|
||||
if (this.feedType === 'home') {
|
||||
return this.rootStore.api.todo.social.getHomeFeed(
|
||||
params as GetHomeFeed.QueryParams,
|
||||
)
|
||||
} else {
|
||||
return this.rootStore.api.todo.social.getAuthorFeed(
|
||||
params as GetAuthorFeed.QueryParams,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {makeAutoObservable} from 'mobx'
|
||||
import {RootStoreModel} from './root-store'
|
||||
import {ProfileViewModel} from './profile-view'
|
||||
import {FeedViewModel} from './feed-view'
|
||||
import {FeedModel} from './feed-view'
|
||||
import {BadgesViewModel} from './badges-view'
|
||||
|
||||
export const SECTION_IDS = {
|
||||
|
@ -19,7 +19,7 @@ export class ProfileUiModel {
|
|||
|
||||
// data
|
||||
profile: ProfileViewModel
|
||||
feed: FeedViewModel
|
||||
feed: FeedModel
|
||||
badges: BadgesViewModel
|
||||
|
||||
// ui state
|
||||
|
@ -38,11 +38,14 @@ export class ProfileUiModel {
|
|||
{autoBind: true},
|
||||
)
|
||||
this.profile = new ProfileViewModel(rootStore, {user: params.user})
|
||||
this.feed = new FeedViewModel(rootStore, {author: params.user, limit: 10})
|
||||
this.feed = new FeedModel(rootStore, 'author', {
|
||||
author: params.user,
|
||||
limit: 10,
|
||||
})
|
||||
this.badges = new BadgesViewModel(rootStore)
|
||||
}
|
||||
|
||||
get currentView(): FeedViewModel | BadgesViewModel {
|
||||
get currentView(): FeedModel | BadgesViewModel {
|
||||
if (this.selectedViewIndex === SECTION_IDS.POSTS) {
|
||||
return this.feed
|
||||
}
|
||||
|
|
|
@ -6967,7 +6967,8 @@ __export(src_exports, {
|
|||
TodoNS: () => TodoNS,
|
||||
TodoSocialBadge: () => badge_exports,
|
||||
TodoSocialFollow: () => follow_exports,
|
||||
TodoSocialGetFeed: () => getFeed_exports,
|
||||
TodoSocialGetAuthorFeed: () => getAuthorFeed_exports,
|
||||
TodoSocialGetHomeFeed: () => getHomeFeed_exports,
|
||||
TodoSocialGetLikedBy: () => getLikedBy_exports,
|
||||
TodoSocialGetNotificationCount: () => getNotificationCount_exports,
|
||||
TodoSocialGetNotifications: () => getNotifications_exports,
|
||||
|
@ -10905,11 +10906,178 @@ var methodSchemas = [
|
|||
},
|
||||
{
|
||||
lexicon: 1,
|
||||
id: "todo.social.getFeed",
|
||||
id: "todo.social.getAuthorFeed",
|
||||
type: "query",
|
||||
description: "A computed view of the home feed or a user's feed",
|
||||
description: "A view of a user's feed",
|
||||
parameters: {
|
||||
author: {
|
||||
type: "string",
|
||||
required: true
|
||||
},
|
||||
limit: {
|
||||
type: "number",
|
||||
maximum: 100
|
||||
},
|
||||
before: {
|
||||
type: "string"
|
||||
}
|
||||
},
|
||||
output: {
|
||||
encoding: "application/json",
|
||||
schema: {
|
||||
type: "object",
|
||||
required: ["feed"],
|
||||
properties: {
|
||||
feed: {
|
||||
type: "array",
|
||||
items: {
|
||||
$ref: "#/$defs/feedItem"
|
||||
}
|
||||
}
|
||||
},
|
||||
$defs: {
|
||||
feedItem: {
|
||||
type: "object",
|
||||
required: [
|
||||
"cursor",
|
||||
"uri",
|
||||
"author",
|
||||
"record",
|
||||
"replyCount",
|
||||
"repostCount",
|
||||
"likeCount",
|
||||
"indexedAt"
|
||||
],
|
||||
properties: {
|
||||
cursor: {
|
||||
type: "string"
|
||||
},
|
||||
uri: {
|
||||
type: "string"
|
||||
},
|
||||
author: {
|
||||
$ref: "#/$defs/user"
|
||||
},
|
||||
repostedBy: {
|
||||
$ref: "#/$defs/user"
|
||||
},
|
||||
record: {
|
||||
type: "object"
|
||||
},
|
||||
embed: {
|
||||
oneOf: [
|
||||
{
|
||||
$ref: "#/$defs/recordEmbed"
|
||||
},
|
||||
{
|
||||
$ref: "#/$defs/externalEmbed"
|
||||
},
|
||||
{
|
||||
$ref: "#/$defs/unknownEmbed"
|
||||
}
|
||||
]
|
||||
},
|
||||
replyCount: {
|
||||
type: "number"
|
||||
},
|
||||
repostCount: {
|
||||
type: "number"
|
||||
},
|
||||
likeCount: {
|
||||
type: "number"
|
||||
},
|
||||
indexedAt: {
|
||||
type: "string",
|
||||
format: "date-time"
|
||||
},
|
||||
myState: {
|
||||
type: "object",
|
||||
properties: {
|
||||
repost: {
|
||||
type: "string"
|
||||
},
|
||||
like: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
user: {
|
||||
type: "object",
|
||||
required: ["did", "name"],
|
||||
properties: {
|
||||
did: {
|
||||
type: "string"
|
||||
},
|
||||
name: {
|
||||
type: "string"
|
||||
},
|
||||
displayName: {
|
||||
type: "string",
|
||||
maxLength: 64
|
||||
}
|
||||
}
|
||||
},
|
||||
recordEmbed: {
|
||||
type: "object",
|
||||
required: ["type", "author", "record"],
|
||||
properties: {
|
||||
type: {
|
||||
const: "record"
|
||||
},
|
||||
author: {
|
||||
$ref: "#/$defs/user"
|
||||
},
|
||||
record: {
|
||||
type: "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
externalEmbed: {
|
||||
type: "object",
|
||||
required: ["type", "uri", "title", "description", "imageUri"],
|
||||
properties: {
|
||||
type: {
|
||||
const: "external"
|
||||
},
|
||||
uri: {
|
||||
type: "string"
|
||||
},
|
||||
title: {
|
||||
type: "string"
|
||||
},
|
||||
description: {
|
||||
type: "string"
|
||||
},
|
||||
imageUri: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
unknownEmbed: {
|
||||
type: "object",
|
||||
required: ["type"],
|
||||
properties: {
|
||||
type: {
|
||||
type: "string",
|
||||
not: {
|
||||
enum: ["record", "external"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
lexicon: 1,
|
||||
id: "todo.social.getHomeFeed",
|
||||
type: "query",
|
||||
description: "A view of the user's home feed",
|
||||
parameters: {
|
||||
algorithm: {
|
||||
type: "string"
|
||||
},
|
||||
limit: {
|
||||
|
@ -10937,6 +11105,7 @@ var methodSchemas = [
|
|||
feedItem: {
|
||||
type: "object",
|
||||
required: [
|
||||
"cursor",
|
||||
"uri",
|
||||
"author",
|
||||
"record",
|
||||
|
@ -11939,9 +12108,9 @@ function toKnownErr18(e) {
|
|||
return e;
|
||||
}
|
||||
|
||||
// src/types/todo/social/getFeed.ts
|
||||
var getFeed_exports = {};
|
||||
__export(getFeed_exports, {
|
||||
// src/types/todo/social/getAuthorFeed.ts
|
||||
var getAuthorFeed_exports = {};
|
||||
__export(getAuthorFeed_exports, {
|
||||
toKnownErr: () => toKnownErr19
|
||||
});
|
||||
function toKnownErr19(e) {
|
||||
|
@ -11950,9 +12119,9 @@ function toKnownErr19(e) {
|
|||
return e;
|
||||
}
|
||||
|
||||
// src/types/todo/social/getLikedBy.ts
|
||||
var getLikedBy_exports = {};
|
||||
__export(getLikedBy_exports, {
|
||||
// src/types/todo/social/getHomeFeed.ts
|
||||
var getHomeFeed_exports = {};
|
||||
__export(getHomeFeed_exports, {
|
||||
toKnownErr: () => toKnownErr20
|
||||
});
|
||||
function toKnownErr20(e) {
|
||||
|
@ -11961,9 +12130,9 @@ function toKnownErr20(e) {
|
|||
return e;
|
||||
}
|
||||
|
||||
// src/types/todo/social/getNotificationCount.ts
|
||||
var getNotificationCount_exports = {};
|
||||
__export(getNotificationCount_exports, {
|
||||
// src/types/todo/social/getLikedBy.ts
|
||||
var getLikedBy_exports = {};
|
||||
__export(getLikedBy_exports, {
|
||||
toKnownErr: () => toKnownErr21
|
||||
});
|
||||
function toKnownErr21(e) {
|
||||
|
@ -11972,9 +12141,9 @@ function toKnownErr21(e) {
|
|||
return e;
|
||||
}
|
||||
|
||||
// src/types/todo/social/getNotifications.ts
|
||||
var getNotifications_exports = {};
|
||||
__export(getNotifications_exports, {
|
||||
// src/types/todo/social/getNotificationCount.ts
|
||||
var getNotificationCount_exports = {};
|
||||
__export(getNotificationCount_exports, {
|
||||
toKnownErr: () => toKnownErr22
|
||||
});
|
||||
function toKnownErr22(e) {
|
||||
|
@ -11983,9 +12152,9 @@ function toKnownErr22(e) {
|
|||
return e;
|
||||
}
|
||||
|
||||
// src/types/todo/social/getPostThread.ts
|
||||
var getPostThread_exports = {};
|
||||
__export(getPostThread_exports, {
|
||||
// src/types/todo/social/getNotifications.ts
|
||||
var getNotifications_exports = {};
|
||||
__export(getNotifications_exports, {
|
||||
toKnownErr: () => toKnownErr23
|
||||
});
|
||||
function toKnownErr23(e) {
|
||||
|
@ -11994,9 +12163,9 @@ function toKnownErr23(e) {
|
|||
return e;
|
||||
}
|
||||
|
||||
// src/types/todo/social/getProfile.ts
|
||||
var getProfile_exports = {};
|
||||
__export(getProfile_exports, {
|
||||
// src/types/todo/social/getPostThread.ts
|
||||
var getPostThread_exports = {};
|
||||
__export(getPostThread_exports, {
|
||||
toKnownErr: () => toKnownErr24
|
||||
});
|
||||
function toKnownErr24(e) {
|
||||
|
@ -12005,9 +12174,9 @@ function toKnownErr24(e) {
|
|||
return e;
|
||||
}
|
||||
|
||||
// src/types/todo/social/getRepostedBy.ts
|
||||
var getRepostedBy_exports = {};
|
||||
__export(getRepostedBy_exports, {
|
||||
// src/types/todo/social/getProfile.ts
|
||||
var getProfile_exports = {};
|
||||
__export(getProfile_exports, {
|
||||
toKnownErr: () => toKnownErr25
|
||||
});
|
||||
function toKnownErr25(e) {
|
||||
|
@ -12016,9 +12185,9 @@ function toKnownErr25(e) {
|
|||
return e;
|
||||
}
|
||||
|
||||
// src/types/todo/social/getUserFollowers.ts
|
||||
var getUserFollowers_exports = {};
|
||||
__export(getUserFollowers_exports, {
|
||||
// src/types/todo/social/getRepostedBy.ts
|
||||
var getRepostedBy_exports = {};
|
||||
__export(getRepostedBy_exports, {
|
||||
toKnownErr: () => toKnownErr26
|
||||
});
|
||||
function toKnownErr26(e) {
|
||||
|
@ -12027,9 +12196,9 @@ function toKnownErr26(e) {
|
|||
return e;
|
||||
}
|
||||
|
||||
// src/types/todo/social/getUserFollows.ts
|
||||
var getUserFollows_exports = {};
|
||||
__export(getUserFollows_exports, {
|
||||
// src/types/todo/social/getUserFollowers.ts
|
||||
var getUserFollowers_exports = {};
|
||||
__export(getUserFollowers_exports, {
|
||||
toKnownErr: () => toKnownErr27
|
||||
});
|
||||
function toKnownErr27(e) {
|
||||
|
@ -12038,9 +12207,9 @@ function toKnownErr27(e) {
|
|||
return e;
|
||||
}
|
||||
|
||||
// src/types/todo/social/postNotificationsSeen.ts
|
||||
var postNotificationsSeen_exports = {};
|
||||
__export(postNotificationsSeen_exports, {
|
||||
// src/types/todo/social/getUserFollows.ts
|
||||
var getUserFollows_exports = {};
|
||||
__export(getUserFollows_exports, {
|
||||
toKnownErr: () => toKnownErr28
|
||||
});
|
||||
function toKnownErr28(e) {
|
||||
|
@ -12049,6 +12218,17 @@ function toKnownErr28(e) {
|
|||
return e;
|
||||
}
|
||||
|
||||
// src/types/todo/social/postNotificationsSeen.ts
|
||||
var postNotificationsSeen_exports = {};
|
||||
__export(postNotificationsSeen_exports, {
|
||||
toKnownErr: () => toKnownErr29
|
||||
});
|
||||
function toKnownErr29(e) {
|
||||
if (e instanceof XRPCError) {
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
// src/types/todo/social/badge.ts
|
||||
var badge_exports = {};
|
||||
|
||||
|
@ -12205,54 +12385,59 @@ var SocialNS = class {
|
|||
this.profile = new ProfileRecord(service);
|
||||
this.repost = new RepostRecord(service);
|
||||
}
|
||||
getFeed(params, data, opts) {
|
||||
return this._service.xrpc.call("todo.social.getFeed", params, data, opts).catch((e) => {
|
||||
getAuthorFeed(params, data, opts) {
|
||||
return this._service.xrpc.call("todo.social.getAuthorFeed", params, data, opts).catch((e) => {
|
||||
throw toKnownErr19(e);
|
||||
});
|
||||
}
|
||||
getHomeFeed(params, data, opts) {
|
||||
return this._service.xrpc.call("todo.social.getHomeFeed", params, data, opts).catch((e) => {
|
||||
throw toKnownErr20(e);
|
||||
});
|
||||
}
|
||||
getLikedBy(params, data, opts) {
|
||||
return this._service.xrpc.call("todo.social.getLikedBy", params, data, opts).catch((e) => {
|
||||
throw toKnownErr20(e);
|
||||
throw toKnownErr21(e);
|
||||
});
|
||||
}
|
||||
getNotificationCount(params, data, opts) {
|
||||
return this._service.xrpc.call("todo.social.getNotificationCount", params, data, opts).catch((e) => {
|
||||
throw toKnownErr21(e);
|
||||
throw toKnownErr22(e);
|
||||
});
|
||||
}
|
||||
getNotifications(params, data, opts) {
|
||||
return this._service.xrpc.call("todo.social.getNotifications", params, data, opts).catch((e) => {
|
||||
throw toKnownErr22(e);
|
||||
throw toKnownErr23(e);
|
||||
});
|
||||
}
|
||||
getPostThread(params, data, opts) {
|
||||
return this._service.xrpc.call("todo.social.getPostThread", params, data, opts).catch((e) => {
|
||||
throw toKnownErr23(e);
|
||||
throw toKnownErr24(e);
|
||||
});
|
||||
}
|
||||
getProfile(params, data, opts) {
|
||||
return this._service.xrpc.call("todo.social.getProfile", params, data, opts).catch((e) => {
|
||||
throw toKnownErr24(e);
|
||||
throw toKnownErr25(e);
|
||||
});
|
||||
}
|
||||
getRepostedBy(params, data, opts) {
|
||||
return this._service.xrpc.call("todo.social.getRepostedBy", params, data, opts).catch((e) => {
|
||||
throw toKnownErr25(e);
|
||||
throw toKnownErr26(e);
|
||||
});
|
||||
}
|
||||
getUserFollowers(params, data, opts) {
|
||||
return this._service.xrpc.call("todo.social.getUserFollowers", params, data, opts).catch((e) => {
|
||||
throw toKnownErr26(e);
|
||||
throw toKnownErr27(e);
|
||||
});
|
||||
}
|
||||
getUserFollows(params, data, opts) {
|
||||
return this._service.xrpc.call("todo.social.getUserFollows", params, data, opts).catch((e) => {
|
||||
throw toKnownErr27(e);
|
||||
throw toKnownErr28(e);
|
||||
});
|
||||
}
|
||||
postNotificationsSeen(params, data, opts) {
|
||||
return this._service.xrpc.call("todo.social.postNotificationsSeen", params, data, opts).catch((e) => {
|
||||
throw toKnownErr28(e);
|
||||
throw toKnownErr29(e);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -12619,7 +12804,8 @@ var RepostRecord = class {
|
|||
TodoNS,
|
||||
TodoSocialBadge,
|
||||
TodoSocialFollow,
|
||||
TodoSocialGetFeed,
|
||||
TodoSocialGetAuthorFeed,
|
||||
TodoSocialGetHomeFeed,
|
||||
TodoSocialGetLikedBy,
|
||||
TodoSocialGetNotificationCount,
|
||||
TodoSocialGetNotifications,
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -19,7 +19,8 @@ import * as TodoAdxSyncGetRoot from './types/todo/adx/syncGetRoot';
|
|||
import * as TodoAdxSyncUpdateRepo from './types/todo/adx/syncUpdateRepo';
|
||||
import * as TodoSocialBadge from './types/todo/social/badge';
|
||||
import * as TodoSocialFollow from './types/todo/social/follow';
|
||||
import * as TodoSocialGetFeed from './types/todo/social/getFeed';
|
||||
import * as TodoSocialGetAuthorFeed from './types/todo/social/getAuthorFeed';
|
||||
import * as TodoSocialGetHomeFeed from './types/todo/social/getHomeFeed';
|
||||
import * as TodoSocialGetLikedBy from './types/todo/social/getLikedBy';
|
||||
import * as TodoSocialGetNotificationCount from './types/todo/social/getNotificationCount';
|
||||
import * as TodoSocialGetNotifications from './types/todo/social/getNotifications';
|
||||
|
@ -54,7 +55,8 @@ export * as TodoAdxSyncGetRoot from './types/todo/adx/syncGetRoot';
|
|||
export * as TodoAdxSyncUpdateRepo from './types/todo/adx/syncUpdateRepo';
|
||||
export * as TodoSocialBadge from './types/todo/social/badge';
|
||||
export * as TodoSocialFollow from './types/todo/social/follow';
|
||||
export * as TodoSocialGetFeed from './types/todo/social/getFeed';
|
||||
export * as TodoSocialGetAuthorFeed from './types/todo/social/getAuthorFeed';
|
||||
export * as TodoSocialGetHomeFeed from './types/todo/social/getHomeFeed';
|
||||
export * as TodoSocialGetLikedBy from './types/todo/social/getLikedBy';
|
||||
export * as TodoSocialGetNotificationCount from './types/todo/social/getNotificationCount';
|
||||
export * as TodoSocialGetNotifications from './types/todo/social/getNotifications';
|
||||
|
@ -121,7 +123,8 @@ export declare class SocialNS {
|
|||
profile: ProfileRecord;
|
||||
repost: RepostRecord;
|
||||
constructor(service: ServiceClient);
|
||||
getFeed(params: TodoSocialGetFeed.QueryParams, data?: TodoSocialGetFeed.InputSchema, opts?: TodoSocialGetFeed.CallOptions): Promise<TodoSocialGetFeed.Response>;
|
||||
getAuthorFeed(params: TodoSocialGetAuthorFeed.QueryParams, data?: TodoSocialGetAuthorFeed.InputSchema, opts?: TodoSocialGetAuthorFeed.CallOptions): Promise<TodoSocialGetAuthorFeed.Response>;
|
||||
getHomeFeed(params: TodoSocialGetHomeFeed.QueryParams, data?: TodoSocialGetHomeFeed.InputSchema, opts?: TodoSocialGetHomeFeed.CallOptions): Promise<TodoSocialGetHomeFeed.Response>;
|
||||
getLikedBy(params: TodoSocialGetLikedBy.QueryParams, data?: TodoSocialGetLikedBy.InputSchema, opts?: TodoSocialGetLikedBy.CallOptions): Promise<TodoSocialGetLikedBy.Response>;
|
||||
getNotificationCount(params: TodoSocialGetNotificationCount.QueryParams, data?: TodoSocialGetNotificationCount.InputSchema, opts?: TodoSocialGetNotificationCount.CallOptions): Promise<TodoSocialGetNotificationCount.Response>;
|
||||
getNotifications(params: TodoSocialGetNotifications.QueryParams, data?: TodoSocialGetNotifications.InputSchema, opts?: TodoSocialGetNotifications.CallOptions): Promise<TodoSocialGetNotifications.Response>;
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
import { Headers } from '@adxp/xrpc';
|
||||
export interface QueryParams {
|
||||
author: string;
|
||||
limit?: number;
|
||||
before?: string;
|
||||
}
|
||||
export interface CallOptions {
|
||||
headers?: Headers;
|
||||
}
|
||||
export declare type InputSchema = undefined;
|
||||
export interface OutputSchema {
|
||||
feed: FeedItem[];
|
||||
}
|
||||
export interface FeedItem {
|
||||
cursor: string;
|
||||
uri: string;
|
||||
author: User;
|
||||
repostedBy?: User;
|
||||
record: {};
|
||||
embed?: RecordEmbed | ExternalEmbed | UnknownEmbed;
|
||||
replyCount: number;
|
||||
repostCount: number;
|
||||
likeCount: number;
|
||||
indexedAt: string;
|
||||
myState?: {
|
||||
repost?: string;
|
||||
like?: string;
|
||||
};
|
||||
}
|
||||
export interface User {
|
||||
did: string;
|
||||
name: string;
|
||||
displayName?: string;
|
||||
}
|
||||
export interface RecordEmbed {
|
||||
type: 'record';
|
||||
author: User;
|
||||
record: {};
|
||||
}
|
||||
export interface ExternalEmbed {
|
||||
type: 'external';
|
||||
uri: string;
|
||||
title: string;
|
||||
description: string;
|
||||
imageUri: string;
|
||||
}
|
||||
export interface UnknownEmbed {
|
||||
type: string;
|
||||
}
|
||||
export interface Response {
|
||||
success: boolean;
|
||||
headers: Headers;
|
||||
data: OutputSchema;
|
||||
}
|
||||
export declare function toKnownErr(e: any): any;
|
|
@ -0,0 +1,55 @@
|
|||
import { Headers } from '@adxp/xrpc';
|
||||
export interface QueryParams {
|
||||
algorithm?: string;
|
||||
limit?: number;
|
||||
before?: string;
|
||||
}
|
||||
export interface CallOptions {
|
||||
headers?: Headers;
|
||||
}
|
||||
export declare type InputSchema = undefined;
|
||||
export interface OutputSchema {
|
||||
feed: FeedItem[];
|
||||
}
|
||||
export interface FeedItem {
|
||||
cursor: string;
|
||||
uri: string;
|
||||
author: User;
|
||||
repostedBy?: User;
|
||||
record: {};
|
||||
embed?: RecordEmbed | ExternalEmbed | UnknownEmbed;
|
||||
replyCount: number;
|
||||
repostCount: number;
|
||||
likeCount: number;
|
||||
indexedAt: string;
|
||||
myState?: {
|
||||
repost?: string;
|
||||
like?: string;
|
||||
};
|
||||
}
|
||||
export interface User {
|
||||
did: string;
|
||||
name: string;
|
||||
displayName?: string;
|
||||
}
|
||||
export interface RecordEmbed {
|
||||
type: 'record';
|
||||
author: User;
|
||||
record: {};
|
||||
}
|
||||
export interface ExternalEmbed {
|
||||
type: 'external';
|
||||
uri: string;
|
||||
title: string;
|
||||
description: string;
|
||||
imageUri: string;
|
||||
}
|
||||
export interface UnknownEmbed {
|
||||
type: string;
|
||||
}
|
||||
export interface Response {
|
||||
success: boolean;
|
||||
headers: Headers;
|
||||
data: OutputSchema;
|
||||
}
|
||||
export declare function toKnownErr(e: any): any;
|
File diff suppressed because one or more lines are too long
|
@ -4,14 +4,14 @@ import {observer} from 'mobx-react-lite'
|
|||
import {Feed} from '../com/posts/Feed'
|
||||
import {FAB} from '../com/util/FloatingActionButton'
|
||||
import {useStores} from '../../state'
|
||||
import {FeedViewModel} from '../../state/models/feed-view'
|
||||
import {FeedModel} from '../../state/models/feed-view'
|
||||
import {ComposePostModel} from '../../state/models/shell'
|
||||
import {ScreenParams} from '../routes'
|
||||
import {s} from '../lib/styles'
|
||||
|
||||
export const Home = observer(function Home({visible}: ScreenParams) {
|
||||
const [hasSetup, setHasSetup] = useState<boolean>(false)
|
||||
const [feedView, setFeedView] = useState<FeedViewModel | undefined>()
|
||||
const [feedView, setFeedView] = useState<FeedModel | undefined>()
|
||||
const store = useStores()
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -24,7 +24,7 @@ export const Home = observer(function Home({visible}: ScreenParams) {
|
|||
} else {
|
||||
store.nav.setTitle('Home')
|
||||
console.log('Fetching home feed')
|
||||
const newFeedView = new FeedViewModel(store, {})
|
||||
const newFeedView = new FeedModel(store, 'home', {})
|
||||
setFeedView(newFeedView)
|
||||
newFeedView.setup().then(() => setHasSetup(true))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue