Skip to content

Commit

Permalink
Merge branch 'main' into embed-8
Browse files Browse the repository at this point in the history
  • Loading branch information
haileyok committed Oct 8, 2024
2 parents 637c99a + dd8be2e commit 462bc05
Show file tree
Hide file tree
Showing 3 changed files with 336 additions and 324 deletions.
18 changes: 11 additions & 7 deletions modules/Share-with-Bluesky/ShareViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,23 @@ class ShareViewController: UIViewController {
} catch {}
return nil
}

private func saveVideoWithInfo(_ dataUrl: URL) -> String? {
let ext = String(dataUrl.lastPathComponent.split(separator: ".").last ?? "mp4")
guard let tempUrl = getTempUrl(ext: ext),
let track = AVURLAsset(url: dataUrl).tracks(withMediaType: AVMediaType.video).first else {
guard let tempUrl = getTempUrl(ext: ext) else {
return nil
}
let size = track.naturalSize.applying(track.preferredTransform)


let data = try? Data(contentsOf: dataUrl)
try? data?.write(to: tempUrl)

return "\(tempUrl.absoluteString)|\(size.width)||\(size.height)"

guard let track = AVURLAsset(url: dataUrl).tracks(withMediaType: AVMediaType.video).first else {
_ = try? FileManager().removeItem(at: tempUrl)
return nil
}

let size = track.naturalSize.applying(track.preferredTransform)
return "\(tempUrl.absoluteString)|\(size.width)|\(size.height)"
}

private func completeRequest() {
Expand Down
7 changes: 7 additions & 0 deletions src/lib/api/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ export async function resolveLink(
uri = await resolveShortLink(uri)
}
if (isBskyPostUrl(uri)) {
// TODO: Remove this abstraction.
// TODO: Nice error messages (e.g. EmbeddingDisabledError).
const result = await getPostAsQuote(getPost, uri)
return {
type: 'record',
Expand All @@ -80,6 +82,7 @@ export async function resolveLink(
}
}
if (isBskyCustomFeedUrl(uri)) {
// TODO: Remove this abstraction.
const result = await getFeedAsEmbed(agent, fetchDid, uri)
return {
type: 'record',
Expand All @@ -92,6 +95,7 @@ export async function resolveLink(
}
}
if (isBskyListUrl(uri)) {
// TODO: Remove this abstraction.
const result = await getListAsEmbed(agent, fetchDid, uri)
return {
type: 'record',
Expand All @@ -104,6 +108,7 @@ export async function resolveLink(
}
}
if (isBskyStartUrl(uri) || isBskyStarterPackUrl(uri)) {
// TODO: Remove this abstraction.
const result = await getStarterPackAsEmbed(agent, fetchDid, uri)
return {
type: 'record',
Expand All @@ -117,6 +122,7 @@ export async function resolveLink(
}
return resolveExternal(agent, uri)

// Forked from useGetPost. TODO: move into RQ.
async function getPost({uri}: {uri: string}) {
const urip = new AtUri(uri)
if (!urip.host.startsWith('did:')) {
Expand All @@ -134,6 +140,7 @@ export async function resolveLink(
throw new Error('getPost: post not found')
}

// Forked from useFetchDid. TODO: move into RQ.
async function fetchDid(handleOrDid: string) {
let identifier = handleOrDid
if (!identifier.startsWith('did:')) {
Expand Down
Loading

0 comments on commit 462bc05

Please sign in to comment.