diff --git a/app/components/Collaborators.js b/app/components/Collaborators.js index d817e9a21..22f47d3e1 100644 --- a/app/components/Collaborators.js +++ b/app/components/Collaborators.js @@ -1,5 +1,5 @@ // @flow -import { sortBy, filter, uniq } from "lodash"; +import { sortBy, filter, uniq, isEqual } from "lodash"; import { observer } from "mobx-react"; import * as React from "react"; import { useTranslation } from "react-i18next"; @@ -23,6 +23,7 @@ function Collaborators(props: Props) { const { t } = useTranslation(); const user = useCurrentUser(); const currentUserId = user?.id; + const [requestedUserIds, setRequestedUserIds] = React.useState([]); const { users, presence } = useStores(); const { document } = props; @@ -51,18 +52,21 @@ function Collaborators(props: Props) { [document.collaboratorIds, users.orderedData, presentIds] ); - // load any users we don't know about + // load any users we don't yet have in memory React.useEffect(() => { - if (users.isFetching) { - return; + const userIdsToFetch = uniq([ + ...document.collaboratorIds, + ...presentIds, + ]).filter((userId) => users.get(userId)); + + if (!isEqual(requestedUserIds, userIdsToFetch)) { + setRequestedUserIds(userIdsToFetch); } - uniq([...document.collaboratorIds, ...presentIds]).forEach((userId) => { - if (!users.get(userId)) { - return users.fetch(userId); - } - }); - }, [document, users, presentIds, document.collaboratorIds]); + userIdsToFetch + .filter((userId) => requestedUserIds.includes(userId)) + .forEach((userId) => users.fetch(userId)); + }, [document, users, presentIds, document.collaboratorIds, requestedUserIds]); const popover = usePopoverState({ gutter: 0, diff --git a/shared/embeds/Gist.js b/shared/embeds/Gist.js index c777051e3..1e2325edf 100644 --- a/shared/embeds/Gist.js +++ b/shared/embeds/Gist.js @@ -2,7 +2,7 @@ import * as React from "react"; const URL_REGEX = new RegExp( - "^https://gist.github.com/([a-z\\d](?:[a-z\\d]|-(?=[a-z\\d])){0,38})/(.*)$" + "^https://gist.github.com/([a-zA-Z\\d](?:[a-zA-Z\\d]|-(?=[a-zA-Z\\d])){0,38})/(.*)$" ); type Props = {| @@ -67,6 +67,7 @@ class Gist extends React.Component { frameBorder="0" width="100%" height="200px" + scrolling="no" id={`gist-${id}`} title={`Github Gist (${id})`} onLoad={this.updateIframeContent} diff --git a/shared/embeds/Gist.test.js b/shared/embeds/Gist.test.js index f625c8492..630451142 100644 --- a/shared/embeds/Gist.test.js +++ b/shared/embeds/Gist.test.js @@ -15,6 +15,12 @@ describe("Gist", () => { match ) ).toBeTruthy(); + + expect( + "https://gist.github.com/ShubhanjanMedhi-dev/900c9c14093611898a4a085938bb90d9".match( + match + ) + ).toBeTruthy(); }); test("to not be enabled elsewhere", () => {