mirror of
https://github.com/urbit/shrub.git
synced 2024-12-19 16:51:42 +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'
|
py='2'
|
||||||
cursor='pointer'
|
cursor='pointer'
|
||||||
fontWeight='500'
|
fontWeight='500'
|
||||||
onClick={() => history.push(`/~landscape/dm/${ship.substring(1)}`)}
|
onClick={() => history.push(`/~landscape/messages/dm/${ship}`)}
|
||||||
>
|
>
|
||||||
Message
|
Message
|
||||||
</Text>
|
</Text>
|
||||||
|
@ -62,7 +62,7 @@ export function NewChannel(props: NewChannelProps): ReactElement {
|
|||||||
let { description, moduleType, ships, writers } = values;
|
let { description, moduleType, ships, writers } = values;
|
||||||
ships = ships.filter(e => e !== '');
|
ships = ships.filter(e => e !== '');
|
||||||
if (workspace?.type === 'messages' && ships.length === 1) {
|
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) {
|
if (group) {
|
||||||
await api.graph.createManagedGraph(
|
await api.graph.createManagedGraph(
|
||||||
|
@ -102,9 +102,10 @@ function SidebarItemBase(props: {
|
|||||||
|
|
||||||
export function SidebarDmItem(props: {
|
export function SidebarDmItem(props: {
|
||||||
ship: string;
|
ship: string;
|
||||||
|
selected?: boolean;
|
||||||
workspace: Workspace;
|
workspace: Workspace;
|
||||||
}) {
|
}) {
|
||||||
const { ship } = props;
|
const { ship, selected = false} = props;
|
||||||
const contact = useContact(ship);
|
const contact = useContact(ship);
|
||||||
const title = contact?.nickname ?? cite(ship) ?? ship;
|
const title = contact?.nickname ?? cite(ship) ?? ship;
|
||||||
const hideAvatars = false;
|
const hideAvatars = false;
|
||||||
@ -116,7 +117,7 @@ export function SidebarDmItem(props: {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<SidebarItemBase
|
<SidebarItemBase
|
||||||
selected={false}
|
selected={selected}
|
||||||
hasNotification={false}
|
hasNotification={false}
|
||||||
hasUnread={false}
|
hasUnread={false}
|
||||||
to={`/~landscape/messages/dm/${ship}`}
|
to={`/~landscape/messages/dm/${ship}`}
|
||||||
|
@ -83,7 +83,7 @@ export function SidebarList(props: {
|
|||||||
|
|
||||||
|
|
||||||
const ordered = getItems(associations, workspace, inbox);
|
const ordered = getItems(associations, workspace, inbox);
|
||||||
//.sort(sidebarSort(associations, props.apps)[config.sortBy]);
|
//.sort(sidebarSort(associations, props.apps)[config.sortBy]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -104,6 +104,7 @@ export function SidebarList(props: {
|
|||||||
key={pathOrShip}
|
key={pathOrShip}
|
||||||
ship={pathOrShip}
|
ship={pathOrShip}
|
||||||
workspace={workspace}
|
workspace={workspace}
|
||||||
|
selected={pathOrShip === selected}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
);
|
);
|
||||||
|
@ -51,46 +51,6 @@ type LandscapeProps = StoreState & {
|
|||||||
subscription: GlobalSubscription;
|
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) {
|
export default function Landscape(props) {
|
||||||
const notificationsCount = useHarkState(s => s.notificationsCount);
|
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?"
|
<Route path="/~landscape/join/:ship?/:name?"
|
||||||
render={(routeProps) => {
|
render={(routeProps) => {
|
||||||
const { ship, name } = routeProps.match.params;
|
const { ship, name } = routeProps.match.params;
|
||||||
|
Loading…
Reference in New Issue
Block a user