landscape: mentions direct to group's identity

"Edit identity" always redirected us to the root identity page.

This passes the 'group' prop and also shims over an issue where comments
pages would produce interface crashes if you attempted to edit your
identity from there.
This commit is contained in:
Matilde Park 2020-12-10 12:28:10 -05:00
parent cf88b8525e
commit 4b5bd0a238
9 changed files with 30 additions and 16 deletions

View File

@ -253,13 +253,14 @@ export class MessageWithSigil extends PureComponent<MessageProps> {
<Text flexShrink={0} gray mono ml={2} className="v-mid child dn-s">{datestamp}</Text> <Text flexShrink={0} gray mono ml={2} className="v-mid child dn-s">{datestamp}</Text>
</Box> </Box>
<ContentBox flexShrink={0} fontSize={fontSize ? fontSize : '14px'}> <ContentBox flexShrink={0} fontSize={fontSize ? fontSize : '14px'}>
{msg.contents.map(c => {msg.contents.map(c =>
<MessageContent <MessageContent
contacts={contacts} contacts={contacts}
content={c} content={c}
remoteContentPolicy={remoteContentPolicy} remoteContentPolicy={remoteContentPolicy}
measure={measure} measure={measure}
fontSize={fontSize} fontSize={fontSize}
group={group}
/>)} />)}
</ContentBox> </ContentBox>
</Box> </Box>
@ -275,16 +276,16 @@ const ContentBox = styled(Box)`
`; `;
export const MessageWithoutSigil = ({ timestamp, contacts, msg, remoteContentPolicy, measure }) => ( export const MessageWithoutSigil = ({ timestamp, contacts, msg, remoteContentPolicy, measure, group }) => (
<> <>
<Text flexShrink={0} mono gray display='inline-block' pt='2px' lineHeight='tall' className="child">{timestamp}</Text> <Text flexShrink={0} mono gray display='inline-block' pt='2px' lineHeight='tall' className="child">{timestamp}</Text>
<ContentBox flexShrink={0} fontSize='14px' className="clamp-message" style={{ flexGrow: 1 }}> <ContentBox flexShrink={0} fontSize='14px' className="clamp-message" style={{ flexGrow: 1 }}>
{msg.contents.map(c => (<MessageContent contacts={contacts} content={c} remoteContentPolicy={remoteContentPolicy} measure={measure}/>))} {msg.contents.map(c => (<MessageContent contacts={contacts} content={c} group={group} remoteContentPolicy={remoteContentPolicy} measure={measure}/>))}
</ContentBox> </ContentBox>
</> </>
); );
export const MessageContent = ({ content, contacts, remoteContentPolicy, measure, fontSize }) => { export const MessageContent = ({ content, contacts, remoteContentPolicy, measure, fontSize, group }) => {
if ('code' in content) { if ('code' in content) {
return <CodeContent content={content} />; return <CodeContent content={content} />;
} else if ('url' in content) { } else if ('url' in content) {
@ -313,7 +314,7 @@ export const MessageContent = ({ content, contacts, remoteContentPolicy, measure
} else if ('text' in content) { } else if ('text' in content) {
return <TextContent fontSize={fontSize} content={content} />; return <TextContent fontSize={fontSize} content={content} />;
} else if ('mention' in content) { } else if ('mention' in content) {
return <Mention ship={content.mention} contacts={contacts} /> return <Mention group={group} ship={content.mention} contacts={contacts} />
} else { } else {
return null; return null;
} }

View File

@ -79,6 +79,7 @@ const GraphNodeContent = ({ group, post, contacts, mod, description, index, remo
return <MentionText return <MentionText
content={contents} content={contents}
contacts={contacts} contacts={contacts}
group={group}
remoteContentPolicy={remoteContentPolicy} remoteContentPolicy={remoteContentPolicy}
/> />
} }
@ -88,6 +89,7 @@ const GraphNodeContent = ({ group, post, contacts, mod, description, index, remo
if (idx[1] === "2") { if (idx[1] === "2") {
return <MentionText return <MentionText
content={contents} content={contents}
group={group}
contacts={contacts} contacts={contacts}
remoteContentPolicy={remoteContentPolicy} remoteContentPolicy={remoteContentPolicy}
/> />
@ -182,7 +184,7 @@ const GraphNode = ({
); );
const groupContacts = contacts[groupPath] ?? {}; const groupContacts = contacts[groupPath] ?? {};
const nodeUrl = getNodeUrl(mod, group.hidden ? '/home' : groupPath, graph, index); const nodeUrl = getNodeUrl(mod, group.hidden ? '/home' : groupPath, graph, index);
const onClick = useCallback(() => { const onClick = useCallback(() => {

View File

@ -10,7 +10,7 @@ import { NoteNavigation } from "./NoteNavigation";
import GlobalApi from "~/logic/api/global"; import GlobalApi from "~/logic/api/global";
import { getLatestRevision, getComments } from '~/logic/lib/publish'; import { getLatestRevision, getComments } from '~/logic/lib/publish';
import Author from "~/views/components/Author"; import Author from "~/views/components/Author";
import { Contacts, GraphNode, Graph, LocalUpdateRemoteContentPolicy, Association, Unreads } from "~/types"; import { Contacts, GraphNode, Graph, LocalUpdateRemoteContentPolicy, Association, Unreads, Group } from "~/types";
interface NoteProps { interface NoteProps {
ship: string; ship: string;
@ -26,12 +26,13 @@ interface NoteProps {
remoteContentPolicy: LocalUpdateRemoteContentPolicy; remoteContentPolicy: LocalUpdateRemoteContentPolicy;
rootUrl: string; rootUrl: string;
baseUrl: string; baseUrl: string;
group: Group;
} }
export function Note(props: NoteProps & RouteComponentProps) { export function Note(props: NoteProps & RouteComponentProps) {
const [deleting, setDeleting] = useState(false); const [deleting, setDeleting] = useState(false);
const { notebook, note, contacts, ship, book, api, rootUrl, baseUrl } = props; const { notebook, note, contacts, ship, book, api, rootUrl, baseUrl, group } = props;
const editCommentId = props.match.params.commentId; const editCommentId = props.match.params.commentId;
const deletePost = async () => { const deletePost = async () => {
@ -126,6 +127,7 @@ export function Note(props: NoteProps & RouteComponentProps) {
baseUrl={baseUrl} baseUrl={baseUrl}
editCommentId={editCommentId} editCommentId={editCommentId}
history={props.history} history={props.history}
group={group}
/> />
<Spinner <Spinner
text="Deleting post..." text="Deleting post..."

View File

@ -22,6 +22,7 @@ interface NoteRoutesProps {
association: Association; association: Association;
baseUrl?: string; baseUrl?: string;
rootUrl?: string; rootUrl?: string;
group: Group;
} }
export function NoteRoutes(props: NoteRoutesProps & RouteComponentProps) { export function NoteRoutes(props: NoteRoutesProps & RouteComponentProps) {
@ -38,7 +39,7 @@ export function NoteRoutes(props: NoteRoutesProps & RouteComponentProps) {
/> />
<Route <Route
path={relativePath("/:commentId?")} path={relativePath("/:commentId?")}
render={(routeProps) => render={(routeProps) =>
<Note <Note
baseUrl={baseUrl} baseUrl={baseUrl}
{...props} {...props}

View File

@ -42,7 +42,7 @@ interface NotebookRoutesProps {
export function NotebookRoutes( export function NotebookRoutes(
props: NotebookRoutesProps & RouteComponentProps props: NotebookRoutesProps & RouteComponentProps
) { ) {
const { ship, book, api, notebookContacts, baseUrl, rootUrl } = props; const { ship, book, api, notebookContacts, baseUrl, rootUrl, groups } = props;
useEffect(() => { useEffect(() => {
ship && book && api.graph.getGraph(ship, book); ship && book && api.graph.getGraph(ship, book);
@ -50,6 +50,8 @@ export function NotebookRoutes(
const graph = props.graphs[`${ship.slice(1)}/${book}`]; const graph = props.graphs[`${ship.slice(1)}/${book}`];
const group = groups?.[props.association?.['group-path']];
const relativePath = (path: string) => `${baseUrl}${path}`; const relativePath = (path: string) => `${baseUrl}${path}`;
return ( return (
@ -114,6 +116,7 @@ export function NotebookRoutes(
hideAvatars={props.hideAvatars} hideAvatars={props.hideAvatars}
hideNicknames={props.hideNicknames} hideNicknames={props.hideNicknames}
remoteContentPolicy={props.remoteContentPolicy} remoteContentPolicy={props.remoteContentPolicy}
group={group}
{...routeProps} {...routeProps}
/> />
); );

View File

@ -79,6 +79,7 @@ export function CommentItem(props: CommentItemProps) {
<Box mb={2}> <Box mb={2}>
<MentionText <MentionText
contacts={contacts} contacts={contacts}
group={group}
content={post?.contents} content={post?.contents}
remoteContentPolicy={remoteContentPolicy} remoteContentPolicy={remoteContentPolicy}
/> />

View File

@ -97,7 +97,7 @@ export function Comments(props: CommentsProps) {
useEffect(() => { useEffect(() => {
console.log(`dismissing ${association?.['app-path']}`); console.log(`dismissing ${association?.['app-path']}`);
return () => { return () => {
api.hark.markCountAsRead(association, parentIndex, 'comment') api.hark.markCountAsRead(association, parentIndex, 'comment')
}; };
}, [comments.post.index]) }, [comments.post.index])
@ -130,6 +130,7 @@ export function Comments(props: CommentsProps) {
hideAvatars={props.hideAvatars} hideAvatars={props.hideAvatars}
remoteContentPolicy={props.remoteContentPolicy} remoteContentPolicy={props.remoteContentPolicy}
baseUrl={props.baseUrl} baseUrl={props.baseUrl}
group={group}
pending={idx.toString() === props.editCommentId} pending={idx.toString() === props.editCommentId}
/> />
); );

View File

@ -15,10 +15,11 @@ import {useHistory} from "react-router-dom";
interface MentionTextProps { interface MentionTextProps {
contacts: Contacts; contacts: Contacts;
content: Content[]; content: Content[];
group: Group;
remoteContentPolicy: LocalUpdateRemoteContentPolicy; remoteContentPolicy: LocalUpdateRemoteContentPolicy;
} }
export function MentionText(props: MentionTextProps) { export function MentionText(props: MentionTextProps) {
const { content, contacts } = props; const { content, contacts, group } = props;
return ( return (
<> <>
@ -35,7 +36,7 @@ export function MentionText(props: MentionTextProps) {
); );
} else if ("mention" in c) { } else if ("mention" in c) {
return ( return (
<Mention key={idx} contacts={contacts || {}} ship={c.mention} /> <Mention key={idx} contacts={contacts || {}} group={group} ship={c.mention} />
); );
} }
return null; return null;

View File

@ -12,7 +12,7 @@ type ProfileOverlayProps = ColProps & {
ship: string; ship: string;
contact?: Contact; contact?: Contact;
color: string; color: string;
topSpace: number | 'auto'; topSpace: number | 'auto';
bottomSpace: number | 'auto'; bottomSpace: number | 'auto';
group?: Group; group?: Group;
onDismiss(): void; onDismiss(): void;
@ -98,6 +98,8 @@ export class ProfileOverlay extends PureComponent<ProfileOverlayProps, {}> {
const isHidden = group ? group.hidden : false; const isHidden = group ? group.hidden : false;
const rootSettings = history.location.pathname.slice(0, history.location.pathname.indexOf("/resource"));
return ( return (
<Col <Col
ref={this.popoverRef} ref={this.popoverRef}
@ -135,7 +137,7 @@ export class ProfileOverlay extends PureComponent<ProfileOverlayProps, {}> {
mt='2' mt='2'
width='100%' width='100%'
style={{ cursor: 'pointer ' }} style={{ cursor: 'pointer ' }}
onClick={() => (isHidden) ? history.push('/~profile/identity') : history.push(`${history.location.pathname}/popover/profile`)} onClick={() => (isHidden) ? history.push('/~profile/identity') : history.push(`${rootSettings}/popover/profile`)}
> >
Edit Identity Edit Identity
</Button> </Button>