Merge branch 'main' into reduce-bundle

This commit is contained in:
SleeplessOne1917 2023-06-23 10:39:01 -04:00
commit 25e9acee39
3 changed files with 15 additions and 6 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "lemmy-ui", "name": "lemmy-ui",
"version": "0.18.0-rc.7", "version": "0.18.0",
"description": "An isomorphic UI for lemmy", "description": "An isomorphic UI for lemmy",
"repository": "https://github.com/LemmyNet/lemmy-ui", "repository": "https://github.com/LemmyNet/lemmy-ui",
"license": "AGPL-3.0", "license": "AGPL-3.0",

View file

@ -101,6 +101,7 @@ interface HomeState {
showTrendingMobile: boolean; showTrendingMobile: boolean;
showSidebarMobile: boolean; showSidebarMobile: boolean;
subscribedCollapsed: boolean; subscribedCollapsed: boolean;
scrolled: boolean;
tagline?: string; tagline?: string;
siteRes: GetSiteResponse; siteRes: GetSiteResponse;
finished: Map<CommentId, boolean | undefined>; finished: Map<CommentId, boolean | undefined>;
@ -217,6 +218,7 @@ export class Home extends Component<any, HomeState> {
postsRes: { state: "empty" }, postsRes: { state: "empty" },
commentsRes: { state: "empty" }, commentsRes: { state: "empty" },
trendingCommunitiesRes: { state: "empty" }, trendingCommunitiesRes: { state: "empty" },
scrolled: true,
siteRes: this.isoData.site_res, siteRes: this.isoData.site_res,
showSubscribedMobile: false, showSubscribedMobile: false,
showTrendingMobile: false, showTrendingMobile: false,
@ -620,6 +622,11 @@ export class Home extends Component<any, HomeState> {
search: getQueryString(queryParams), search: getQueryString(queryParams),
}); });
if (!this.state.scrolled) {
this.setState({ scrolled: true });
setTimeout(() => window.scrollTo(0, 0), 0);
}
await this.fetchData(); await this.fetchData();
} }
@ -815,23 +822,23 @@ export class Home extends Component<any, HomeState> {
} }
handlePageChange(page: number) { handlePageChange(page: number) {
this.setState({ scrolled: false });
this.updateUrl({ page }); this.updateUrl({ page });
window.scrollTo(0, 0);
} }
handleSortChange(val: SortType) { handleSortChange(val: SortType) {
this.setState({ scrolled: false });
this.updateUrl({ sort: val, page: 1 }); this.updateUrl({ sort: val, page: 1 });
window.scrollTo(0, 0);
} }
handleListingTypeChange(val: ListingType) { handleListingTypeChange(val: ListingType) {
this.setState({ scrolled: false });
this.updateUrl({ listingType: val, page: 1 }); this.updateUrl({ listingType: val, page: 1 });
window.scrollTo(0, 0);
} }
handleDataTypeChange(val: DataType) { handleDataTypeChange(val: DataType) {
this.setState({ scrolled: false });
this.updateUrl({ dataType: val, page: 1 }); this.updateUrl({ dataType: val, page: 1 });
window.scrollTo(0, 0);
} }
async handleAddModToCommunity(form: AddModToCommunity) { async handleAddModToCommunity(form: AddModToCommunity) {

View file

@ -1,3 +1,5 @@
import { isBrowser } from "@utils/browser";
export class FirstLoadService { export class FirstLoadService {
#isFirstLoad: boolean; #isFirstLoad: boolean;
static #instance: FirstLoadService; static #instance: FirstLoadService;
@ -20,6 +22,6 @@ export class FirstLoadService {
} }
static get isFirstLoad() { static get isFirstLoad() {
return this.#Instance.isFirstLoad; return !isBrowser() || this.#Instance.isFirstLoad;
} }
} }