mirror of
https://github.com/urbit/shrub.git
synced 2024-12-19 16:51:42 +03:00
interface: add getters for stores
This commit is contained in:
parent
63b3a37d86
commit
86552306c2
@ -16,7 +16,7 @@ const useGroupState = createState<GroupState>('Group', {
|
||||
}, ['groups']);
|
||||
|
||||
export function useGroup(group: string) {
|
||||
return useGroupState(useCallback(s => s.groups[group], [group]));
|
||||
return useGroupState(useCallback(s => s.groups[group] as Group | undefined, [group]));
|
||||
}
|
||||
|
||||
export function useGroupForAssoc(association: Association) {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { MetadataUpdatePreview, Associations } from "@urbit/api";
|
||||
import { useCallback } from 'react';
|
||||
import { MetadataUpdatePreview, Association, Associations } from "@urbit/api";
|
||||
|
||||
import { BaseState, createState } from "./base";
|
||||
|
||||
@ -9,6 +10,14 @@ export interface MetadataState extends BaseState<MetadataState> {
|
||||
// preview: (group: string) => Promise<MetadataUpdatePreview>;
|
||||
};
|
||||
|
||||
export function useAssocForGraph(graph: string) {
|
||||
return useMetadataState(useCallback(s => s.associations.graph[graph] as Association | undefined, [graph]));
|
||||
}
|
||||
|
||||
export function useAssocForGroup(group: string) {
|
||||
return useMetadataState(useCallback(s => s.associations.groups[group] as Association | undefined, [group]));
|
||||
}
|
||||
|
||||
const useMetadataState = createState<MetadataState>('Metadata', {
|
||||
associations: { groups: {}, graph: {}, contacts: {}, chat: {}, link: {}, publish: {} },
|
||||
// preview: async (group): Promise<MetadataUpdatePreview> => {
|
||||
@ -54,4 +63,4 @@ const useMetadataState = createState<MetadataState>('Metadata', {
|
||||
});
|
||||
|
||||
|
||||
export default useMetadataState;
|
||||
export default useMetadataState;
|
||||
|
Loading…
Reference in New Issue
Block a user