interface: fix group feed settings render

This commit is contained in:
Logan Allen 2021-04-01 19:14:38 -05:00
parent 15f92702f2
commit 95cae3e36b

View File

@ -10,6 +10,9 @@ import {
import { FormSubmit } from "~/views/components/FormSubmit";
import { StatelessAsyncToggle } from "~/views/components/StatelessAsyncToggle";
import useMetadataState from '~/logic/state/metadata';
interface FormSchema {
permissions: GroupFeedPermissions;
}
@ -20,22 +23,26 @@ export function GroupFeedSettings(props: {
api: GlobalApi;
}) {
const { association, group, api } = props;
const isEnabled = !!association?.metadata?.config?.group;
const resource = resourceFromPath(association.group);
const feedResource = association?.metadata.config?.group?.resource;
const toggleFeed = async () => {
const isEnabled = !!feedResource;
const associations = useMetadataState(state => state.associations);
const feedMetadata = associations?.graph[feedResource];
const vip = feedMetadata?.vip || '';
const toggleFeed = async (actions: any) => {
if (isEnabled) {
await api.graph.disableGroupFeed(resource);
} else {
await api.graph.enableGroupFeed(resource);
await api.graph.enableGroupFeed(resource, vip);
}
};
const writers: Set<string> | undefined =
group.tags.graph?.[feedResource]?.writers;
const initialValues: FormSchema = {
permissions: !writers
? "everyone"
: writers.size === 1 && writers.has(window.ship)
permissions: vip === '' && !writers ? 'everyone' :
writers.size === 1 && writers.has(window.ship)
? "host"
: "admins",
};
@ -76,7 +83,7 @@ export function GroupFeedSettings(props: {
</Label>
</Col>
</BaseLabel>
{isEnabled && (
{isEnabled && false && (
<>
<GroupFeedPermsInput id="permissions" />
<FormSubmit start>Update Permissions</FormSubmit>