Improve handling of deleted posts
parent
bf7b0be23d
commit
88c868dd80
|
@ -1,5 +1,5 @@
|
||||||
import {makeAutoObservable, runInAction} from 'mobx'
|
import {makeAutoObservable, runInAction} from 'mobx'
|
||||||
import * as GetPostThread from '../../third-party/api/src/client/types/app/bsky/feed/getPostThread'
|
import {AppBskyFeedGetPostThread as GetPostThread} from '../../third-party/api'
|
||||||
import {AtUri} from '../../third-party/uri'
|
import {AtUri} from '../../third-party/uri'
|
||||||
import _omit from 'lodash.omit'
|
import _omit from 'lodash.omit'
|
||||||
import {RootStoreModel} from './root-store'
|
import {RootStoreModel} from './root-store'
|
||||||
|
@ -216,6 +216,7 @@ export class PostThreadViewModel {
|
||||||
isRefreshing = false
|
isRefreshing = false
|
||||||
hasLoaded = false
|
hasLoaded = false
|
||||||
error = ''
|
error = ''
|
||||||
|
notFound = false
|
||||||
resolvedUri = ''
|
resolvedUri = ''
|
||||||
params: GetPostThread.QueryParams
|
params: GetPostThread.QueryParams
|
||||||
|
|
||||||
|
@ -286,13 +287,15 @@ export class PostThreadViewModel {
|
||||||
this.isLoading = true
|
this.isLoading = true
|
||||||
this.isRefreshing = isRefreshing
|
this.isRefreshing = isRefreshing
|
||||||
this.error = ''
|
this.error = ''
|
||||||
|
this.notFound = false
|
||||||
}
|
}
|
||||||
|
|
||||||
private _xIdle(err: string = '') {
|
private _xIdle(err: any = undefined) {
|
||||||
this.isLoading = false
|
this.isLoading = false
|
||||||
this.isRefreshing = false
|
this.isRefreshing = false
|
||||||
this.hasLoaded = true
|
this.hasLoaded = true
|
||||||
this.error = err
|
this.error = err ? err.toString() : ''
|
||||||
|
this.notFound = err instanceof GetPostThread.NotFoundError
|
||||||
}
|
}
|
||||||
|
|
||||||
// loader functions
|
// loader functions
|
||||||
|
@ -317,7 +320,7 @@ export class PostThreadViewModel {
|
||||||
this._replaceAll(res)
|
this._replaceAll(res)
|
||||||
this._xIdle()
|
this._xIdle()
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
this._xIdle(`Failed to load thread: ${e.toString()}`)
|
this._xIdle(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10424,7 +10424,7 @@ var methodSchemaDict = {
|
||||||
required: ["useCount"],
|
required: ["useCount"],
|
||||||
properties: {
|
properties: {
|
||||||
useCount: {
|
useCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
$defs: {}
|
$defs: {}
|
||||||
|
@ -10841,7 +10841,7 @@ var methodSchemaDict = {
|
||||||
description: "The NSID of the record type."
|
description: "The NSID of the record type."
|
||||||
},
|
},
|
||||||
limit: {
|
limit: {
|
||||||
type: "number",
|
type: "integer",
|
||||||
minimum: 1,
|
minimum: 1,
|
||||||
default: 50,
|
default: 50,
|
||||||
description: "The number of records to return. TODO-max number?"
|
description: "The number of records to return. TODO-max number?"
|
||||||
|
@ -11306,16 +11306,16 @@ var methodSchemaDict = {
|
||||||
maxLength: 256
|
maxLength: 256
|
||||||
},
|
},
|
||||||
followersCount: {
|
followersCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
followsCount: {
|
followsCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
membersCount: {
|
membersCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
postsCount: {
|
postsCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
myState: {
|
myState: {
|
||||||
type: "object",
|
type: "object",
|
||||||
|
@ -11403,7 +11403,7 @@ var methodSchemaDict = {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: {
|
properties: {
|
||||||
limit: {
|
limit: {
|
||||||
type: "number",
|
type: "integer",
|
||||||
maximum: 100
|
maximum: 100
|
||||||
},
|
},
|
||||||
cursor: {
|
cursor: {
|
||||||
|
@ -11536,7 +11536,7 @@ var methodSchemaDict = {
|
||||||
type: "string"
|
type: "string"
|
||||||
},
|
},
|
||||||
limit: {
|
limit: {
|
||||||
type: "number",
|
type: "integer",
|
||||||
maximum: 100
|
maximum: 100
|
||||||
},
|
},
|
||||||
before: {
|
before: {
|
||||||
|
@ -11661,7 +11661,7 @@ var methodSchemaDict = {
|
||||||
type: "string"
|
type: "string"
|
||||||
},
|
},
|
||||||
limit: {
|
limit: {
|
||||||
type: "number",
|
type: "integer",
|
||||||
maximum: 100
|
maximum: 100
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11818,7 +11818,7 @@ var methodSchemaDict = {
|
||||||
type: "string"
|
type: "string"
|
||||||
},
|
},
|
||||||
limit: {
|
limit: {
|
||||||
type: "number",
|
type: "integer",
|
||||||
maximum: 100
|
maximum: 100
|
||||||
},
|
},
|
||||||
before: {
|
before: {
|
||||||
|
@ -11889,16 +11889,16 @@ var methodSchemaDict = {
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
replyCount: {
|
replyCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
repostCount: {
|
repostCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
upvoteCount: {
|
upvoteCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
downvoteCount: {
|
downvoteCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
indexedAt: {
|
indexedAt: {
|
||||||
type: "string",
|
type: "string",
|
||||||
|
@ -12066,16 +12066,16 @@ var methodSchemaDict = {
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
replyCount: {
|
replyCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
repostCount: {
|
repostCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
upvoteCount: {
|
upvoteCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
downvoteCount: {
|
downvoteCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
indexedAt: {
|
indexedAt: {
|
||||||
type: "string",
|
type: "string",
|
||||||
|
@ -12207,7 +12207,7 @@ var methodSchemaDict = {
|
||||||
type: "string"
|
type: "string"
|
||||||
},
|
},
|
||||||
depth: {
|
depth: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -12265,7 +12265,7 @@ var methodSchemaDict = {
|
||||||
$ref: "#/$defs/post"
|
$ref: "#/$defs/post"
|
||||||
},
|
},
|
||||||
replyCount: {
|
replyCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
replies: {
|
replies: {
|
||||||
type: "array",
|
type: "array",
|
||||||
|
@ -12274,13 +12274,13 @@ var methodSchemaDict = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
repostCount: {
|
repostCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
upvoteCount: {
|
upvoteCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
downvoteCount: {
|
downvoteCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
indexedAt: {
|
indexedAt: {
|
||||||
type: "string",
|
type: "string",
|
||||||
|
@ -12445,7 +12445,7 @@ var methodSchemaDict = {
|
||||||
$ref: "#/$defs/post"
|
$ref: "#/$defs/post"
|
||||||
},
|
},
|
||||||
replyCount: {
|
replyCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
replies: {
|
replies: {
|
||||||
type: "array",
|
type: "array",
|
||||||
|
@ -12454,13 +12454,13 @@ var methodSchemaDict = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
repostCount: {
|
repostCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
upvoteCount: {
|
upvoteCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
downvoteCount: {
|
downvoteCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
indexedAt: {
|
indexedAt: {
|
||||||
type: "string",
|
type: "string",
|
||||||
|
@ -12578,7 +12578,12 @@ var methodSchemaDict = {
|
||||||
enum: ["app.bsky.system.actorUser", "app.bsky.system.actorScene"]
|
enum: ["app.bsky.system.actorUser", "app.bsky.system.actorScene"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
errors: [
|
||||||
|
{
|
||||||
|
name: "NotFound"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"app.bsky.feed.getRepostedBy": {
|
"app.bsky.feed.getRepostedBy": {
|
||||||
lexicon: 1,
|
lexicon: 1,
|
||||||
|
@ -12595,7 +12600,7 @@ var methodSchemaDict = {
|
||||||
type: "string"
|
type: "string"
|
||||||
},
|
},
|
||||||
limit: {
|
limit: {
|
||||||
type: "number",
|
type: "integer",
|
||||||
maximum: 100
|
maximum: 100
|
||||||
},
|
},
|
||||||
before: {
|
before: {
|
||||||
|
@ -12726,7 +12731,7 @@ var methodSchemaDict = {
|
||||||
type: "string"
|
type: "string"
|
||||||
},
|
},
|
||||||
limit: {
|
limit: {
|
||||||
type: "number",
|
type: "integer",
|
||||||
maximum: 100
|
maximum: 100
|
||||||
},
|
},
|
||||||
before: {
|
before: {
|
||||||
|
@ -12797,16 +12802,16 @@ var methodSchemaDict = {
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
replyCount: {
|
replyCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
repostCount: {
|
repostCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
upvoteCount: {
|
upvoteCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
downvoteCount: {
|
downvoteCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
indexedAt: {
|
indexedAt: {
|
||||||
type: "string",
|
type: "string",
|
||||||
|
@ -12977,16 +12982,16 @@ var methodSchemaDict = {
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
replyCount: {
|
replyCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
repostCount: {
|
repostCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
upvoteCount: {
|
upvoteCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
downvoteCount: {
|
downvoteCount: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
},
|
},
|
||||||
indexedAt: {
|
indexedAt: {
|
||||||
type: "string",
|
type: "string",
|
||||||
|
@ -13128,7 +13133,7 @@ var methodSchemaDict = {
|
||||||
enum: ["up", "down"]
|
enum: ["up", "down"]
|
||||||
},
|
},
|
||||||
limit: {
|
limit: {
|
||||||
type: "number",
|
type: "integer",
|
||||||
maximum: 100
|
maximum: 100
|
||||||
},
|
},
|
||||||
before: {
|
before: {
|
||||||
|
@ -13365,7 +13370,7 @@ var methodSchemaDict = {
|
||||||
type: "boolean"
|
type: "boolean"
|
||||||
},
|
},
|
||||||
limit: {
|
limit: {
|
||||||
type: "number",
|
type: "integer",
|
||||||
maximum: 100
|
maximum: 100
|
||||||
},
|
},
|
||||||
before: {
|
before: {
|
||||||
|
@ -13582,7 +13587,7 @@ var methodSchemaDict = {
|
||||||
type: "string"
|
type: "string"
|
||||||
},
|
},
|
||||||
limit: {
|
limit: {
|
||||||
type: "number",
|
type: "integer",
|
||||||
maximum: 100
|
maximum: 100
|
||||||
},
|
},
|
||||||
before: {
|
before: {
|
||||||
|
@ -13727,7 +13732,7 @@ var methodSchemaDict = {
|
||||||
type: "string"
|
type: "string"
|
||||||
},
|
},
|
||||||
limit: {
|
limit: {
|
||||||
type: "number",
|
type: "integer",
|
||||||
maximum: 100
|
maximum: 100
|
||||||
},
|
},
|
||||||
before: {
|
before: {
|
||||||
|
@ -13872,7 +13877,7 @@ var methodSchemaDict = {
|
||||||
type: "string"
|
type: "string"
|
||||||
},
|
},
|
||||||
limit: {
|
limit: {
|
||||||
type: "number",
|
type: "integer",
|
||||||
maximum: 100
|
maximum: 100
|
||||||
},
|
},
|
||||||
before: {
|
before: {
|
||||||
|
@ -14017,7 +14022,7 @@ var methodSchemaDict = {
|
||||||
type: "string"
|
type: "string"
|
||||||
},
|
},
|
||||||
limit: {
|
limit: {
|
||||||
type: "number",
|
type: "integer",
|
||||||
maximum: 100
|
maximum: 100
|
||||||
},
|
},
|
||||||
before: {
|
before: {
|
||||||
|
@ -14160,7 +14165,7 @@ var methodSchemaDict = {
|
||||||
required: ["count"],
|
required: ["count"],
|
||||||
properties: {
|
properties: {
|
||||||
count: {
|
count: {
|
||||||
type: "number"
|
type: "integer"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
$defs: {}
|
$defs: {}
|
||||||
|
@ -14175,7 +14180,7 @@ var methodSchemaDict = {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: {
|
properties: {
|
||||||
limit: {
|
limit: {
|
||||||
type: "number",
|
type: "integer",
|
||||||
maximum: 100
|
maximum: 100
|
||||||
},
|
},
|
||||||
before: {
|
before: {
|
||||||
|
@ -14563,11 +14568,11 @@ var recordSchemaDict = {
|
||||||
required: ["start", "end"],
|
required: ["start", "end"],
|
||||||
properties: {
|
properties: {
|
||||||
start: {
|
start: {
|
||||||
type: "number",
|
type: "integer",
|
||||||
minimum: 0
|
minimum: 0
|
||||||
},
|
},
|
||||||
end: {
|
end: {
|
||||||
type: "number",
|
type: "integer",
|
||||||
minimum: 0
|
minimum: 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14620,11 +14625,11 @@ var recordSchemaDict = {
|
||||||
required: ["start", "end"],
|
required: ["start", "end"],
|
||||||
properties: {
|
properties: {
|
||||||
start: {
|
start: {
|
||||||
type: "number",
|
type: "integer",
|
||||||
minimum: 0
|
minimum: 0
|
||||||
},
|
},
|
||||||
end: {
|
end: {
|
||||||
type: "number",
|
type: "integer",
|
||||||
minimum: 0
|
minimum: 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15315,10 +15320,18 @@ function toKnownErr29(e) {
|
||||||
// src/client/types/app/bsky/feed/getPostThread.ts
|
// src/client/types/app/bsky/feed/getPostThread.ts
|
||||||
var getPostThread_exports = {};
|
var getPostThread_exports = {};
|
||||||
__export(getPostThread_exports, {
|
__export(getPostThread_exports, {
|
||||||
|
NotFoundError: () => NotFoundError,
|
||||||
toKnownErr: () => toKnownErr30
|
toKnownErr: () => toKnownErr30
|
||||||
});
|
});
|
||||||
|
var NotFoundError = class extends XRPCError {
|
||||||
|
constructor(src) {
|
||||||
|
super(src.status, src.error, src.message);
|
||||||
|
}
|
||||||
|
};
|
||||||
function toKnownErr30(e) {
|
function toKnownErr30(e) {
|
||||||
if (e instanceof XRPCError) {
|
if (e instanceof XRPCError) {
|
||||||
|
if (e.error === "NotFound")
|
||||||
|
return new NotFoundError(e);
|
||||||
}
|
}
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,4 @@
|
||||||
import { Headers } from '@atproto/xrpc';
|
import { Headers, XRPCError } from '@atproto/xrpc';
|
||||||
export interface QueryParams {
|
export interface QueryParams {
|
||||||
uri: string;
|
uri: string;
|
||||||
depth?: number;
|
depth?: number;
|
||||||
|
@ -61,4 +61,7 @@ export interface Response {
|
||||||
headers: Headers;
|
headers: Headers;
|
||||||
data: OutputSchema;
|
data: OutputSchema;
|
||||||
}
|
}
|
||||||
|
export declare class NotFoundError extends XRPCError {
|
||||||
|
constructor(src: XRPCError);
|
||||||
|
}
|
||||||
export declare function toKnownErr(e: any): any;
|
export declare function toKnownErr(e: any): any;
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -43,6 +43,11 @@ export const FeedItem = observer(function FeedItem({
|
||||||
}
|
}
|
||||||
}, [item])
|
}, [item])
|
||||||
|
|
||||||
|
if (item.additionalPost?.notFound) {
|
||||||
|
// don't render anything if the target post was deleted or unfindable
|
||||||
|
return <View />
|
||||||
|
}
|
||||||
|
|
||||||
if (item.isReply) {
|
if (item.isReply) {
|
||||||
return (
|
return (
|
||||||
<Link href={itemHref} title={itemTitle}>
|
<Link href={itemHref} title={itemTitle}>
|
||||||
|
|
|
@ -88,6 +88,15 @@ export const PostThreadItem = observer(function PostThreadItem({
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (deleted) {
|
||||||
|
return (
|
||||||
|
<View style={[styles.outer, s.p20, s.flexRow]}>
|
||||||
|
<FontAwesomeIcon icon={['far', 'trash-can']} style={[s.gray4]} />
|
||||||
|
<Text style={[s.gray5, s.ml10]}>This post has been deleted.</Text>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if (item._isHighlightedPost) {
|
if (item._isHighlightedPost) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
|
@ -321,7 +321,7 @@ export const MobileShell: React.FC = observer(() => {
|
||||||
<Btn
|
<Btn
|
||||||
icon={isAtHome ? 'home-solid' : 'home'}
|
icon={isAtHome ? 'home-solid' : 'home'}
|
||||||
onPress={onPressHome}
|
onPress={onPressHome}
|
||||||
onLongPress={doNewTab('/')}
|
onLongPress={TABS_ENABLED ? doNewTab('/') : undefined}
|
||||||
/>
|
/>
|
||||||
{TABS_ENABLED ? (
|
{TABS_ENABLED ? (
|
||||||
<Btn
|
<Btn
|
||||||
|
@ -333,7 +333,7 @@ export const MobileShell: React.FC = observer(() => {
|
||||||
<Btn
|
<Btn
|
||||||
icon={isAtNotifications ? 'bell-solid' : 'bell'}
|
icon={isAtNotifications ? 'bell-solid' : 'bell'}
|
||||||
onPress={onPressNotifications}
|
onPress={onPressNotifications}
|
||||||
onLongPress={doNewTab('/notifications')}
|
onLongPress={TABS_ENABLED ? doNewTab('/notifications') : undefined}
|
||||||
notificationCount={store.me.notificationCount}
|
notificationCount={store.me.notificationCount}
|
||||||
/>
|
/>
|
||||||
<Btn
|
<Btn
|
||||||
|
|
Loading…
Reference in New Issue