mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-12 15:01:38 +03:00
interface: remove chat special-casing
This commit is contained in:
parent
5cef1cfe70
commit
b516926510
@ -50,53 +50,22 @@ export function ChannelMenu(props: ChannelMenuProps) {
|
||||
|
||||
const isOurs = ship.slice(1) === window.ship;
|
||||
|
||||
const isMuted = appIsGraph(app)
|
||||
? props.graphNotificationConfig.watching.findIndex(
|
||||
const isMuted =
|
||||
props.graphNotificationConfig.watching.findIndex(
|
||||
(a) => a.graph === appPath && a.index === "/"
|
||||
) === -1
|
||||
: props.chatNotificationConfig.findIndex((a) => a === appPath) === -1;
|
||||
) === -1;
|
||||
|
||||
const onChangeMute = async () => {
|
||||
if (association["app-name"] === "chat") {
|
||||
const func = isMuted ? "listenChat" : "ignoreChat";
|
||||
return api.hark[func](appPath);
|
||||
}
|
||||
const func = isMuted ? "listenGraph" : "ignoreGraph";
|
||||
await api.hark[func](appPath, "/");
|
||||
};
|
||||
const onUnsubscribe = useCallback(async () => {
|
||||
const app = metadata.module || association["app-name"];
|
||||
switch (app) {
|
||||
case "chat":
|
||||
await api.chat.delete(appPath);
|
||||
break;
|
||||
case "publish":
|
||||
await api.graph.leaveGraph(ship, name);
|
||||
break;
|
||||
case "link":
|
||||
await api.graph.leaveGraph(ship, name);
|
||||
break;
|
||||
default:
|
||||
throw new Error("Invalid app name");
|
||||
}
|
||||
await api.graph.leaveGraph(ship, name);
|
||||
history.push(`/~landscape${workspace}`);
|
||||
}, [api, association]);
|
||||
|
||||
const onDelete = useCallback(async () => {
|
||||
const app = metadata.module || association["app-name"];
|
||||
switch (app) {
|
||||
case "chat":
|
||||
await api.chat.delete(appPath);
|
||||
break;
|
||||
case "publish":
|
||||
await api.graph.deleteGraph(name);
|
||||
break;
|
||||
case "link":
|
||||
await api.graph.deleteGraph(name);
|
||||
break;
|
||||
default:
|
||||
throw new Error("Invalid app name");
|
||||
}
|
||||
await api.graph.deleteGraph(name);
|
||||
history.push(`/~landscape${workspace}`);
|
||||
}, [api, association]);
|
||||
|
||||
|
@ -14,7 +14,7 @@ import GlobalApi from '~/logic/api/global';
|
||||
import { AsyncButton } from '~/views/components/AsyncButton';
|
||||
import { FormError } from '~/views/components/FormError';
|
||||
import { RouteComponentProps } from 'react-router-dom';
|
||||
import { stringToSymbol, parentPath } from '~/logic/lib/util';
|
||||
import { stringToSymbol, parentPath, deSig } from '~/logic/lib/util';
|
||||
import { resourceFromPath } from '~/logic/lib/group';
|
||||
import { Associations } from '~/types/metadata-update';
|
||||
import { useWaitForProps } from '~/logic/lib/useWaitForProps';
|
||||
@ -81,7 +81,7 @@ export function NewChannel(props: NewChannelProps & RouteComponentProps) {
|
||||
resId,
|
||||
name,
|
||||
description,
|
||||
{ invite: { pending: ships.map(s => `~${s}`) } },
|
||||
{ invite: { pending: ships.map(s => `~${deSig(s)}`) } },
|
||||
moduleType
|
||||
);
|
||||
}
|
||||
|
@ -3,11 +3,11 @@ import _ from 'lodash';
|
||||
|
||||
import { Icon, Row, Box, Text } from "@tlon/indigo-react";
|
||||
|
||||
import { Association } from "~/types/metadata-update";
|
||||
|
||||
import { SidebarAppConfigs, SidebarItemStatus } from "./Sidebar";
|
||||
import { HoverBoxLink } from "~/views/components/HoverBox";
|
||||
import { Groups } from "~/types";
|
||||
import { Groups, Association } from "~/types";
|
||||
|
||||
import { cite } from "~/logic/lib/util";
|
||||
|
||||
function SidebarItemIndicator(props: { status?: SidebarItemStatus }) {
|
||||
switch (props.status) {
|
||||
@ -34,14 +34,14 @@ const getAppIcon = (app: string, mod: string) => {
|
||||
return _.capitalize(app);
|
||||
};
|
||||
|
||||
const DM_REGEX = /\/~([a-z]|-)*\/dm--/;
|
||||
const DM_REGEX = /ship\/~([a-z]|-)*\/dm--/;
|
||||
function getItemTitle(association: Association) {
|
||||
if(DM_REGEX.test(association['app-path'])) {
|
||||
const [,ship,name] = association['app-path'].split('/');
|
||||
const [,,ship,name] = association['app-path'].split('/');
|
||||
if(ship.slice(1) === window.ship) {
|
||||
return `~${name.slice(4)}`;
|
||||
return cite(`~${name.slice(4)}`);
|
||||
}
|
||||
return ship;
|
||||
return cite(ship);
|
||||
|
||||
}
|
||||
return association.metadata.title || association['app-path'];
|
||||
|
Loading…
Reference in New Issue
Block a user