mirror of
https://github.com/urbit/shrub.git
synced 2024-12-23 19:05:48 +03:00
interface: update DM creation route
This commit is contained in:
parent
2b20196767
commit
f2f0cac31e
@ -157,7 +157,7 @@ export function ProfileActions(props: any): ReactElement {
|
||||
py='2'
|
||||
cursor='pointer'
|
||||
fontWeight='500'
|
||||
onClick={() => history.push(`/~landscape/dm/${ship.substring(1)}`)}
|
||||
onClick={() => history.push(`/~landscape/messages/dm/${ship}`)}
|
||||
>
|
||||
Message
|
||||
</Text>
|
||||
|
@ -62,7 +62,7 @@ export function NewChannel(props: NewChannelProps): ReactElement {
|
||||
let { description, moduleType, ships, writers } = values;
|
||||
ships = ships.filter(e => e !== '');
|
||||
if (workspace?.type === 'messages' && ships.length === 1) {
|
||||
return history.push(`/~landscape/dm/${deSig(ships[0])}`);
|
||||
return history.push(`/~landscape/messages/dm/${deSig(ships[0])}`);
|
||||
}
|
||||
if (group) {
|
||||
await api.graph.createManagedGraph(
|
||||
|
@ -102,9 +102,10 @@ function SidebarItemBase(props: {
|
||||
|
||||
export function SidebarDmItem(props: {
|
||||
ship: string;
|
||||
selected?: boolean;
|
||||
workspace: Workspace;
|
||||
}) {
|
||||
const { ship } = props;
|
||||
const { ship, selected = false} = props;
|
||||
const contact = useContact(ship);
|
||||
const title = contact?.nickname ?? cite(ship) ?? ship;
|
||||
const hideAvatars = false;
|
||||
@ -116,7 +117,7 @@ export function SidebarDmItem(props: {
|
||||
|
||||
return (
|
||||
<SidebarItemBase
|
||||
selected={false}
|
||||
selected={selected}
|
||||
hasNotification={false}
|
||||
hasUnread={false}
|
||||
to={`/~landscape/messages/dm/${ship}`}
|
||||
|
@ -83,7 +83,7 @@ export function SidebarList(props: {
|
||||
|
||||
|
||||
const ordered = getItems(associations, workspace, inbox);
|
||||
//.sort(sidebarSort(associations, props.apps)[config.sortBy]);
|
||||
//.sort(sidebarSort(associations, props.apps)[config.sortBy]);
|
||||
|
||||
return (
|
||||
<>
|
||||
@ -104,6 +104,7 @@ export function SidebarList(props: {
|
||||
key={pathOrShip}
|
||||
ship={pathOrShip}
|
||||
workspace={workspace}
|
||||
selected={pathOrShip === selected}
|
||||
/>
|
||||
|
||||
);
|
||||
|
@ -51,46 +51,6 @@ type LandscapeProps = StoreState & {
|
||||
subscription: GlobalSubscription;
|
||||
}
|
||||
|
||||
export function DMRedirect(props: LandscapeProps & RouteComponentProps & { ship: string; }): ReactElement {
|
||||
const { ship, api, history } = props;
|
||||
const goToGraph = useCallback((graph: string) => {
|
||||
history.push(`/~landscape/messages/resource/chat/ship/~${graph}`);
|
||||
}, [history]);
|
||||
const graphKeys = useGraphState(state => state.graphKeys);
|
||||
|
||||
useEffect(() => {
|
||||
const station = `${window.ship}/dm--${ship}`;
|
||||
const theirStation = `${ship}/dm--${window.ship}`;
|
||||
|
||||
if (graphKeys.has(station)) {
|
||||
goToGraph(station);
|
||||
return;
|
||||
}
|
||||
|
||||
if (graphKeys.has(theirStation)) {
|
||||
goToGraph(theirStation);
|
||||
return;
|
||||
}
|
||||
|
||||
const aud = ship !== window.ship ? [`~${ship}`] : [];
|
||||
const title = `${cite(window.ship)} <-> ${cite(ship)}`;
|
||||
|
||||
api.graph.createUnmanagedGraph(
|
||||
`dm--${ship}`,
|
||||
title,
|
||||
'',
|
||||
{ invite: { pending: aud } },
|
||||
'chat'
|
||||
).then(() => {
|
||||
goToGraph(station);
|
||||
});
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Loading text="Creating DM" />
|
||||
);
|
||||
}
|
||||
|
||||
export default function Landscape(props) {
|
||||
const notificationsCount = useHarkState(s => s.notificationsCount);
|
||||
|
||||
@ -145,12 +105,6 @@ export default function Landscape(props) {
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<Route path='/~landscape/dm/:ship?'
|
||||
render={(routeProps) => {
|
||||
const { ship } = routeProps.match.params;
|
||||
return <DMRedirect {...routeProps} {...props} ship={ship} />;
|
||||
}}
|
||||
/>
|
||||
<Route path="/~landscape/join/:ship?/:name?"
|
||||
render={(routeProps) => {
|
||||
const { ship, name } = routeProps.match.params;
|
||||
|
Loading…
Reference in New Issue
Block a user