Skip to content

Commit

Permalink
Merge branch 'bluesky-social:main' into update-french-localization
Browse files Browse the repository at this point in the history
  • Loading branch information
surfdude29 authored Sep 11, 2024
2 parents 7554e3a + 9912029 commit c9fe769
Show file tree
Hide file tree
Showing 17 changed files with 363 additions and 212 deletions.
17 changes: 17 additions & 0 deletions src/components/dms/MessageContext.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react'

const MessageContext = React.createContext(false)

export function MessageContextProvider({
children,
}: {
children: React.ReactNode
}) {
return (
<MessageContext.Provider value={true}>{children}</MessageContext.Provider>
)
}

export function useIsWithinMessage() {
return React.useContext(MessageContext)
}
17 changes: 10 additions & 7 deletions src/components/dms/MessageItemEmbed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {AppBskyEmbedRecord} from '@atproto/api'

import {PostEmbeds, PostEmbedViewContext} from '#/view/com/util/post-embeds'
import {atoms as a, native, useTheme} from '#/alf'
import {MessageContextProvider} from './MessageContext'

let MessageItemEmbed = ({
embed,
Expand All @@ -13,13 +14,15 @@ let MessageItemEmbed = ({
const t = useTheme()

return (
<View style={[a.my_xs, t.atoms.bg, native({flexBasis: 0})]}>
<PostEmbeds
embed={embed}
allowNestedQuotes
viewContext={PostEmbedViewContext.Feed}
/>
</View>
<MessageContextProvider>
<View style={[a.my_xs, t.atoms.bg, native({flexBasis: 0})]}>
<PostEmbeds
embed={embed}
allowNestedQuotes
viewContext={PostEmbedViewContext.Feed}
/>
</View>
</MessageContextProvider>
)
}
MessageItemEmbed = React.memo(MessageItemEmbed)
Expand Down
53 changes: 53 additions & 0 deletions src/components/hooks/useFullscreen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import {
useCallback,
useEffect,
useRef,
useState,
useSyncExternalStore,
} from 'react'

import {isFirefox, isSafari} from '#/lib/browser'
import {isWeb} from '#/platform/detection'

function fullscreenSubscribe(onChange: () => void) {
document.addEventListener('fullscreenchange', onChange)
return () => document.removeEventListener('fullscreenchange', onChange)
}

export function useFullscreen(ref?: React.RefObject<HTMLElement>) {
if (!isWeb) throw new Error("'useFullscreen' is a web-only hook")
const isFullscreen = useSyncExternalStore(fullscreenSubscribe, () =>
Boolean(document.fullscreenElement),
)
const scrollYRef = useRef<null | number>(null)
const [prevIsFullscreen, setPrevIsFullscreen] = useState(isFullscreen)

const toggleFullscreen = useCallback(() => {
if (isFullscreen) {
document.exitFullscreen()
} else {
if (!ref) throw new Error('No ref provided')
if (!ref.current) return
scrollYRef.current = window.scrollY
ref.current.requestFullscreen()
}
}, [isFullscreen, ref])

useEffect(() => {
if (prevIsFullscreen === isFullscreen) return
setPrevIsFullscreen(isFullscreen)

// Chrome has an issue where it doesn't scroll back to the top after exiting fullscreen
// Let's play it safe and do it if not FF or Safari, since anything else will probably be chromium
if (prevIsFullscreen && !isFirefox && !isSafari) {
setTimeout(() => {
if (scrollYRef.current !== null) {
window.scrollTo(0, scrollYRef.current)
scrollYRef.current = null
}
}, 100)
}
}, [isFullscreen, prevIsFullscreen])

return [isFullscreen, toggleFullscreen] as const
}
3 changes: 2 additions & 1 deletion src/lib/media/video/compress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {SUPPORTED_MIME_TYPES, SupportedMimeTypes} from '#/lib/constants'
import {extToMime} from '#/state/queries/video/util'
import {CompressedVideo} from './types'

const MIN_SIZE_FOR_COMPRESSION = 1024 * 1024 * 25 // 25mb
const MIN_SIZE_FOR_COMPRESSION = 25 // 25mb

export async function compressVideo(
file: ImagePickerAsset,
Expand All @@ -30,6 +30,7 @@ export async function compressVideo(
compressionMethod: 'manual',
bitrate: 3_000_000, // 3mbps
maxSize: 1920,
// WARNING: this ONE SPECIFIC ARG is in MB -sfn
minimumFileSizeForCompress,
getCancellationId: id => {
if (signal) {
Expand Down
5 changes: 1 addition & 4 deletions src/lib/statsig/gates.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
export type Gate =
// Keep this alphabetic please.
| 'debug_show_feedcontext'
| 'suggested_feeds_interstitial'
| 'video_upload' // upload videos
| 'video_view_on_posts' // see posted videos
'debug_show_feedcontext' | 'suggested_feeds_interstitial' | 'video_upload' // upload videos
Loading

0 comments on commit c9fe769

Please sign in to comment.