summaryrefslogtreecommitdiff
path: root/app/client/common
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-09-22 20:02:16 +0200
committerJules Laplace <julescarbon@gmail.com>2018-09-22 20:02:16 +0200
commit4f34b95ea36bce31efc4b2c571129387e258271e (patch)
tree6d98d6b9d630c9f05e2249c083e417df825f86fc /app/client/common
parent89a3b6bb4a6d6a7ef936e8ec1d4afefd4a8385fd (diff)
thumbnail embed
Diffstat (limited to 'app/client/common')
-rw-r--r--app/client/common/fileViewer.component.js32
1 files changed, 21 insertions, 11 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()
+ }
})
}