From 4f34b95ea36bce31efc4b2c571129387e258271e Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 22 Sep 2018 20:02:16 +0200 Subject: thumbnail embed --- app/client/common/fileViewer.component.js | 32 ++++++++++++++++++++----------- public/assets/css/css.css | 3 ++- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/app/client/common/fileViewer.component.js b/app/client/common/fileViewer.component.js index fcc4e9c..d9f3f4b 100644 --- a/app/client/common/fileViewer.component.js +++ b/app/client/common/fileViewer.component.js @@ -29,7 +29,7 @@ class FileViewer extends Component { } fetch() { - const { file, path } = this.props + const { file, path, thumbnail } = this.props if (!file) return if (this.state.loading) { this.setState({ stale: true }) @@ -39,16 +39,26 @@ class FileViewer extends Component { console.log('fetch file', fn) const { tool: module } = this.props.app this.setState({ buffer: null, loading: true }) - - actions.socket.read_file({ module, fn }).then(buffer => { - console.log('fetched buffer') - const { stale } = this.state - this.setState({ buffer, loading: false, stale: false, }, () => { - if (stale) { - console.log('stale, fetching...') - this.fetch() - } - }) + + if (thumbnail) { + const size = parseInt(thumbnail) || 200 + actions.socket + .thumbnail({ module, fn, size }) + .then(this.loadBuffer.bind(this)) + } else { + actions.socket + .read_file({ module, fn }) + .then(this.loadBuffer.bind(this)) + } + } + loadBuffer(buffer) { + console.log('fetched buffer') + const { stale } = this.state + this.setState({ buffer, loading: false, stale: false, }, () => { + if (stale) { + console.log('stale, fetching...') + this.fetch() + } }) } diff --git a/public/assets/css/css.css b/public/assets/css/css.css index a1d29e5..cd992f7 100644 --- a/public/assets/css/css.css +++ b/public/assets/css/css.css @@ -694,7 +694,8 @@ input.small { .timeline { display: block; - border: 1px solid #333; + border: 1px solid #ddd; + border-radius: 2px; background: #fff; position: relative; margin-bottom: 5px; -- cgit v1.2.3-70-g09d2