Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Scroll to new space posts

Anand Baburajanf947272fc55a
diff --git a/web/apps/space/src/screens/HomeScreen.tsx b/web/apps/space/src/screens/HomeScreen.tsx
index 01fff4c6d9..6d9e751e77 100644
--- a/web/apps/space/src/screens/HomeScreen.tsx
+++ b/web/apps/space/src/screens/HomeScreen.tsx
@@ -196,6 +196,17 @@ const pageScrollY = () =>
0,
);
+const scrollPageToTop = () => {
+ if (pageScrollY() <= 0) return;
+
+ window.scrollTo({
+ behavior: window.matchMedia("(prefers-reduced-motion: reduce)").matches
+ ? "auto"
+ : "smooth",
+ top: 0,
+ });
+};
+
const useHideHeaderOnScrollDirection = () => {
const [isHidden, setIsHidden] = useState(false);
const lastScrollYRef = React.useRef(0);
@@ -938,6 +949,7 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
const postInputRef = React.useRef<HTMLInputElement | null>(null);
const localPostObjectUrlsRef = React.useRef<Set<string>>(new Set());
const activeLocalPostObjectUrlRef = React.useRef<string | null>(null);
+ const topLocalFeedPostIDRef = React.useRef(localFeedPosts[0]?.id ?? null);
const selectedPhotoFriendID = selectedViewer?.photo.friendID;
const selectedPhotoIsOwn =
Boolean(profile.spaceId) && selectedPhotoFriendID == profile.spaceId;
@@ -1058,6 +1070,14 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
/>
);
+ React.useEffect(() => {
+ const topLocalFeedPostID = localFeedPosts[0]?.id ?? null;
+ if (topLocalFeedPostIDRef.current == topLocalFeedPostID) return;
+
+ topLocalFeedPostIDRef.current = topLocalFeedPostID;
+ if (topLocalFeedPostID) scrollPageToTop();
+ }, [localFeedPosts]);
+
const shareProfileLink = async () => {
if (!onShareProfileLink) return;
const profileLink = await onShareProfileLink();
diff --git a/web/apps/space/src/styles/globals.css b/web/apps/space/src/styles/globals.css
index c32d71f6c0..3248a7c722 100644
--- a/web/apps/space/src/styles/globals.css
+++ b/web/apps/space/src/styles/globals.css
@@ -3,6 +3,10 @@
repeat;
}
+:where(a, button, [role="button"]) {
+ -webkit-tap-highlight-color: transparent;
+}
+
.pswp-space-viewer {
--pswp-root-z-index: 0;
--pswp-bg: #000000;