Skip to content

Commit

Permalink
Show loader on breadcrumb change (#2371)
Browse files Browse the repository at this point in the history
* better code in schemeName function

* Display loader on breadcrumb change

* .

* update the following DAOs select instately
  • Loading branch information
roienatan authored Dec 23, 2020
1 parent 089087b commit f68c1ab
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/components/Dao/DaoContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ interface IState {
modalParentPath: string;
schemeId: string|null;
proposalWindowType: PROPOSAL_WINDOW_TYPE|null;
loading: boolean;
}

interface IDispatchProps {
Expand Down Expand Up @@ -76,6 +77,7 @@ class DaoContainer extends React.Component<IProps, IState> {
modalParentPath: "/dao/:daoAvatarAddress",
schemeId: "",
proposalWindowType: null,
loading: false,
};
}
public daoSubscription: any;
Expand Down Expand Up @@ -110,6 +112,12 @@ class DaoContainer extends React.Component<IProps, IState> {
this.setState({ memberDaos: memberDaos });
}

componentDidUpdate(prevProps: IProps) {
if (this.props.data[0] !== prevProps.data[0]){
this.setState({ loading: false });
}
}

public handleNewProposal = async (schemeId?: string): Promise<void> => {
const { showNotification, daoAvatarAddress } = this.props;

Expand Down Expand Up @@ -188,24 +196,27 @@ class DaoContainer extends React.Component<IProps, IState> {
.replace(":daoAvatarAddress", route.params.daoAvatarAddress)
.replace(":schemeId", this.state.schemeId);
};
private onFollwingDaosListChange = (daoAddress: string, history: any) => history.push(`/dao/${daoAddress}`);
private onFollwingDaosListChange = (daoAddress: string, history: any) => {
this.setState({ loading: true });
history.push(`/dao/${daoAddress}`);
};

public render(): RenderOutput {
const daoState = this.props.data[0];
const { followingDaosAddresses } = this.props;
const { memberDaos } = this.state;
const { memberDaos, loading } = this.state;

const followingDaos = followingDaosAddresses?.filter(address => getDAONameByID(address) !== undefined)
.map(daoAddress => {
return { id: daoAddress, name: getDAONameByID(daoAddress) };
});

const myDaos = followingDaos?.concat(memberDaos);

const currentDaoAddress = window.location.pathname.split("/")[2];
const myDaosAddresses = [] as any;
const myDaosOptions = myDaos?.map(dao => {
myDaosAddresses.push(dao.id);
return <option key={dao.id} selected={dao.id === daoState.address ? true : false} value={dao.id}>{dao.name}</option>;
return <option key={dao.id} selected={dao.id === currentDaoAddress ? true : false} value={dao.id}>{dao.name}</option>;
});

if (!myDaosAddresses.includes(daoState.id)){
Expand All @@ -223,7 +234,7 @@ class DaoContainer extends React.Component<IProps, IState> {
<meta name="twitter:description" content={daoState.name + " | Managed on Alchemy by DAOstack"} />
</Helmet>

<div className={css.wrapper}>
{!loading ? <div className={css.wrapper}>
<Switch>
<Route exact path="/dao/:daoAvatarAddress/members"
render={this.daoMembersRoute} />
Expand Down Expand Up @@ -257,7 +268,7 @@ class DaoContainer extends React.Component<IProps, IState> {
component={this.createProposalRoute}
/>

</div>
</div> : <Loading />}
</div>
);
}
Expand Down

0 comments on commit f68c1ab

Please sign in to comment.