mirror of
https://github.com/outline/outline.git
synced 2026-11-23 06:11:04 +03:00
cleanup
This commit is contained in:
1 parent
4c4caf7949
commit
7cad20589c
3 files changed
+10
-12
No files matched your search
@@ -44,7 +44,7 @@ export const determineSidebarContext = ({
|
||||
|
||||
if (membershipType === "document") {
|
||||
return "shared";
|
||||
} else if (membershipType === "group" && user) {
|
||||
} else if (membershipType === "group") {
|
||||
const group = user.groupsWithDocumentMemberships.find(
|
||||
(g) => !!g.documentMemberships.find((m) => m.documentId === document.id)
|
||||
);
|
||||
|
||||
@@ -3,14 +3,13 @@ import { observer, useObserver } from "mobx-react";
|
||||
import { CommentIcon } from "outline-icons";
|
||||
import * as React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link, useRouteMatch } from "react-router-dom";
|
||||
import { Link, useLocation, useRouteMatch } from "react-router-dom";
|
||||
import styled from "styled-components";
|
||||
import { TeamPreference } from "@shared/types";
|
||||
import Document from "~/models/Document";
|
||||
import Revision from "~/models/Revision";
|
||||
import DocumentMeta from "~/components/DocumentMeta";
|
||||
import Fade from "~/components/Fade";
|
||||
import { useLocationState } from "~/components/Sidebar/hooks/useLocationState";
|
||||
import useCurrentTeam from "~/hooks/useCurrentTeam";
|
||||
import usePolicy from "~/hooks/usePolicy";
|
||||
import useStores from "~/hooks/useStores";
|
||||
@@ -28,7 +27,7 @@ function TitleDocumentMeta({ to, document, revision, ...rest }: Props) {
|
||||
const { views, comments, ui } = useStores();
|
||||
const { t } = useTranslation();
|
||||
const match = useRouteMatch();
|
||||
const locationSidebarContext = useLocationState();
|
||||
const location = useLocation();
|
||||
const team = useCurrentTeam();
|
||||
const documentViews = useObserver(() => views.inDocument(document.id));
|
||||
const totalViewers = documentViews.length;
|
||||
@@ -49,7 +48,7 @@ function TitleDocumentMeta({ to, document, revision, ...rest }: Props) {
|
||||
<CommentLink
|
||||
to={{
|
||||
pathname: documentPath(document),
|
||||
state: { sidebarContext: locationSidebarContext },
|
||||
state: location.state,
|
||||
}}
|
||||
onClick={() => ui.toggleComments(document.id)}
|
||||
>
|
||||
@@ -72,7 +71,7 @@ function TitleDocumentMeta({ to, document, revision, ...rest }: Props) {
|
||||
match.url === insightsPath
|
||||
? documentPath(document)
|
||||
: insightsPath,
|
||||
state: { sidebarContext: locationSidebarContext },
|
||||
state: location.state,
|
||||
}}
|
||||
>
|
||||
{t("Viewed by")}{" "}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { observer } from "mobx-react";
|
||||
import * as React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { mergeRefs } from "react-merge-refs";
|
||||
import { useHistory, useRouteMatch } from "react-router-dom";
|
||||
import { useHistory, useLocation, useRouteMatch } from "react-router-dom";
|
||||
import { richExtensions, withComments } from "@shared/editor/nodes";
|
||||
import { TeamPreference } from "@shared/types";
|
||||
import { colorPalette } from "@shared/utils/collections";
|
||||
@@ -13,7 +13,6 @@ import { RefHandle } from "~/components/ContentEditable";
|
||||
import { useDocumentContext } from "~/components/DocumentContext";
|
||||
import Editor, { Props as EditorProps } from "~/components/Editor";
|
||||
import Flex from "~/components/Flex";
|
||||
import { useLocationState } from "~/components/Sidebar/hooks/useLocationState";
|
||||
import BlockMenuExtension from "~/editor/extensions/BlockMenu";
|
||||
import ClipboardTextSerializer from "~/editor/extensions/ClipboardTextSerializer";
|
||||
import EmojiMenuExtension from "~/editor/extensions/EmojiMenu";
|
||||
@@ -82,7 +81,7 @@ function DocumentEditor(props: Props, ref: React.RefObject<any>) {
|
||||
const user = useCurrentUser({ rejectOnEmpty: false });
|
||||
const team = useCurrentTeam({ rejectOnEmpty: false });
|
||||
const history = useHistory();
|
||||
const locationSidebarContext = useLocationState();
|
||||
const location = useLocation();
|
||||
const {
|
||||
document,
|
||||
onChangeTitle,
|
||||
@@ -132,10 +131,10 @@ function DocumentEditor(props: Props, ref: React.RefObject<any>) {
|
||||
(commentId: string) => {
|
||||
history.replace({
|
||||
pathname: window.location.pathname.replace(/\/history$/, ""),
|
||||
state: { commentId, sidebarContext: locationSidebarContext },
|
||||
state: { ...(location.state as Record<string, unknown>), commentId },
|
||||
});
|
||||
},
|
||||
[history, locationSidebarContext]
|
||||
[history, location]
|
||||
);
|
||||
|
||||
// Create a Comment model in local store when a comment mark is created, this
|
||||
@@ -232,7 +231,7 @@ function DocumentEditor(props: Props, ref: React.RefObject<any>) {
|
||||
match.path === matchDocumentHistory
|
||||
? documentPath(document)
|
||||
: documentHistoryPath(document),
|
||||
state: { sidebarContext: locationSidebarContext },
|
||||
state: location.state,
|
||||
}}
|
||||
rtl={
|
||||
titleRef.current?.getComputedDirection() === "rtl" ? true : false
|
||||
|
||||
Reference in new issue
Block a user