-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'bluesky-social:main' into update-french-localization
- Loading branch information
Showing
17 changed files
with
363 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.