Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 7ce3206
Author: noaione <noaione0809@gmail.com>
Date:   Thu Dec 9 14:25:12 2021 +0800

    finally fix stupid lodash problem

commit 03c904d
Author: noaione <noaione0809@gmail.com>
Date:   Thu Dec 9 14:15:02 2021 +0800

    peepoPog wow

commit 6a712a9
Author: noaione <noaione0809@gmail.com>
Date:   Thu Dec 9 14:12:59 2021 +0800

    Try to fix the channels shown in the main page
  • Loading branch information
noaione committed Dec 9, 2021
1 parent a0f980c commit d527bd8
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions pages/index.tsx
Expand Up @@ -3,7 +3,7 @@ import React from "react";
import Head from "next/head";

import { connect, ConnectedProps } from "react-redux";
import { delay, groupBy } from "lodash";
import { groupBy } from "lodash";
import LoadingBar from "react-top-loading-bar";

import ChannelsPages from "../components/ChannelsPages";
Expand Down Expand Up @@ -70,6 +70,10 @@ interface HomepageChannelState {
progressBar: number;
}

function ISleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
}

class HomepageChannelsPage extends React.Component<PropsFromRedux, HomepageChannelState> {
constructor(props) {
super(props);
Expand All @@ -87,17 +91,15 @@ class HomepageChannelsPage extends React.Component<PropsFromRedux, HomepageChann
}

const loadedData = await getAllChannelsAsync("", 1, setLoadData);
console.log("rawLoadedData", loadedData);
const groupedByGroup = groupBy(loadedData, "group");
this.props.resetState();
for (const [groupName, groupVals] of Object.entries(groupedByGroup)) {
delay(() => {
this.props.startNewData(groupVals);
console.info(`Loaded ${groupVals.length} channels for group ${groupName}`);
}, 250);
// this.props.startNewData(groupVals);
}
// this.props.startNewData(loadedData);
console.log("groupedByGroup", groupedByGroup);
this.setState({ isLoading: false });
for (const [_, groupVals] of Object.entries(groupedByGroup)) {
await ISleep(450);
this.props.startNewData(groupVals);
}
}

render() {
Expand Down

0 comments on commit d527bd8

Please sign in to comment.