mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-11-13 02:07:06 +00:00
feat: initial Pezkuwi Apps rebrand from polkadot-apps
Rebranded terminology: - Polkadot → Pezkuwi - Kusama → Dicle - Westend → Zagros - Rococo → PezkuwiChain - Substrate → Bizinikiwi - parachain → teyrchain Custom logos with Kurdistan brand colors (#e6007a → #86e62a): - bizinikiwi-hexagon.svg - sora-bizinikiwi.svg - hezscanner.svg - heztreasury.svg - pezkuwiscan.svg - pezkuwistats.svg - pezkuwiassembly.svg - pezkuwiholic.svg
This commit is contained in:
commit
d21bfb1320
5867 files changed
+329019
No files matched your search
@@ -0,0 +1,41 @@
|
||||
// Copyright 2017-2025 @pezkuwi/app-referenda authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Changes } from '@pezkuwi/react-hooks/useEventChanges';
|
||||
import type { StorageKey } from '@pezkuwi/types';
|
||||
import type { AccountId32, EventRecord } from '@pezkuwi/types/interfaces';
|
||||
import type { PalletColl } from './types.js';
|
||||
|
||||
import { createNamedHook, useApi, useEventChanges, useMapKeys } from '@pezkuwi/react-hooks';
|
||||
|
||||
const OPT_ID = {
|
||||
transform: (keys: StorageKey<[AccountId32]>[]): AccountId32[] =>
|
||||
keys.map(({ args: [id] }) => id)
|
||||
};
|
||||
|
||||
function filter (records: EventRecord[]): Changes<AccountId32> {
|
||||
const added: AccountId32[] = [];
|
||||
const removed: AccountId32[] = [];
|
||||
|
||||
records.forEach(({ event: { data: [id], method } }): void => {
|
||||
if (method === 'MemberAdded') {
|
||||
added.push(id as AccountId32);
|
||||
} else {
|
||||
removed.push(id as AccountId32);
|
||||
}
|
||||
});
|
||||
|
||||
return { added, removed };
|
||||
}
|
||||
|
||||
function useMemberIdsImpl (collective: PalletColl): AccountId32[] | undefined {
|
||||
const { api } = useApi();
|
||||
const startValue = useMapKeys(api.query[collective].members, [], OPT_ID);
|
||||
|
||||
return useEventChanges([
|
||||
api.events[collective].MemberAdded,
|
||||
api.events[collective].MemberRemoved
|
||||
], filter, startValue);
|
||||
}
|
||||
|
||||
export default createNamedHook('useMemberIds', useMemberIdsImpl);
|
||||
Reference in new issue
Block a user