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>
</Box>
<ContentBox flexShrink={0} fontSize={fontSize ? fontSize : '14px'}>
{msg.contents.map(c =>
<MessageContent
{msg.contents.map(c =>
<MessageContent
contacts={contacts}
content={c}
remoteContentPolicy={remoteContentPolicy}
measure={measure}
fontSize={fontSize}
group={group}
/>)}
</ContentBox>
</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>
<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>
</>
);
export const MessageContent = ({ content, contacts, remoteContentPolicy, measure, fontSize }) => {
export const MessageContent = ({ content, contacts, remoteContentPolicy, measure, fontSize, group }) => {
if ('code' in content) {
return <CodeContent content={content} />;
} else if ('url' in content) {
@ -313,7 +314,7 @@ export const MessageContent = ({ content, contacts, remoteContentPolicy, measure
} else if ('text' in content) {
return <TextContent fontSize={fontSize} content={content} />;
} else if ('mention' in content) {
return <Mention ship={content.mention} contacts={contacts} />
return <Mention group={group} ship={content.mention} contacts={contacts} />
} else {
return null;
}

View File

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

View File

@ -10,7 +10,7 @@ import { NoteNavigation } from "./NoteNavigation";
import GlobalApi from "~/logic/api/global";
import { getLatestRevision, getComments } from '~/logic/lib/publish';
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 {
ship: string;
@ -26,12 +26,13 @@ interface NoteProps {
remoteContentPolicy: LocalUpdateRemoteContentPolicy;
rootUrl: string;
baseUrl: string;
group: Group;
}
export function Note(props: NoteProps & RouteComponentProps) {
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 deletePost = async () => {
@ -126,6 +127,7 @@ export function Note(props: NoteProps & RouteComponentProps) {
baseUrl={baseUrl}
editCommentId={editCommentId}
history={props.history}
group={group}
/>
<Spinner
text="Deleting post..."

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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