From 007059ed2483009043b5569e4d95049139878798 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 21 Jul 2017 05:31:27 +0200 Subject: html.. --- client/components/Browser/Files/FileListView.jsx | 3 ++- client/components/Tasks/TaskFormView.jsx | 2 +- client/containers/fileLink.js | 1 + client/vendor/format.js | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) (limited to 'client') diff --git a/client/components/Browser/Files/FileListView.jsx b/client/components/Browser/Files/FileListView.jsx index df59a1d..312cc5f 100644 --- a/client/components/Browser/Files/FileListView.jsx +++ b/client/components/Browser/Files/FileListView.jsx @@ -1,5 +1,6 @@ import { h, Component } from 'preact' +import format from '../../../vendor/format.js' import FileUploadButton from './FileUploadButton.jsx' import FileLink from '../../../containers/fileLink.js' import TaskContentLink from '../../../containers/taskContentLink.js' @@ -21,7 +22,7 @@ export default function FileListView (props) { return (
{file.name} - {file.processed ? file.mime : '(waiting)'} + {file.processed ? format.getAge(file.created_at) : '(waiting)'} {file.duration ? (file.duration.toFixed(1) + 's') : ''} content diff --git a/client/components/Tasks/TaskFormView.jsx b/client/components/Tasks/TaskFormView.jsx index 01265b8..a567052 100644 --- a/client/components/Tasks/TaskFormView.jsx +++ b/client/components/Tasks/TaskFormView.jsx @@ -25,7 +25,7 @@ export default function TaskFormView (props) {
- props.setAlpha(e.target.value)} /> alpha: {props.alpha} diff --git a/client/containers/fileLink.js b/client/containers/fileLink.js index 22834d8..ad82f75 100644 --- a/client/containers/fileLink.js +++ b/client/containers/fileLink.js @@ -12,6 +12,7 @@ const mapStateToProps = (state, ownProps) => ({ const mapDispatchToProps = (dispatch, ownProps) => ({ onClick: () => { + if (! ownProps.file) return switch (ownProps.file.type) { case 'audio': let file = ownProps.file diff --git a/client/vendor/format.js b/client/vendor/format.js index 1e5836e..e6b8261 100644 --- a/client/vendor/format.js +++ b/client/vendor/format.js @@ -166,7 +166,7 @@ function getRevision (thread) { } function getAge (t) { - let age = Math.abs( Date.now()/1000 - t) + let age = Math.abs( Date.now() - new Date(t)) / 1000 const r = Math.floor let m if (age < 5) { return "now" } @@ -175,7 +175,7 @@ function getAge (t) { if (age < 60) { return r(age) + "m" } m = r(age % 60) age /= 60 - if (m > 0 && age < 2) { return m + "m" + r(age) + "h" } + if (m > 0 && age < 2) { return r(age) + "h" + m + "m" } if (age < 24) { return r(age) + "h" } age /= 24 if (age < 7) { return r(age) + "d" } -- cgit v1.2.3-70-g09d2