fix: improved fullscreen button

This commit is contained in:
florian 2023-07-16 13:44:57 +02:00
parent 448019f381
commit 2294e5e9d6
2 changed files with 1 additions and 32 deletions

View File

@ -5,7 +5,6 @@ import React, { useEffect, useMemo, useRef, useState } from "react";
import { NDKFilter, NDKUser } from "@nostr-dev-kit/ndk";
import AuthorProfile from "./AuthorProfile";
import IconFullScreen from "./IconFullScreen";
import useWindowSize from "./useWindowSize";
type NostrImage = {
url: string;
@ -73,7 +72,6 @@ const App = () => {
const images = useRef<NostrImage[]>([]);
const [activeImages, setActiveImages] = useState<NostrImage[]>([]);
const upcommingImage = useRef<NostrImage>();
const windowSize = useWindowSize();
useEffect(() => {
const postSubscription = ndk.subscribe(buildFilter());
@ -134,10 +132,7 @@ const App = () => {
};
}, []);
const fullScreen = useMemo(
() => document.fullscreenElement !== null,
[windowSize] // Hack to force update
);
const fullScreen = document.fullscreenElement !== null;
const activeNpub = upcommingImage?.current?.author?.npub;
const activeProfile = activeNpub && getProfile(activeNpub);

View File

@ -1,26 +0,0 @@
import { useEffect, useState } from "react";
/**
* Get the window size.
*/
export const useWindowSize = () => {
const [windowSize, setWindowSize] = useState({
width: window.innerWidth,
height: window.innerHeight,
});
useEffect(() => {
const handler = () => {
setWindowSize({
width: window.innerWidth,
height: window.innerHeight,
});
};
window.addEventListener("resize", handler);
return () => window.removeEventListener("resize", handler);
}, []);
return windowSize;
};
export default useWindowSize;