summary refs log tree commit diff
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2014-11-14 15:34:19 +0000
committerKegan Dougal <kegan@matrix.org>2014-11-14 15:34:19 +0000
commitd4f6d65e1d3406453e43f289cdba3d06c7d64fe0 (patch)
tree54864c9b00384fe8fa3999a28271785a21df198a
parentActually look for last_active_ago in the right place.. (diff)
downloadsynapse-d4f6d65e1d3406453e43f289cdba3d06c7d64fe0.tar.xz
Add extra checks to duration filter.
-rw-r--r--syweb/webclient/app-filter.js3
-rw-r--r--syweb/webclient/test/unit/filters.spec.js5
2 files changed, 8 insertions, 0 deletions
diff --git a/syweb/webclient/app-filter.js b/syweb/webclient/app-filter.js
index b0971e8493..003e6d3f11 100644
--- a/syweb/webclient/app-filter.js
+++ b/syweb/webclient/app-filter.js
@@ -26,6 +26,9 @@ angular.module('matrixWebClient')
         var h = parseInt(t / (60 * 60)) % 24;
         var d = parseInt(t / (60 * 60 * 24));
         if (t < 60) {
+            if (t < 0) {
+                return "0s";
+            }
             return s + "s";
         }
         if (t < 60 * 60) {
diff --git a/syweb/webclient/test/unit/filters.spec.js b/syweb/webclient/test/unit/filters.spec.js
index e8944cbfc2..fe31da709b 100644
--- a/syweb/webclient/test/unit/filters.spec.js
+++ b/syweb/webclient/test/unit/filters.spec.js
@@ -285,6 +285,11 @@ describe('duration filter', function() {
         var output = durationFilter(1000*60*60*2 + 1000*60*35);
         expect(output).toEqual("2h");
     });
+    
+    it("should represent -ve numbers as '0s'", function() {
+        var output = durationFilter(-2000);
+        expect(output).toEqual("0s");
+    });
 });
 
 describe('orderMembersList filter', function() {