Skip to content

Commit

Permalink
Show message if loading own comments is taking >10s
Browse files Browse the repository at this point in the history
  • Loading branch information
miko committed Jan 17, 2024
1 parent 91ad6b8 commit d6f9be3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions static/app-strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2957,6 +2957,7 @@
"Credits: %credits%": "Credits: %credits%",
"Publications: %claims%": "Publications: %claims%",
"Channels:": "Channels",
"Larger comment histories may take time to load": "Larger comment histories may take time to load",

"--end--": "--end--"
}
16 changes: 16 additions & 0 deletions ui/page/ownComments/view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ export default function OwnComments(props: Props) {
const spinnerRef = React.useRef();
const [page, setPage] = React.useState(0);
const [activeChannelId, setActiveChannelId] = React.useState('');
const [isLoadingLong, setIsLoadingLong] = React.useState(false);
const loadingTimingTimeoutId = React.useRef(null);
handleLogicForCheckingLongLoadingTime();

function handleLogicForCheckingLongLoadingTime() {
if (isFetchingComments && !loadingTimingTimeoutId.current) {
loadingTimingTimeoutId.current = setTimeout(() => {
setIsLoadingLong(true);
}, 10000);
} else if (!isFetchingComments && loadingTimingTimeoutId.current) {
clearTimeout(loadingTimingTimeoutId.current);
setIsLoadingLong(false);
loadingTimingTimeoutId.current = null;
}
}

// Since we are sharing the key for Discussion and MyComments, don't show
// the list until we've gone through the initial reset.
Expand Down Expand Up @@ -188,6 +203,7 @@ export default function OwnComments(props: Props) {
{(isFetchingComments || moreBelow) && (
<div className="main--empty" ref={spinnerRef}>
<Spinner type="small" />
{isLoadingLong && <p>{__('Larger comment histories may take time to load')}</p>}
</div>
)}
</>
Expand Down

0 comments on commit d6f9be3

Please sign in to comment.