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