Page MenuHomePhabricator

D5230.id17089.diff
No OneTemporary

D5230.id17089.diff

diff --git a/web/calendar/thread-picker.react.js b/web/calendar/thread-picker.react.js
--- a/web/calendar/thread-picker.react.js
+++ b/web/calendar/thread-picker.react.js
@@ -8,7 +8,6 @@
import { useSelector } from '../redux/redux-utils';
import { htmlTargetFromEvent } from '../vector-utils';
-import { LeftPager, RightPager } from '../vectors.react';
import css from './thread-picker.css';
type OptionProps = {
@@ -41,9 +40,7 @@
...BaseProps,
+onScreenThreadInfos: $ReadOnlyArray<ThreadInfo>,
};
-type State = {
- +currentPage: number,
-};
+type State = {};
class ThreadPicker extends React.PureComponent<Props, State> {
static pageSize = 5;
@@ -52,9 +49,6 @@
constructor(props: Props) {
super(props);
- this.state = {
- currentPage: 0,
- };
invariant(
props.onScreenThreadInfos.length > 0,
"ThreadPicker can't be open when onScreenThreadInfos is empty",
@@ -72,60 +66,14 @@
length > 0,
"ThreadPicker can't be open when onScreenThreadInfos is empty",
);
- const firstIndex = ThreadPicker.pageSize * this.state.currentPage;
- const secondIndex = Math.min(
- ThreadPicker.pageSize * (this.state.currentPage + 1),
- length,
- );
-
- let pager = null;
- if (length > ThreadPicker.pageSize) {
- let leftPager = <LeftPager className={css.pagerIcon} />;
- if (this.state.currentPage > 0) {
- leftPager = (
- <a
- href="#"
- className={css.pagerButton}
- onClick={this.onBackPagerClick}
- >
- {leftPager}
- </a>
- );
- }
- let rightPager = <RightPager className={css.pagerIcon} />;
- if (ThreadPicker.pageSize * (this.state.currentPage + 1) < length) {
- rightPager = (
- <a
- href="#"
- className={css.pagerButton}
- onClick={this.onNextPagerClick}
- >
- {rightPager}
- </a>
- );
- }
- pager = (
- <div className={css.pagerContainer} key="pager">
- <div className={css.pager}>
- {leftPager}
- <span className={css.pagerStatus}>
- {`${firstIndex + 1}–${secondIndex} of ${length}`}
- </span>
- {rightPager}
- </div>
- </div>
- );
- }
- const options = this.props.onScreenThreadInfos
- .slice(firstIndex, secondIndex)
- .map(threadInfo => (
- <ThreadPickerOption
- threadInfo={threadInfo}
- createNewEntry={this.props.createNewEntry}
- key={threadInfo.id}
- />
- ));
+ const options = this.props.onScreenThreadInfos.map(threadInfo => (
+ <ThreadPickerOption
+ threadInfo={threadInfo}
+ createNewEntry={this.props.createNewEntry}
+ key={threadInfo.id}
+ />
+ ));
return (
<div
@@ -137,7 +85,6 @@
ref={this.pickerDivRef}
>
{options}
- {pager}
</div>
);
}
@@ -161,26 +108,6 @@
event.preventDefault();
}
};
-
- onBackPagerClick = (event: SyntheticEvent<HTMLAnchorElement>) => {
- event.preventDefault();
- this.setState(prevState => {
- invariant(prevState.currentPage > 0, "can't go back from 0");
- return { currentPage: prevState.currentPage - 1 };
- });
- };
-
- onNextPagerClick = (event: SyntheticEvent<HTMLAnchorElement>) => {
- event.preventDefault();
- this.setState((prevState, props) => {
- invariant(
- ThreadPicker.pageSize * (prevState.currentPage + 1) <
- props.onScreenThreadInfos.length,
- 'page is too high',
- );
- return { currentPage: prevState.currentPage + 1 };
- });
- };
}
const ConnectedThreadPicker: React.ComponentType<BaseProps> = React.memo<BaseProps>(

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 26, 10:09 PM (1 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2586495
Default Alt Text
D5230.id17089.diff (3 KB)

Event Timeline