use isAtUriString instead of typecast

This commit is contained in:
Samuel Newman
2026-05-13 17:55:34 +03:00
parent e0aa8b6de3
commit cb8e8a8ac8
+3 -3
View File
@@ -1,6 +1,6 @@
import '../index.css' import '../index.css'
import {type AtUriString, Client} from '@atproto/lex' import {Client, isAtUriString} from '@atproto/lex'
import {h, render} from 'preact' import {h, render} from 'preact'
import logo from '../../assets/logo.svg' import logo from '../../assets/logo.svg'
@@ -17,7 +17,7 @@ if (!root) throw new Error('No root element')
const client = new Client('https://public.api.bsky.app') const client = new Client('https://public.api.bsky.app')
const uri = `at://${window.location.pathname.slice('/embed/'.length)}` const uri = `at://${window.location.pathname.slice('/embed/'.length)}`
if (!uri) { if (!isAtUriString(uri)) {
throw new Error('No uri in path') throw new Error('No uri in path')
} }
@@ -41,7 +41,7 @@ switch (colorMode) {
client client
.call(app.bsky.feed.getPosts, { .call(app.bsky.feed.getPosts, {
uris: [uri as AtUriString], uris: [uri],
}) })
.then(({posts}) => { .then(({posts}) => {
const post = posts[0] const post = posts[0]