Merge branch 'main' of github.com:outline/outline
This commit is contained in:
@@ -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<string[]>([]);
|
||||
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,
|
||||
|
||||
@@ -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<Props> {
|
||||
frameBorder="0"
|
||||
width="100%"
|
||||
height="200px"
|
||||
scrolling="no"
|
||||
id={`gist-${id}`}
|
||||
title={`Github Gist (${id})`}
|
||||
onLoad={this.updateIframeContent}
|
||||
|
||||
@@ -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", () => {
|
||||
|
||||
Reference in New Issue
Block a user