mirror of
https://github.com/outline/outline.git
synced 2026-11-28 00:09:58 +03:00
Fix shared pages prefetch loading
This commit is contained in:
1 parent
2ee8167cdc
commit
dbcf23d3cd
2 files changed
+25
No files matched your search
@@ -25,6 +25,7 @@ import useBuildTheme from "~/hooks/useBuildTheme";
|
||||
import useCurrentUser from "~/hooks/useCurrentUser";
|
||||
import { usePostLoginPath } from "~/hooks/useLastVisitedPath";
|
||||
import useStores from "~/hooks/useStores";
|
||||
import { client } from "~/utils/ApiClient";
|
||||
import { AuthorizationError, OfflineError } from "~/utils/errors";
|
||||
import isCloudHosted from "~/utils/isCloudHosted";
|
||||
import { changeLanguage, detectLanguage } from "~/utils/language";
|
||||
@@ -109,6 +110,16 @@ function SharedDocumentScene(props: Props) {
|
||||
: undefined;
|
||||
const theme = useBuildTheme(response?.team?.customTheme, themeOverride);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (shareId) {
|
||||
client.setShareId(shareId);
|
||||
}
|
||||
|
||||
return () => {
|
||||
client.setShareId(undefined);
|
||||
};
|
||||
}, [shareId]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!user) {
|
||||
void changeLanguage(detectLanguage(), i18n);
|
||||
|
||||
@@ -36,10 +36,16 @@ const fetchWithRetry = retry(fetch);
|
||||
class ApiClient {
|
||||
baseUrl: string;
|
||||
|
||||
shareId?: string;
|
||||
|
||||
constructor(options: Options = {}) {
|
||||
this.baseUrl = options.baseUrl || "/api";
|
||||
}
|
||||
|
||||
setShareId = (shareId: string | undefined) => {
|
||||
this.shareId = shareId;
|
||||
};
|
||||
|
||||
fetch = async <T = any>(
|
||||
path: string,
|
||||
method: string,
|
||||
@@ -51,6 +57,14 @@ class ApiClient {
|
||||
let urlToFetch;
|
||||
let isJson;
|
||||
|
||||
if (this.shareId) {
|
||||
// add to data
|
||||
data = {
|
||||
...(data || {}),
|
||||
shareId: this.shareId,
|
||||
};
|
||||
}
|
||||
|
||||
if (method === "GET") {
|
||||
if (data) {
|
||||
modifiedPath = `${path}?${data && queryString.stringify(data)}`;
|
||||
|
||||
Reference in new issue
Block a user