mirror of
https://github.com/urbit/shrub.git
synced 2024-11-28 13:54:20 +03:00
GraphNotification: safe property access
This commit is contained in:
parent
bb3661975d
commit
77fded3dab
@ -145,8 +145,7 @@ function ContentSummary({ icon, name, author, to }) {
|
|||||||
export const GraphNodeContent = ({ post, mod, index, hidden, association }) => {
|
export const GraphNodeContent = ({ post, mod, index, hidden, association }) => {
|
||||||
const { contents } = post;
|
const { contents } = post;
|
||||||
const idx = index.slice(1).split("/");
|
const idx = index.slice(1).split("/");
|
||||||
const { group, resource } = association;
|
const url = getNodeUrl(mod, hidden, association?.group, association?.resource, index);
|
||||||
const url = getNodeUrl(mod, hidden, group, resource, index);
|
|
||||||
if (mod === "link" && idx.length === 1) {
|
if (mod === "link" && idx.length === 1) {
|
||||||
const [{ text: title }] = contents;
|
const [{ text: title }] = contents;
|
||||||
return (
|
return (
|
||||||
@ -296,7 +295,7 @@ export function GraphNotification(props: {
|
|||||||
dm,
|
dm,
|
||||||
singleAuthor
|
singleAuthor
|
||||||
);
|
);
|
||||||
const groupAssociation = useAssocForGroup(association.group);
|
const groupAssociation = useAssocForGroup(association?.group);
|
||||||
const groups = useGroupState((state) => state.groups);
|
const groups = useGroupState((state) => state.groups);
|
||||||
|
|
||||||
const onClick = useCallback(() => {
|
const onClick = useCallback(() => {
|
||||||
@ -307,13 +306,12 @@ export function GraphNotification(props: {
|
|||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
const first = contents[0];
|
const first = contents[0];
|
||||||
const { group, resource } = association;
|
|
||||||
history.push(
|
history.push(
|
||||||
getNodeUrl(
|
getNodeUrl(
|
||||||
index.module,
|
index.module,
|
||||||
groups[association.group]?.hidden,
|
groups[association?.group]?.hidden,
|
||||||
group,
|
group,
|
||||||
resource,
|
association?.resource,
|
||||||
first.index
|
first.index
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -328,7 +326,7 @@ export function GraphNotification(props: {
|
|||||||
authorsInHeader ||
|
authorsInHeader ||
|
||||||
index.description === "note" ||
|
index.description === "note" ||
|
||||||
index.description === "link";
|
index.description === "link";
|
||||||
const channelTitle = dm ? undefined : association.metadata.title ?? graph;
|
const channelTitle = dm ? undefined : association?.metadata?.title ?? graph;
|
||||||
const groupTitle = groupAssociation?.metadata?.title;
|
const groupTitle = groupAssociation?.metadata?.title;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -349,7 +347,7 @@ export function GraphNotification(props: {
|
|||||||
description={index.description}
|
description={index.description}
|
||||||
index={contents?.[0].index}
|
index={contents?.[0].index}
|
||||||
association={association}
|
association={association}
|
||||||
hidden={groups[association.group]?.hidden}
|
hidden={groups[association?.group]?.hidden}
|
||||||
/>
|
/>
|
||||||
{contents.length > 4 && (
|
{contents.length > 4 && (
|
||||||
<Text mb="2" gray>
|
<Text mb="2" gray>
|
||||||
|
Loading…
Reference in New Issue
Block a user