Skip to content

Commit

Permalink
Feature/proposal data needs (#758)
Browse files Browse the repository at this point in the history
* Publish new lib versions. (#412)

* fix/fix-table-types (#354)

* removed the any types from hub

* renamed Table to DaoTable and DataTable to DaoTable to be more consistent with DaoCard

* removed commented out DaoData type

* one more comment -- thought i got both before

* Fix/355 summon params mixup (#356)

* more ignore

* fixes bad init params order in summon tx

* Feature/tag component (#349)

* Created basic tag component

* Added dynamic color selections for tags

* Bumped versions fixed filer

* Added icon support to tag component

Co-authored-by: Jord <[email protected]>
Co-authored-by: Jonathan Prozzi <[email protected]>

* Feature/delegate play (#357)

* more ignore

* fixes bad init params order in summon tx

* delegate testing and subgraph field updates

* finishes mapping

* update dao-data query and transformer

* adds delegate tag to list view and hooks up delegate filtering

* refactors filter into query helper

* Spencer's Summon tooltip suggestions (#370)

* Spencer's Summon tooltip suggestions

- Summon portion of #365 

* Delimiter references

#368

For now, just referencing spaces. But if tabs, commas, or other delimiters are also supported, those should be references in the tooltips as well.

* Address Jord's comments

Co-authored-by: Sam Kuhlmann <[email protected]>

* Fix/summon poll (#375)

* more ignore

* fixes bad init params order in summon tx

* delegate testing and subgraph field updates

* finishes mapping

* update dao-data query and transformer

* adds delegate tag to list view and hooks up delegate filtering

* adds schema field to tx entity

* updates poll for tx entity made before dao entity

* Feature/alpha baal update (#376)

* new abis

* updates summoner tx logic and contract addresses

* fixes transaction entity creation location;

* fixes some test

* Feature/unit utils (#380)

* create custom d.ts for human-format

* type and convert unit fn from V2

* readableNumber util accepts number strings, throws error if string but number string

* fix 0 to 1 utils, extend MaxDecimals to shorten decimal places

* refine spacer and unit symbol placement

* update new card to handle new params

* update table

* corrections

* alter d.ts file

* potential solutions to ts bug

* implement keating's d.ts fix

* fix comment

* Fix/network switcher (#381)

* better error handling

* fix bug

* remove log

* get react-table TS to stop yelling (#382)

Co-authored-by: Sam Kuhlmann <[email protected]>

* Feature/hub sort (#383)

* wip

* gets query working on dao entity after lots of subgraph updates

* updates front end for sort

* fixes type issue

* fixes build issue

* reviewing v3 monorepo and saw some networks missing (#399)

* Feature/public profile (#384)

* Add some stuff

* Add public profile

* Add ens

* Get build to pass

* Update apps/hub-app/src/pages/PublicProfilePage.tsx

Co-authored-by: Rowdy <[email protected]>

Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>

* fixing doc display name from <[object Object]> to displayName (#402)

Co-authored-by: Sam Kuhlmann <[email protected]>

* adds search (#401)

* adds search wip

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* Feature/public profile (#384)

* Add some stuff

* Add public profile

* Add ens

* Get build to pass

* Update apps/hub-app/src/pages/PublicProfilePage.tsx

Co-authored-by: Rowdy <[email protected]>

Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>

* fixing doc display name from <[object Object]> to displayName (#402)

Co-authored-by: Sam Kuhlmann <[email protected]>

* conflicts

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* fix build error

Co-authored-by: Alexander Keating <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>

* Release/12072022 (#411)

* adds search wip

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* conflicts

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* fix build error

* feature bump

Co-authored-by: Jonathan Prozzi <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Jord <[email protected]>
Co-authored-by: Spencer Graham <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>
Co-authored-by: Alexander Keating <[email protected]>

* Revert "Publish new lib versions. (#412)"

This reverts commit bab7077.

* develop to master (#482)

* UI/layout cleanup (#438)

* run generator

* import connect, theme libs. Add eindow.global. Ensure main.tsx uses React 17 API.

* deletes app test

* updates favicon and title

* remove nx defaults

* rough in layout box, target DH connect nav with class

* remove even more css. World's dubest layout component

* switches to connect class padding for mobile

* extract base layout component to storybook

* hook export chain, change name to outerlayout

* extract formSegment from summon-app; replace in all instances in summon

* extract split-column, replace all instances in summon

* document future changes in comments

* fix exports

* switch core-app to nx default project

* fix spacing

* Fix/split column bug (#444)

- fix bug

* Layouts/subnav (#447)

* clear out extra app.t.tsx

* build sub-nav

* style sub-nav

* test subnav

* extract subNavLink into component

* subnavlink story

* build subnavlink story

* fix broken as prop

* add mobile view, icon button trigger

* add tsc command to core-app

* adds human-format, removes profanity

* Fix summon (#446)

* Fix summon

* clear out extra app.t.tsx

* build sub-nav

* style sub-nav

* test subnav

* extract subNavLink into component

* subnavlink story

* build subnavlink story

* fix broken as prop

* Fix summon

* add mobile view, icon button trigger

* add tsc command to core-app

* adds human-format, removes profanity

* add human-format to dao-data

* move dts file

Co-authored-by: jordan <[email protected]>
Co-authored-by: Jord <[email protected]>

* Haus layout (#451)

* Publish new lib versions. (#412)

* fix/fix-table-types (#354)

* removed the any types from hub

* renamed Table to DaoTable and DataTable to DaoTable to be more consistent with DaoCard

* removed commented out DaoData type

* one more comment -- thought i got both before

* Fix/355 summon params mixup (#356)

* more ignore

* fixes bad init params order in summon tx

* Feature/tag component (#349)

* Created basic tag component

* Added dynamic color selections for tags

* Bumped versions fixed filer

* Added icon support to tag component

Co-authored-by: Jord <[email protected]>
Co-authored-by: Jonathan Prozzi <[email protected]>

* Feature/delegate play (#357)

* more ignore

* fixes bad init params order in summon tx

* delegate testing and subgraph field updates

* finishes mapping

* update dao-data query and transformer

* adds delegate tag to list view and hooks up delegate filtering

* refactors filter into query helper

* Spencer's Summon tooltip suggestions (#370)

* Spencer's Summon tooltip suggestions

- Summon portion of #365 

* Delimiter references

#368

For now, just referencing spaces. But if tabs, commas, or other delimiters are also supported, those should be references in the tooltips as well.

* Address Jord's comments

Co-authored-by: Sam Kuhlmann <[email protected]>

* Fix/summon poll (#375)

* more ignore

* fixes bad init params order in summon tx

* delegate testing and subgraph field updates

* finishes mapping

* update dao-data query and transformer

* adds delegate tag to list view and hooks up delegate filtering

* adds schema field to tx entity

* updates poll for tx entity made before dao entity

* Feature/alpha baal update (#376)

* new abis

* updates summoner tx logic and contract addresses

* fixes transaction entity creation location;

* fixes some test

* Feature/unit utils (#380)

* create custom d.ts for human-format

* type and convert unit fn from V2

* readableNumber util accepts number strings, throws error if string but number string

* fix 0 to 1 utils, extend MaxDecimals to shorten decimal places

* refine spacer and unit symbol placement

* update new card to handle new params

* update table

* corrections

* alter d.ts file

* potential solutions to ts bug

* implement keating's d.ts fix

* fix comment

* Fix/network switcher (#381)

* better error handling

* fix bug

* remove log

* get react-table TS to stop yelling (#382)

Co-authored-by: Sam Kuhlmann <[email protected]>

* Feature/hub sort (#383)

* wip

* gets query working on dao entity after lots of subgraph updates

* updates front end for sort

* fixes type issue

* fixes build issue

* reviewing v3 monorepo and saw some networks missing (#399)

* Feature/public profile (#384)

* Add some stuff

* Add public profile

* Add ens

* Get build to pass

* Update apps/hub-app/src/pages/PublicProfilePage.tsx

Co-authored-by: Rowdy <[email protected]>

Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>

* fixing doc display name from <[object Object]> to displayName (#402)

Co-authored-by: Sam Kuhlmann <[email protected]>

* adds search (#401)

* adds search wip

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* Feature/public profile (#384)

* Add some stuff

* Add public profile

* Add ens

* Get build to pass

* Update apps/hub-app/src/pages/PublicProfilePage.tsx

Co-authored-by: Rowdy <[email protected]>

Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>

* fixing doc display name from <[object Object]> to displayName (#402)

Co-authored-by: Sam Kuhlmann <[email protected]>

* conflicts

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* fix build error

Co-authored-by: Alexander Keating <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>

* Release/12072022 (#411)

* adds search wip

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* conflicts

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* fix build error

* feature bump

Co-authored-by: Jonathan Prozzi <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Jord <[email protected]>
Co-authored-by: Spencer Graham <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>
Co-authored-by: Alexander Keating <[email protected]>

* Revert "Publish new lib versions. (#412)"

This reverts commit bab7077.

* build formLayout Component

* type correction

* build formLayout story

* rough in bicolumn layout

* handle bicolumn mobile switch, finish bicolumn

* fix mainlayout naming

* build story for bi-column layout

* build dh layout one shot?

* yes, one shot

* fix import

* change prop name

Co-authored-by: Jonathan Prozzi <[email protected]>
Co-authored-by: Alexander Keating <[email protected]>
Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Spencer Graham <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>

* bumping packages that were published pre revert last week - causing fialures with package publishing (#460)

* removing period from info content which casues confusing tooltip (#453)

Co-authored-by: Sam Kuhlmann <[email protected]>

* Feature/hub profile menu fix (#480)

* fixes profile link and layout

* dao list style

* adds toast to share link

* Readme tables preferred (#483)

* adjusting breakdown of apps and libs to tables

* adding additoonal app references and libs

* adding timestamp and address fields to many events (#468)

* adding timestamps and address fields to many events

* addressing code review

* shortening naming convention on proposals, top level txHash defined as txHash going forward

* update version

* deploy subgraph and generate query types

Co-authored-by: skuhlmann <[email protected]>

Co-authored-by: Jord <[email protected]>
Co-authored-by: Alexander Keating <[email protected]>
Co-authored-by: jordan <[email protected]>
Co-authored-by: Jonathan Prozzi <[email protected]>
Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Spencer Graham <[email protected]>

* Revert "develop to master (#482)" (#492)

This reverts commit 5f7d121.

Co-authored-by: Sam Kuhlmann <[email protected]>

* Develop into master (#577)

* Feature/form builder (#553)

* Publish new lib versions. (#412)

* fix/fix-table-types (#354)

* removed the any types from hub

* renamed Table to DaoTable and DataTable to DaoTable to be more consistent with DaoCard

* removed commented out DaoData type

* one more comment -- thought i got both before

* Fix/355 summon params mixup (#356)

* more ignore

* fixes bad init params order in summon tx

* Feature/tag component (#349)

* Created basic tag component

* Added dynamic color selections for tags

* Bumped versions fixed filer

* Added icon support to tag component

Co-authored-by: Jord <[email protected]>
Co-authored-by: Jonathan Prozzi <[email protected]>

* Feature/delegate play (#357)

* more ignore

* fixes bad init params order in summon tx

* delegate testing and subgraph field updates

* finishes mapping

* update dao-data query and transformer

* adds delegate tag to list view and hooks up delegate filtering

* refactors filter into query helper

* Spencer's Summon tooltip suggestions (#370)

* Spencer's Summon tooltip suggestions

- Summon portion of #365 

* Delimiter references

#368

For now, just referencing spaces. But if tabs, commas, or other delimiters are also supported, those should be references in the tooltips as well.

* Address Jord's comments

Co-authored-by: Sam Kuhlmann <[email protected]>

* Fix/summon poll (#375)

* more ignore

* fixes bad init params order in summon tx

* delegate testing and subgraph field updates

* finishes mapping

* update dao-data query and transformer

* adds delegate tag to list view and hooks up delegate filtering

* adds schema field to tx entity

* updates poll for tx entity made before dao entity

* Feature/alpha baal update (#376)

* new abis

* updates summoner tx logic and contract addresses

* fixes transaction entity creation location;

* fixes some test

* Feature/unit utils (#380)

* create custom d.ts for human-format

* type and convert unit fn from V2

* readableNumber util accepts number strings, throws error if string but number string

* fix 0 to 1 utils, extend MaxDecimals to shorten decimal places

* refine spacer and unit symbol placement

* update new card to handle new params

* update table

* corrections

* alter d.ts file

* potential solutions to ts bug

* implement keating's d.ts fix

* fix comment

* Fix/network switcher (#381)

* better error handling

* fix bug

* remove log

* get react-table TS to stop yelling (#382)

Co-authored-by: Sam Kuhlmann <[email protected]>

* Feature/hub sort (#383)

* wip

* gets query working on dao entity after lots of subgraph updates

* updates front end for sort

* fixes type issue

* fixes build issue

* reviewing v3 monorepo and saw some networks missing (#399)

* Feature/public profile (#384)

* Add some stuff

* Add public profile

* Add ens

* Get build to pass

* Update apps/hub-app/src/pages/PublicProfilePage.tsx

Co-authored-by: Rowdy <[email protected]>

Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>

* fixing doc display name from <[object Object]> to displayName (#402)

Co-authored-by: Sam Kuhlmann <[email protected]>

* adds search (#401)

* adds search wip

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* Feature/public profile (#384)

* Add some stuff

* Add public profile

* Add ens

* Get build to pass

* Update apps/hub-app/src/pages/PublicProfilePage.tsx

Co-authored-by: Rowdy <[email protected]>

Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>

* fixing doc display name from <[object Object]> to displayName (#402)

Co-authored-by: Sam Kuhlmann <[email protected]>

* conflicts

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* fix build error

Co-authored-by: Alexander Keating <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>

* Release/12072022 (#411)

* adds search wip

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* conflicts

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* fix build error

* feature bump

Co-authored-by: Jonathan Prozzi <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Jord <[email protected]>
Co-authored-by: Spencer Graham <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>
Co-authored-by: Alexander Keating <[email protected]>

* Revert "Publish new lib versions. (#412)"

This reverts commit bab7077.

* build formLayout Component

* type correction

* build formLayout story

* rough in bicolumn layout

* handle bicolumn mobile switch, finish bicolumn

* fix mainlayout naming

* build story for bi-column layout

* scaffold formBuilder library

* rough in formBuilder

* restructure types

* refactor component structure

* test render inputs

* add core fields to builder enum

* add row layout to builder

* built logger, fix logger bug

* add disable all functionality

* handle asynchronous callback as props to form builder

* remove some comments

* put submit button in form footer

* fix code based on review

* build validation pipeline

* clean form and field types

* revise types again, simplify rules API

* commit after refactor carnage

* roll back to react-hook-form v6, finally get some traction

* found source of bug, trying new rhf version

* ...and the bug was slain, returned to that cold, miserable shit heap from whence it came.

* reintroduce devtool and logger

* build metadata form, form segment subForm component

* clean, add custom submit btn text

* clean

* build string validations

* derive validation type from function obj

* wrestled types into validation system

* rebuild form builder as context

* build formBuilder hook, use it in the factory

* create sample test

* update form placement

* more post merge corrections

* write validation updaters and add to pipeline, test required updaters, test validation, test pipeline

* try jest testing

* ensure field state updates on formState change

* more cleaning

* reorg files

* build metadata form

* tweak button styles, add defaultValues to formBuilder

* good place to stop

* remove comments

* fix Jest errors

* fix field wrapper stories, update lock

* may have fixed jest errors

Co-authored-by: Jonathan Prozzi <[email protected]>
Co-authored-by: Alexander Keating <[email protected]>
Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Spencer Graham <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>

* Fix build (#563)

* Fix build

* Almost

* More changes

Co-authored-by: Jord <[email protected]>
Co-authored-by: Jonathan Prozzi <[email protected]>
Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Spencer Graham <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>

* Revert "Develop into master (#577)"

This reverts commit b8644d3.

* connectedAddress votes wip

* adds vote queries

* prevents double list items on dao change

* debugging

* address previous pr feedback

* type issue

Co-authored-by: Jonathan Prozzi <[email protected]>
Co-authored-by: Alexander Keating <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Jord <[email protected]>
Co-authored-by: Spencer Graham <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>
Co-authored-by: jordan <[email protected]>
  • Loading branch information
8 people authored Aug 30, 2022
1 parent c85e42c commit 5ff246e
Show file tree
Hide file tree
Showing 22 changed files with 1,619 additions and 444 deletions.
1 change: 0 additions & 1 deletion apps/core-app/src/components/FilterDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const IconFilter = styled(RiFilterFill)`
`;

type FilterDropdownProps = {
// filter: Record<string, string>;
filter: string;
toggleFilter: (event: MouseEvent<HTMLButtonElement>) => void;
};
Expand Down
6 changes: 3 additions & 3 deletions apps/core-app/src/components/MetadataSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
Link,
} from '@daohaus/ui';

import { TDao, useUserMembership } from '../contexts/DaoContext';
import { TDao, useConnectedMembership } from '../contexts/DaoContext';
import { TagList } from '../components/TagList';
import { useParams } from 'react-router-dom';
import { Keychain } from '@daohaus/common-utilities';
Expand Down Expand Up @@ -54,13 +54,13 @@ type MetadataSettingsProps = {

export const MetadataSettings = ({ dao }: MetadataSettingsProps) => {
const { daochain, daoid } = useParams();
const { userMembership } = useUserMembership();
const { connectedMembership } = useConnectedMembership();

return (
<>
<MetaCardHeader>
<H3>Metadata</H3>
{userMembership && Number(userMembership.shares) && (
{connectedMembership && Number(connectedMembership.shares) && (
<Link href={`/molochv3/${daochain}/${daoid}/settings/update`}>
<Button>Update Settings</Button>
</Link>
Expand Down
27 changes: 23 additions & 4 deletions apps/core-app/src/components/SearchInput.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { ChangeEvent } from 'react';
import { ChangeEvent, useEffect, useState } from 'react';
import styled from 'styled-components';
import { indigoDark } from '@radix-ui/colors';
import { BiSearch } from 'react-icons/bi';
import { Input } from '@daohaus/ui';
import useDebounce from '../utils/debounceHook';

const StyledInput = styled(Input)`
background: ${indigoDark.indigo3};
Expand All @@ -26,7 +27,7 @@ const IconSearch = styled(BiSearch)`

type SearchInputProps = {
searchTerm: string;
setSearchTerm: (event: ChangeEvent<HTMLInputElement>) => void;
setSearchTerm: (term: string) => void;
totalItems: number;
};

Expand All @@ -35,15 +36,33 @@ const SearchInput = ({
setSearchTerm,
totalItems,
}: SearchInputProps) => {
const [localSearchTerm, setLocalSearchTerm] = useState<string>('');

const debouncedSearchTerm = useDebounce<string>(localSearchTerm, 700);

useEffect(() => {
if (localSearchTerm !== searchTerm) {
setSearchTerm(localSearchTerm);
}
// TODO: I don't want to fire on these others!!
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [debouncedSearchTerm]);

const handleSearchTermChange = (event: ChangeEvent<HTMLInputElement>) => {
setLocalSearchTerm((prevState) =>
prevState === event.target.value ? '' : event.target.value
);
};

return (
<StyledInput
icon={IconSearch}
id="table-search"
placeholder={`Search ${totalItems} ${
totalItems === 1 ? 'Proposal' : 'Proposals'
}`}
onChange={setSearchTerm}
defaultValue={searchTerm}
onChange={handleSearchTermChange}
defaultValue={localSearchTerm}
/>
);
};
Expand Down
154 changes: 128 additions & 26 deletions apps/core-app/src/contexts/DaoContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
DaoWithTokenDataQuery,
FindMemberQuery,
ITransformedProposalListQuery,
ListConnectedMemberProposalsQuery,
ListMembersQuery,
Member_Filter,
Member_OrderBy,
Expand All @@ -20,9 +21,11 @@ import {
useState,
SetStateAction,
Dispatch,
useRef,
} from 'react';
import { useParams } from 'react-router-dom';
import {
loadConnectedMemberVotesList,
loadDao,
loadMember,
loadMembersList,
Expand All @@ -40,9 +43,14 @@ export const defaultDaoData = {
refreshDao: async () => {
return;
},
userMembership: null,
isUserMembershipLoading: false,
refreshUserMembership: async () => {
connectedMembership: null,
isConnectedMembershipLoading: false,
refreshConnectedMembership: async () => {
return;
},
connectedMembershipProposalVotes: null,
isConnectedMembershipProposalVotesLoading: false,
refreshConnectedMembershipProposalVotes: async () => {
return;
},
members: null,
Expand Down Expand Up @@ -102,10 +110,16 @@ export type DaoConnectDaoType = {
refreshAll: () => Promise<void>;
};

export type DaoConnectUserMembershipType = {
userMembership: FindMemberQuery['member'] | null | undefined;
isUserMembershipLoading: boolean;
refreshUserMembership: () => Promise<void>;
export type DaoConnectConnectedMembershipType = {
connectedMembership: FindMemberQuery['member'] | null | undefined;
isConnectedMembershipLoading: boolean;
refreshConnectedMembership: () => Promise<void>;
connectedMembershipProposalVotes:
| ListConnectedMemberProposalsQuery['proposals']
| null
| undefined;
isConnectedMembershipProposalVotesLoading: boolean;
refreshConnectedMembershipProposalVotes: () => Promise<void>;
};

export type DaoConnectMembersType = {
Expand Down Expand Up @@ -146,7 +160,7 @@ export type DaoConnectProposalsType = {

interface DaoConnectType
extends DaoConnectDaoType,
DaoConnectUserMembershipType,
DaoConnectConnectedMembershipType,
DaoConnectMembersType,
DaoConnectProposalsType {}

Expand All @@ -164,10 +178,20 @@ export const DaoContextProvider = ({ children }: DaoContextProviderProps) => {
const [dao, setDao] = useState<DaoWithTokenDataQuery['dao'] | undefined>();
const [isDaoLoading, setDaoLoading] = useState(false);

const [userMembership, setUserMembership] = useState<
const [connectedMembership, setConnectedMembership] = useState<
FindMemberQuery['member'] | undefined
>();
const [isUserMembershipLoading, setUserMembershipLoading] = useState(false);
const [isConnectedMembershipLoading, setConnectedMembershipLoading] =
useState(false);

const [
connectedMembershipProposalVotes,
setConnectedMembershipProposalVotes,
] = useState<ListConnectedMemberProposalsQuery['proposals'] | undefined>();
const [
isConnectedMembershipProposalVotesLoading,
setConnectedMembershipProposalVotesLoading,
] = useState(false);

const [members, setMembers] = useState<
ListMembersQuery['members'] | undefined
Expand Down Expand Up @@ -228,8 +252,8 @@ export const DaoContextProvider = ({ children }: DaoContextProviderProps) => {
daoid,
daochain: daochain as keyof Keychain,
address,
setMember: setUserMembership,
setMemberLoading: setUserMembershipLoading,
setMember: setConnectedMembership,
setMemberLoading: setConnectedMembershipLoading,
shouldUpdate,
});
}
Expand All @@ -238,9 +262,13 @@ export const DaoContextProvider = ({ children }: DaoContextProviderProps) => {
};
}, [daochain, daoid, address]);

const currentDaoMembers = useRef<null | string>(null);
useEffect(() => {
let shouldUpdate = true;
if (daoid && daochain) {
if (currentDaoMembers.current && currentDaoMembers.current !== daoid) {
setMembers(undefined);
}
loadMembersList({
filter: { dao: daoid, ...membersFilter },
ordering: membersSort,
Expand All @@ -251,16 +279,26 @@ export const DaoContextProvider = ({ children }: DaoContextProviderProps) => {
setNextPaging: setMembersNextPaging,
shouldUpdate,
});
currentDaoMembers.current = daoid;
}
return () => {
shouldUpdate = false;
};
}, [daochain, daoid, membersFilter, membersSort, membersPaging]);

const currentDaoProposals = useRef<null | string>(null);
useEffect(() => {
let shouldUpdate = true;

console.log('prop useeffect fired');
if (daochain && daoid) {
console.log('proposalsFilter', proposalsFilter);
if (
currentDaoProposals.current &&
currentDaoProposals.current !== daoid
) {
console.log('CLEAR');
setProposals(undefined);
}
loadProposalsList({
filter: { dao: daoid, ...proposalsFilter },
ordering: proposalsSort,
Expand All @@ -271,18 +309,56 @@ export const DaoContextProvider = ({ children }: DaoContextProviderProps) => {
setNextPaging: setProposalsNextPaging,
shouldUpdate,
});
currentDaoProposals.current = daoid;
}

return () => {
shouldUpdate = false;
};
}, [daochain, daoid, proposalsFilter, proposalsSort, proposalsPaging]);

const currentDaoConnectedMembershipProposalVotes = useRef<null | string>(
null
);
useEffect(() => {
let shouldUpdate = true;
if (daochain && daoid && address) {
if (
currentDaoConnectedMembershipProposalVotes.current &&
currentDaoConnectedMembershipProposalVotes.current !== daoid
) {
setConnectedMembershipProposalVotes(undefined);
}
loadConnectedMemberVotesList({
filter: { dao: daoid, ...proposalsFilter },
ordering: proposalsSort,
paging: proposalsPaging,
daochain: daochain as keyof Keychain,
setData: setConnectedMembershipProposalVotes,
setLoading: setConnectedMembershipProposalVotesLoading,
shouldUpdate,
memberAddress: address,
});
currentDaoConnectedMembershipProposalVotes.current = daoid;
}

return () => {
shouldUpdate = false;
};
}, [
daochain,
daoid,
proposalsFilter,
proposalsSort,
proposalsPaging,
address,
]);

const refreshAll = async () => {
refreshDao();
refreshMembers();
refreshProposals();
refreshUserMembership();
refreshConnectedMembership();
};

const refreshDao = async () => {
Expand All @@ -296,14 +372,14 @@ export const DaoContextProvider = ({ children }: DaoContextProviderProps) => {
});
}
};
const refreshUserMembership = async () => {
const refreshConnectedMembership = async () => {
if (daochain && daoid && address) {
loadMember({
daoid,
daochain: daochain as keyof Keychain,
address,
setMember: setUserMembership,
setMemberLoading: setUserMembershipLoading,
setMember: setConnectedMembership,
setMemberLoading: setConnectedMembershipLoading,
shouldUpdate: true,
});
}
Expand Down Expand Up @@ -336,6 +412,20 @@ export const DaoContextProvider = ({ children }: DaoContextProviderProps) => {
});
}
};
const refreshConnectedMembershipProposalVotes = async () => {
if (daochain && daoid && address) {
loadConnectedMemberVotesList({
filter: { dao: daoid, ...proposalsFilter },
ordering: proposalsSort,
paging: proposalsPaging,
daochain: daochain as keyof Keychain,
setData: setConnectedMembershipProposalVotes,
setLoading: setConnectedMembershipProposalVotesLoading,
shouldUpdate: false,
memberAddress: address,
});
}
};

const getNextPage = async (entity: string): Promise<void> => {
if (entity === 'members' && membersNextPaging) {
Expand All @@ -352,9 +442,12 @@ export const DaoContextProvider = ({ children }: DaoContextProviderProps) => {
dao,
isDaoLoading,
refreshDao,
userMembership,
isUserMembershipLoading,
refreshUserMembership,
connectedMembership,
isConnectedMembershipLoading,
refreshConnectedMembership,
connectedMembershipProposalVotes,
isConnectedMembershipProposalVotesLoading,
refreshConnectedMembershipProposalVotes,
members,
setMembers,
isMembersLoading,
Expand Down Expand Up @@ -395,13 +488,22 @@ export const useDao = (): DaoConnectDaoType => {
refreshAll,
};
};
export const useUserMembership = (): DaoConnectUserMembershipType => {
const { userMembership, isUserMembershipLoading, refreshUserMembership } =
useContext(DaoContext);
export const useConnectedMembership = (): DaoConnectConnectedMembershipType => {
const {
connectedMembership,
isConnectedMembershipLoading,
refreshConnectedMembership,
connectedMembershipProposalVotes,
isConnectedMembershipProposalVotesLoading,
refreshConnectedMembershipProposalVotes,
} = useContext(DaoContext);
return {
userMembership,
isUserMembershipLoading,
refreshUserMembership,
connectedMembership,
isConnectedMembershipLoading,
refreshConnectedMembership,
connectedMembershipProposalVotes,
isConnectedMembershipProposalVotesLoading,
refreshConnectedMembershipProposalVotes,
};
};
export const useMembers = (): DaoConnectMembersType => {
Expand Down
Loading

0 comments on commit 5ff246e

Please sign in to comment.