mirror of
https://github.com/urbit/shrub.git
synced 2024-12-23 19:05:48 +03:00
interface: fix group feed settings render
This commit is contained in:
parent
15f92702f2
commit
95cae3e36b
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user