diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2020-06-28 20:48:28 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2020-06-28 20:48:28 +0200 |
| commit | 4aaea8a6fe04b98d2ec67ca49c4c1655e58f2b60 (patch) | |
| tree | 8243dcf3822c2724b55003e4ce4df2c5062c83b1 /animism-align/frontend/util/index.js | |
| parent | 2b347f0bd515e7a3d7918c61dc3b8a0c1be99c2c (diff) | |
adding canvas, drawing tick timestamps based on zoom
Diffstat (limited to 'animism-align/frontend/util/index.js')
| -rw-r--r-- | animism-align/frontend/util/index.js | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/animism-align/frontend/util/index.js b/animism-align/frontend/util/index.js index 194ecf0..baa121c 100644 --- a/animism-align/frontend/util/index.js +++ b/animism-align/frontend/util/index.js @@ -52,7 +52,7 @@ export const courtesyS = (n, s) => n + ' ' + (n === 1 ? s : s + 's') export const padSeconds = n => n < 10 ? '0' + n : n -export const timestamp = (n = 0, fps = 25) => { +export const timestamp = (n = 0, fps = 1) => { n /= fps let s = padSeconds(Math.round(n) % 60) n = Math.floor(n / 60) @@ -224,12 +224,17 @@ export const api = (dispatch, type=api_type, tag, url, data) => { if (data) { url.search = new URLSearchParams(data).toString() } - return fetch(url, { + let req = fetch(url, { method: 'GET', // mode: 'cors', }) - .then(res => res.json()) - .then(res => dispatch({ + // console.log(tag) + if (tag === 'text') { + req = req.then(res => res.text()) + } else { + req = req.then(res => res.json()) + } + req = req.then(res => dispatch({ type: type.loaded, tag, data: res, @@ -239,6 +244,7 @@ export const api = (dispatch, type=api_type, tag, url, data) => { tag, err, })) + return req } /* sorting */ |
