Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into mute-words-updates
Browse files Browse the repository at this point in the history
* origin/main:
  Make composer reducer source of truth for images/video when publishing (#5595)
  Track links and embeds in the composer reducer (#5593)
  Bump SDK (#5602)
  Update built asset caching (#5601)
  Downgrade sentry to recommended 5.24.3 (#5604)
  Add option to search in any language (#5598)
  Font tweaks (#5597)
  • Loading branch information
estrattonbailey committed Oct 4, 2024
2 parents 37e5154 + 09caf32 commit c587b1e
Show file tree
Hide file tree
Showing 16 changed files with 474 additions and 510 deletions.
10 changes: 2 additions & 8 deletions bskyweb/cmd/bskyweb/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,8 @@ func serve(cctx *cli.Context) error {
path := c.Request().URL.Path
maxAge := 1 * (60 * 60) // default is 1 hour

// Cache javascript and images files for 1 week, which works because
// they're always versioned (e.g. /static/js/main.64c14927.js)
if strings.HasPrefix(path, "/static/js/") || strings.HasPrefix(path, "/static/images/") || strings.HasPrefix(path, "/static/media/") {
maxAge = 7 * (60 * 60 * 24) // 1 week
}

// fonts can be cached for a year
if strings.HasSuffix(path, ".otf") {
// all assets in /static/js, /static/css, /static/media are content-hashed and can be cached for a long time
if strings.HasPrefix(path, "/static/js/") || strings.HasPrefix(path, "/static/css/") || strings.HasPrefix(path, "/static/media/") {
maxAge = 365 * (60 * 60 * 24) // 1 year
}

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"icons:optimize": "svgo -f ./assets/icons"
},
"dependencies": {
"@atproto/api": "^0.13.8",
"@atproto/api": "^0.13.11",
"@braintree/sanitize-url": "^6.0.2",
"@discord/bottom-sheet": "bluesky-social/react-native-bottom-sheet",
"@emoji-mart/react": "^1.1.1",
Expand Down Expand Up @@ -81,7 +81,7 @@
"@react-navigation/drawer": "^6.6.15",
"@react-navigation/native": "^6.1.17",
"@react-navigation/native-stack": "^6.9.26",
"@sentry/react-native": "5.32.0",
"@sentry/react-native": "5.24.3",
"@tamagui/focus-scope": "^1.84.1",
"@tanstack/query-async-storage-persister": "^5.25.0",
"@tanstack/react-query": "^5.8.1",
Expand Down
6 changes: 3 additions & 3 deletions src/alf/atoms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,13 @@ export const atoms = {
letterSpacing: tokens.TRACKING,
},
font_normal: {
fontWeight: tokens.fontWeight.regular,
fontWeight: tokens.fontWeight.normal,
},
font_bold: {
fontWeight: tokens.fontWeight.semibold,
fontWeight: tokens.fontWeight.bold,
},
font_heavy: {
fontWeight: tokens.fontWeight.extrabold,
fontWeight: tokens.fontWeight.heavy,
},
italic: {
fontStyle: 'italic',
Expand Down
13 changes: 5 additions & 8 deletions src/alf/tokens.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Platform} from 'react-native'
import {isAndroid} from '#/platform/detection'

export const TRACKING = Platform.OS === 'android' ? 0.1 : 0
export const TRACKING = isAndroid ? 0.1 : 0

export const color = {
temp_purple: 'rgb(105 0 255)',
Expand Down Expand Up @@ -51,12 +51,9 @@ export const borderRadius = {
* These correspond to Inter font files we actually load.
*/
export const fontWeight = {
regular: '400',
// medium: '500',
semibold: '600',
// bold: '700',
extrabold: '800',
// black: '900',
normal: '400',
bold: isAndroid ? '700' : '600',
heavy: isAndroid ? '900' : '800',
} as const

export const gradients = {
Expand Down
32 changes: 15 additions & 17 deletions src/lib/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import {
AppBskyEmbedDefs,
AppBskyEmbedExternal,
AppBskyEmbedImages,
AppBskyEmbedRecord,
AppBskyEmbedRecordWithMedia,
AppBskyEmbedVideo,
AppBskyFeedPostgate,
AtUri,
BlobRef,
BskyAgent,
ComAtprotoLabelDefs,
RichText,
Expand Down Expand Up @@ -46,14 +44,7 @@ interface PostOpts {
uri: string
cid: string
}
video?: {
blobRef: BlobRef
altText: string
captions: {lang: string; file: File}[]
aspectRatio?: AppBskyEmbedDefs.AspectRatio
}
extLink?: ExternalEmbedDraft
images?: ComposerImage[]
labels?: string[]
threadgate: ThreadgateAllowUISetting[]
postgate: AppBskyFeedPostgate.Record
Expand Down Expand Up @@ -230,13 +221,15 @@ async function resolveMedia(
| AppBskyEmbedVideo.Main
| undefined
> {
if (opts.images?.length) {
const state = opts.composerState
const media = state.embed.media
if (media?.type === 'images') {
logger.debug(`Uploading images`, {
count: opts.images.length,
count: media.images.length,
})
opts.onStateChange?.(`Uploading images...`)
const images: AppBskyEmbedImages.Image[] = await Promise.all(
opts.images.map(async (image, i) => {
media.images.map(async (image, i) => {
logger.debug(`Compressing image #${i}`)
const {path, width, height, mime} = await compressImage(image)
logger.debug(`Uploading image #${i}`)
Expand All @@ -253,9 +246,10 @@ async function resolveMedia(
images,
}
}
if (opts.video) {
if (media?.type === 'video' && media.video.status === 'done') {
const video = media.video
const captions = await Promise.all(
opts.video.captions
video.captions
.filter(caption => caption.lang !== '')
.map(async caption => {
const {data} = await agent.uploadBlob(caption.file, {
Expand All @@ -266,13 +260,17 @@ async function resolveMedia(
)
return {
$type: 'app.bsky.embed.video',
video: opts.video.blobRef,
alt: opts.video.altText || undefined,
video: video.pendingPublish.blobRef,
alt: video.altText || undefined,
captions: captions.length === 0 ? undefined : captions,
aspectRatio: opts.video.aspectRatio,
aspectRatio: {
width: video.asset.width,
height: video.asset.height,
},
}
}
if (opts.extLink) {
// TODO: Read this from composer state as well.
if (opts.extLink.embed) {
return undefined
}
Expand Down
Loading

0 comments on commit c587b1e

Please sign in to comment.