- {/* Only show these two selects on mobile */}
- {this.hasFollows && (
+
+
+ {/* Only show these two selects on mobile */}
+ {this.hasFollows && (
+
+ handleShowSubscribedMobile(this, show)}
+ />
+
+ )}
handleShowSubscribedMobile(this, show)}
+ option="show_sidebar"
+ isChecked={showSidebarMobile}
+ onCheck={show => handleShowSidebarMobile(this, show)}
/>
- )}
-
- handleShowSidebarMobile(this, show)}
- />
-
-
-
handlePostOrCommentTypeChange(this, val)}
- />
-
- {postOrCommentType === "post" && this.isoData.myUserInfo && (
- <>
-
- handleShowHiddenChange(this, hidden)}
- />
-
-
- handleHideReadChange(this, hideRead)}
- />
-
- >
- )}
- {/** TODO add show read posts also **/}
-
- handleListingTypeChange(this, val)}
- />
-
-
-
handlePostListingModeChange(this, val)}
- showLabel
- />
-
- {this.props.postOrCommentType === "post" ? (
- <>
+ {this.props.postOrCommentType === "post" ? (
+ <>
+
+
handleSortChange(this, val)}
+ showLabel
+ />
+
+ >
+ ) : (
-
handleSortChange(this, val)}
+ handleCommentSortChange(this, val)}
showLabel
/>
-
- handlePostTimeRangeChange(this, seconds)}
- />
-
- >
- ) : (
+ )}
+ {/** TODO add show read posts also **/}
- handleCommentSortChange(this, val)}
+ handleListingTypeChange(this, val)}
/>
- )}
-
- {getRss(
- listingType ??
- this.state.siteRes.site_view.local_site.default_post_listing_type,
- sort,
+
+
handlePostListingModeChange(this, val)}
+ showLabel
+ />
+
+
+
handlePostOrCommentTypeChange(this, val)}
+ />
+
+
+ {getRss(
+ listingType ??
+ this.state.siteRes.site_view.local_site
+ .default_post_listing_type,
+ sort,
+ )}
+
+
+ {!hidePostTimeRange && (
+
)}
+ {postOrCommentType === "post" &&
+ this.isoData.myUserInfo &&
+ !this.state.selectButtonsHidden && (
+
+
+ handleShowHiddenChange(this, hidden)}
+ />
+
+
+ handleHideReadChange(this, hideRead)}
+ />
+
+
+ handlePostTimeRangeChange2(this, val)}
+ />
+
+
+ )}
+ {!hidePostTimeRange && (
+
x.seconds === postTimeRange)
+ ?.step ?? POST_TIME_RANGE_STEPS.length - 1
+ }
+ onInput={e => handlePostTimeRangeChange(this, e)}
+ />
+ )}
);
}
@@ -1137,10 +1171,42 @@ function handleSortChange(i: Home, val: PostSortType) {
i.updateUrl({ sort: val, cursor: undefined });
}
-function handlePostTimeRangeChange(i: Home, val: number) {
+const HOUR = 60 * 60;
+const DAY = 24 * HOUR;
+const MONTH = 30 * DAY;
+
+const POST_TIME_RANGE_STEPS = [
+ { step: 0, label: "1 Hour", seconds: HOUR },
+ { step: 1, label: "6 Hours", seconds: 6 * HOUR },
+ { step: 2, label: "12 Hours", seconds: 12 * HOUR },
+ { step: 3, label: "1 Day", seconds: DAY },
+ { step: 4, label: "1 Week", seconds: 7 * DAY },
+ { step: 5, label: "1 Month", seconds: MONTH },
+ { step: 6, label: "3 Months", seconds: 3 * MONTH },
+ { step: 7, label: "6 Months", seconds: 6 * MONTH },
+ { step: 8, label: "1 Year", seconds: 365 * DAY },
+ { step: 9, label: "All", seconds: undefined },
+];
+
+function handlePostTimeRangeChange(
+ i: Home,
+ event: FormEvent
,
+) {
+ event.preventDefault();
+ const postTimeRange = POST_TIME_RANGE_STEPS.find(
+ x => x.step === Number(event.target.value),
+ )?.seconds;
+ i.updateUrl({ postTimeRange, cursor: undefined });
+}
+
+function handlePostTimeRangeChange2(i: Home, val: number) {
i.updateUrl({ postTimeRange: val, cursor: undefined });
}
+function postTimeRangeValue(value?: number): string {
+ return POST_TIME_RANGE_STEPS.find(x => x.seconds === value)?.label ?? "All";
+}
+
function handleCommentSortChange(i: Home, val: CommentSortType) {
i.updateUrl({ sort: val, cursor: undefined });
}
@@ -1494,3 +1560,7 @@ async function handleHideDonationDialog(myUserInfo?: MyUserInfo) {
}
}
}
+
+function handleHideSelectButtons(i: Home) {
+ i.setState({ selectButtonsHidden: !i.state.selectButtonsHidden });
+}