Replace clearTimeout with clearInterval. (#6820)
This commit is contained in:
parent
e9e4059ad3
commit
8b82de8118
1 changed files with 36 additions and 35 deletions
|
|
@ -42,71 +42,72 @@ if (sidebarListingsMinimizeButton) {
|
|||
* @param {object} user The currently logged on user, null if not logged on.
|
||||
*/
|
||||
|
||||
function renderTagsFollowed(tagsFollowedContainer, user = userData()) {
|
||||
if (user === null || document.getElementById('followed-tags-wrapper')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only render if a user is logged on.
|
||||
import('../leftSidebar/TagsFollowed').then(({ TagsFollowed }) => {
|
||||
const { followed_tags } = user; // eslint-disable-line camelcase
|
||||
const followedTags = JSON.parse(followed_tags);
|
||||
|
||||
// This should be done server-side potentially
|
||||
// sort tags by descending weight, descending popularity and name
|
||||
followedTags.sort((tagA, tagB) => {
|
||||
return (
|
||||
tagB.points - tagA.points ||
|
||||
tagB.hotness_score - tagA.hotness_score ||
|
||||
tagA.name.localeCompare(tagB.name)
|
||||
);
|
||||
});
|
||||
|
||||
render(<TagsFollowed tags={followedTags} />, tagsFollowedContainer, tagsFollowedContainer.firstElementChild);
|
||||
function renderTagsFollowed(tagsFollowedContainer, user = userData()) {
|
||||
if (user === null || document.getElementById('followed-tags-wrapper')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only render if a user is logged on.
|
||||
import('../leftSidebar/TagsFollowed').then(({ TagsFollowed }) => {
|
||||
const { followed_tags } = user; // eslint-disable-line camelcase
|
||||
const followedTags = JSON.parse(followed_tags);
|
||||
|
||||
// This should be done server-side potentially
|
||||
// sort tags by descending weight, descending popularity and name
|
||||
followedTags.sort((tagA, tagB) => {
|
||||
return (
|
||||
tagB.points - tagA.points ||
|
||||
tagB.hotness_score - tagA.hotness_score ||
|
||||
tagA.name.localeCompare(tagB.name)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
render(
|
||||
<TagsFollowed tags={followedTags} />,
|
||||
tagsFollowedContainer,
|
||||
tagsFollowedContainer.firstElementChild,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
const feedTimeFrame = frontPageFeedPathNames.get(window.location.pathname);
|
||||
|
||||
|
||||
if (!document.getElementById('featured-story-marker')) {
|
||||
let waitingForDataLoad = setInterval(function dataLoadedCheck() {
|
||||
const waitingForDataLoad = setInterval(function dataLoadedCheck() {
|
||||
const { user = null, userStatus } = document.body.dataset;
|
||||
if (userStatus === 'logged-out') {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (userStatus === 'logged-in' && user !== null) {
|
||||
clearTimeout(waitingForDataLoad);
|
||||
|
||||
clearInterval(waitingForDataLoad);
|
||||
|
||||
import('./homePageFeed').then(({ renderFeed }) => {
|
||||
// We have user data, render followed tags.
|
||||
renderFeed(feedTimeFrame);
|
||||
|
||||
|
||||
InstantClick.on('change', () => {
|
||||
const { userStatus: currentUserStatus } = document.body.dataset;
|
||||
|
||||
|
||||
if (currentUserStatus === 'logged-out') {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const url = new URL(window.location);
|
||||
const changedFeedTimeFrame = frontPageFeedPathNames.get(url.pathname);
|
||||
|
||||
|
||||
if (!frontPageFeedPathNames.has(url.pathname)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
renderFeed(changedFeedTimeFrame);
|
||||
});
|
||||
});
|
||||
renderTagsFollowed(document.getElementById('sidebar-nav-followed-tags'));
|
||||
return;
|
||||
}
|
||||
}, 2);
|
||||
}, 2);
|
||||
}
|
||||
|
||||
|
||||
InstantClick.on('receive', (address, body, title) => {
|
||||
if (document.body.dataset.userStatus !== 'logged-in') {
|
||||
// Nothing to do, the user is not logged on.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue