From 05dd87b70dae576c355aea8fe09852aa387b657b Mon Sep 17 00:00:00 2001 From: Kyle Kelley Date: Thu, 15 Feb 2018 14:56:04 -0800 Subject: [PATCH] switch to fetchContentFulfilled --- .../desktop/src/notebook/epics/index.js | 5 ++-- .../desktop/src/notebook/epics/loading.js | 29 ++++++++++++++++--- packages/core/src/epics/contents.js | 1 + 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/applications/desktop/src/notebook/epics/index.js b/applications/desktop/src/notebook/epics/index.js index d219b76088..23796cde64 100644 --- a/applications/desktop/src/notebook/epics/index.js +++ b/applications/desktop/src/notebook/epics/index.js @@ -21,10 +21,10 @@ import { executeCellEpic, updateDisplayEpic, commListenEpic, - executeAllCellsEpic + executeAllCellsEpic, // TODO: Integration of the following epics // launchKernelWhenNotebookSetEpic - // setNotebookEpic + setNotebookEpic } from "@nteract/core/epics"; import { publishEpic } from "./github-publish"; @@ -43,6 +43,7 @@ export const wrapEpic = (epic: Epic<*, *, *>) => (...args: any) => epic(...args).pipe(catchError(retryAndEmitError)); const epics = [ + setNotebookEpic, executeAllCellsEpic, restartKernelEpic, watchSpawn, diff --git a/applications/desktop/src/notebook/epics/loading.js b/applications/desktop/src/notebook/epics/loading.js index 499ca3a1be..c9230edc3c 100644 --- a/applications/desktop/src/notebook/epics/loading.js +++ b/applications/desktop/src/notebook/epics/loading.js @@ -5,7 +5,14 @@ import * as fs from "fs"; import { of } from "rxjs/observable/of"; import { forkJoin } from "rxjs/observable/forkJoin"; -import { map, tap, mergeMap, switchMap, catchError } from "rxjs/operators"; +import { + map, + tap, + mergeMap, + switchMap, + catchError, + timeout +} from "rxjs/operators"; import { ActionsObservable, ofType } from "redux-observable"; @@ -135,8 +142,22 @@ export const loadEpic = (action$: ActionsObservable<*>) => // Project onto the Contents API response (content, stat) => createContentsResponse(filepath, stat, content) ).pipe( - // TODO: Switch this all to a response to fetchContents instead - // and handle accordingly + // Timeout after one minute + timeout(60 * 1000), + map(model => + actions.fetchContentFulfilled({ + path: model.filepath, + model + }) + ), + catchError((err: Error) => + of(actions.fetchContentFailed({ path: filepath, error: err })) + ) + ); + }) + ); + +/* map(({ content, filePath }) => convertRawNotebook(filePath, content)), mergeMap(({ filename, notebook }) => { const { cwd, kernelSpecName } = extractNewKernel(filename, notebook); @@ -151,7 +172,7 @@ export const loadEpic = (action$: ActionsObservable<*>) => catchError(err => of({ type: "ERROR", payload: err, error: true })) ); }) - ); + );*/ /** * Sets a new empty notebook. diff --git a/packages/core/src/epics/contents.js b/packages/core/src/epics/contents.js index f29b4101ee..6e8b5dcbbf 100644 --- a/packages/core/src/epics/contents.js +++ b/packages/core/src/epics/contents.js @@ -114,6 +114,7 @@ export function saveContentEpic( } // When content gets loaded, if it's a notebook, set it up as the notebook +// TODO: should this be renamed as "fetchContentFulfilledEpic" export function setNotebookEpic( action$: ActionsObservable<*>, store: Store<*, *>