diff --git a/package.json b/package.json index e40307ac..f01c907b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lemmy-ui", - "version": "0.18.0-rc.7", + "version": "0.18.0", "description": "An isomorphic UI for lemmy", "repository": "https://github.com/LemmyNet/lemmy-ui", "license": "AGPL-3.0", diff --git a/src/shared/components/home/home.tsx b/src/shared/components/home/home.tsx index bad771fc..71e5842e 100644 --- a/src/shared/components/home/home.tsx +++ b/src/shared/components/home/home.tsx @@ -101,6 +101,7 @@ interface HomeState { showTrendingMobile: boolean; showSidebarMobile: boolean; subscribedCollapsed: boolean; + scrolled: boolean; tagline?: string; siteRes: GetSiteResponse; finished: Map; @@ -217,6 +218,7 @@ export class Home extends Component { postsRes: { state: "empty" }, commentsRes: { state: "empty" }, trendingCommunitiesRes: { state: "empty" }, + scrolled: true, siteRes: this.isoData.site_res, showSubscribedMobile: false, showTrendingMobile: false, @@ -620,6 +622,11 @@ export class Home extends Component { search: getQueryString(queryParams), }); + if (!this.state.scrolled) { + this.setState({ scrolled: true }); + setTimeout(() => window.scrollTo(0, 0), 0); + } + await this.fetchData(); } @@ -815,23 +822,23 @@ export class Home extends Component { } handlePageChange(page: number) { + this.setState({ scrolled: false }); this.updateUrl({ page }); - window.scrollTo(0, 0); } handleSortChange(val: SortType) { + this.setState({ scrolled: false }); this.updateUrl({ sort: val, page: 1 }); - window.scrollTo(0, 0); } handleListingTypeChange(val: ListingType) { + this.setState({ scrolled: false }); this.updateUrl({ listingType: val, page: 1 }); - window.scrollTo(0, 0); } handleDataTypeChange(val: DataType) { + this.setState({ scrolled: false }); this.updateUrl({ dataType: val, page: 1 }); - window.scrollTo(0, 0); } async handleAddModToCommunity(form: AddModToCommunity) { diff --git a/src/shared/services/FirstLoadService.ts b/src/shared/services/FirstLoadService.ts index b7558eff..926e3acd 100644 --- a/src/shared/services/FirstLoadService.ts +++ b/src/shared/services/FirstLoadService.ts @@ -1,3 +1,5 @@ +import { isBrowser } from "@utils/browser"; + export class FirstLoadService { #isFirstLoad: boolean; static #instance: FirstLoadService; @@ -20,6 +22,6 @@ export class FirstLoadService { } static get isFirstLoad() { - return this.#Instance.isFirstLoad; + return !isBrowser() || this.#Instance.isFirstLoad; } }