]> Untitled Git - lemmy-ui.git/commitdiff
Merge branch 'main' into enable-zoom
authorSleeplessOne1917 <abias1122@gmail.com>
Thu, 22 Jun 2023 16:31:19 +0000 (16:31 +0000)
committerGitHub <noreply@github.com>
Thu, 22 Jun 2023 16:31:19 +0000 (16:31 +0000)
src/shared/components/community/community.tsx
src/shared/components/home/home.tsx
src/shared/utils/browser/restore-scroll-position.ts
src/shared/utils/browser/save-scroll-position.ts

index 7eefe0eb96ea0c8a2932e5b9f94d0bef371adf1f..111b47cd9d4747be7da88e94fa729413096456ec 100644 (file)
@@ -15,7 +15,6 @@ import {
   updateCommunityBlock,
   updatePersonBlock,
 } from "@utils/app";
-import { restoreScrollPosition, saveScrollPosition } from "@utils/browser";
 import {
   getPageFromString,
   getQueryParams,
@@ -229,10 +228,6 @@ export class Community extends Component<
     setupTippy();
   }
 
-  componentWillUnmount() {
-    saveScrollPosition(this.context);
-  }
-
   static async fetchInitialData({
     client,
     path,
@@ -609,7 +604,6 @@ export class Community extends Component<
       });
     }
 
-    restoreScrollPosition(this.context);
     setupTippy();
   }
 
index 0d91bdbcc28815b0aaa427a2bc44c64e8ed33dff..4a84664bf08d2c0961e409dcc5c04ba443a02ac0 100644 (file)
@@ -13,7 +13,6 @@ import {
   showLocal,
   updatePersonBlock,
 } from "@utils/app";
-import { restoreScrollPosition, saveScrollPosition } from "@utils/browser";
 import {
   getPageFromString,
   getQueryParams,
@@ -293,10 +292,6 @@ export class Home extends Component<any, HomeState> {
     setupTippy();
   }
 
-  componentWillUnmount() {
-    saveScrollPosition(this.context);
-  }
-
   static async fetchInitialData({
     client,
     auth,
@@ -800,7 +795,6 @@ export class Home extends Component<any, HomeState> {
       });
     }
 
-    restoreScrollPosition(this.context);
     setupTippy();
   }
 
index f1534644d9c24a0cfc78ef9e2468d0068576c06f..6986ae597f1a6086784010e71beee7dc8ad01b44 100644 (file)
@@ -1,5 +1,6 @@
 export default function restoreScrollPosition(context: any) {
   const path: string = context.router.route.location.pathname;
   const y = Number(sessionStorage.getItem(`scrollPosition_${path}`));
+
   window.scrollTo(0, y);
 }
index 48353287dccfb4c1a7928ffb47713b9e3282590e..596d5d9f529eb0f378b2a8cbc9897990f0266eb4 100644 (file)
@@ -1,5 +1,6 @@
 export default function saveScrollPosition(context: any) {
   const path: string = context.router.route.location.pathname;
   const y = window.scrollY;
+
   sessionStorage.setItem(`scrollPosition_${path}`, y.toString());
 }