Fix mention-creation and implement mentions in notifications

zio/stable
Paul Frazee 2022-12-06 13:47:52 -06:00
parent 1a11c13fce
commit ae522c86fe
3 changed files with 22 additions and 4 deletions

View File

@ -21,7 +21,7 @@ export function doPolyfill() {
export async function post( export async function post(
store: RootStoreModel, store: RootStoreModel,
text: string, text: string,
replyTo?: Post.PostRef, replyTo?: Post.ReplyRef,
knownHandles?: Set<string>, knownHandles?: Set<string>,
) { ) {
let reply let reply
@ -43,6 +43,14 @@ export async function post(
} }
} }
const entities = extractEntities(text, knownHandles) const entities = extractEntities(text, knownHandles)
if (entities) {
for (const ent of entities) {
if (ent.type === 'mention') {
const prof = await store.profiles.getProfile(ent.value)
ent.value = prof.data.did
}
}
}
return await store.api.app.bsky.feed.post.create( return await store.api.app.bsky.feed.post.create(
{did: store.me.did || ''}, {did: store.me.did || ''},
{ {

View File

@ -81,6 +81,10 @@ export class NotificationsViewItemModel implements GroupedNotification {
return this.reason === 'trend' return this.reason === 'trend'
} }
get isMention() {
return this.reason === 'mention'
}
get isReply() { get isReply() {
return this.reason === 'reply' return this.reason === 'reply'
} }
@ -94,7 +98,13 @@ export class NotificationsViewItemModel implements GroupedNotification {
} }
get needsAdditionalData() { get needsAdditionalData() {
if (this.isUpvote || this.isRepost || this.isTrend || this.isReply) { if (
this.isUpvote ||
this.isRepost ||
this.isTrend ||
this.isReply ||
this.isMention
) {
return !this.additionalPost return !this.additionalPost
} }
return false return false
@ -124,7 +134,7 @@ export class NotificationsViewItemModel implements GroupedNotification {
return return
} }
let postUri let postUri
if (this.isReply) { if (this.isReply || this.isMention) {
postUri = this.uri postUri = this.uri
} else if (this.isUpvote || this.isRead || this.isTrend) { } else if (this.isUpvote || this.isRead || this.isTrend) {
postUri = this.subjectUri postUri = this.subjectUri

View File

@ -48,7 +48,7 @@ export const FeedItem = observer(function FeedItem({
return <View /> return <View />
} }
if (item.isReply) { if (item.isReply || item.isMention) {
return ( return (
<Link href={itemHref} title={itemTitle}> <Link href={itemHref} title={itemTitle}>
<Post <Post