Skip to content

Commit

Permalink
fix: isDiscussable handles undefined subject
Browse files Browse the repository at this point in the history
affects: @esri/hub-common, @esri/hub-sites

ISSUES CLOSED: 10185
  • Loading branch information
mjuniper committed Apr 25, 2024
1 parent c820942 commit 78b3e37
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 6 additions & 1 deletion packages/common/src/discussions/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ import { IFilter, IHubSearchResult, IPredicate, IQuery } from "../search";
export function isDiscussable(
subject: Partial<IGroup | IItem | IHubContent | IHubItemEntity>
) {
return !(subject.typeKeywords ?? []).includes(CANNOT_DISCUSS);
let result = false;
if (subject) {
const typeKeywords = subject.typeKeywords || [];
result = !typeKeywords.includes(CANNOT_DISCUSS);
}
return result;
}

/**
Expand Down
6 changes: 1 addition & 5 deletions packages/common/src/sites/HubSite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,7 @@ export class HubSite
);

const followersGroup = await this.getFollowersGroup();
setProp(
"_followers.isDiscussable",
isDiscussable(followersGroup || {}),
editor
);
setProp("_followers.isDiscussable", isDiscussable(followersGroup), editor);

editor._discussions = this.entity.features["hub:site:feature:discussions"];

Expand Down

0 comments on commit 78b3e37

Please sign in to comment.