Skip to content

Commit

Permalink
Merge pull request #31 from cyntler/fix-datastream
Browse files Browse the repository at this point in the history
Fix DataStream
  • Loading branch information
cyntler authored Aug 16, 2022
2 parents 0689baa + 0f1e70a commit 23b1135
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import TXTRenderer from "./plugins/txt";
import { AppProvider } from "./state";
import { defaultTheme } from "./theme";
import { DocRenderer, IConfig, IDocument, ITheme } from "./types";
import { isWindow } from "./utils/isWindow";

export interface DocViewerProps {
documents: IDocument[];
Expand All @@ -28,6 +29,10 @@ export interface DocViewerProps {
initialActiveDocument?: IDocument;
}

if (isWindow) {
(window as any).DataStream = null;
}

const DocViewer: FC<DocViewerProps> = (props) => {
const { documents, theme } = props;

Expand Down
1 change: 1 addition & 0 deletions src/utils/isWindow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const isWindow = typeof window !== "undefined";
7 changes: 4 additions & 3 deletions src/utils/useDocumentLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { DocViewerContext } from "../state";
import {
MainStateActions,
setDocumentLoading,
updateCurrentDocument, updateDocumentNumber,
updateCurrentDocument,
updateDocumentNumber,
} from "../state/actions";
import {IMainState, initialState} from "../state/reducer";
import { IMainState } from "../state/reducer";
import { DocRenderer } from "../types";
import {
defaultFileLoader,
Expand Down Expand Up @@ -46,7 +47,7 @@ export const useDocumentLoader = (): {
const contentTypes = contentTypeRaw?.split(";") || [];
const contentType = contentTypes.length ? contentTypes[0] : undefined;

dispatch(updateDocumentNumber())
dispatch(updateDocumentNumber());
dispatch(
updateCurrentDocument({
...currentDocument,
Expand Down

0 comments on commit 23b1135

Please sign in to comment.