Skip to content

Commit

Permalink
suggestions (#7382)
Browse files Browse the repository at this point in the history
* suggestions

* Revert unneeded changes

---------

Co-authored-by: Eric Bailey <[email protected]>
  • Loading branch information
matthieusieben and estrattonbailey committed Jan 8, 2025
1 parent 09cb5aa commit 31ae185
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
9 changes: 9 additions & 0 deletions src/lib/strings/embed-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -568,3 +568,12 @@ export function parseTenorGif(urlp: URL):
dimensions,
}
}

export function isTenorGifUri(url: URL | string) {
try {
return parseTenorGif(typeof url === 'string' ? new URL(url) : url).success
} catch {
// Invalid URL
return false
}
}
6 changes: 1 addition & 5 deletions src/screens/Messages/components/MessageInputEmbed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,7 @@ export function MessageInputEmbed({
)

const {rt, record} = useMemo(() => {
if (
post &&
AppBskyFeedPost.isRecord(post.record) &&
AppBskyFeedPost.validateRecord(post.record).success
) {
if (post && AppBskyFeedPost.isValidRecord(post.record)) {
return {
rt: new RichTextAPI({
text: post.record.text,
Expand Down
4 changes: 2 additions & 2 deletions src/types/atproto/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ export * as profile from '#/types/atproto/profile'
* }
* ```
*/
export function fastIsType<R>(
export function fastIsType<R extends {$type?: string}>(
record: unknown,
identity: <V>(v: V) => boolean,
identity: <V>(v: V) => v is V & {$type: NonNullable<R['$type']>},
): record is R {
return identity(record)
}
6 changes: 2 additions & 4 deletions src/types/atproto/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ export function anyToBasic(
associated: view.associated,
viewer: view.viewer,
labels: view.labels,
// @ts-expect-error `createdAt` doesn't exist on chat view
createdAt: ChatBskyActorDefs.isProfileViewBasic(view)
? undefined
: view.createdAt,
// `createdAt` doesn't exist in ChatBskyActorDefs.ProfileViewBasic
createdAt: 'createdAt' in view ? view.createdAt : undefined,
}
}

Expand Down

0 comments on commit 31ae185

Please sign in to comment.