From 6bf5764c6ce49cb0c8a1f609d7e28b8a81f74326 Mon Sep 17 00:00:00 2001 From: rr- Date: Sun, 27 Nov 2016 21:52:40 +0100 Subject: [PATCH] client/posts: fix adding loop flag to non videos --- client/html/post_upload_row.tpl | 2 +- client/js/views/post_upload_view.js | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/client/html/post_upload_row.tpl b/client/html/post_upload_row.tpl index 25ff3ae..d91f274 100644 --- a/client/html/post_upload_row.tpl +++ b/client/html/post_upload_row.tpl @@ -60,7 +60,7 @@ <%= ctx.makeCheckbox({ text: 'Loop video', name: 'loop-video', - checked: true, + checked: ctx.uploadable.flags.includes('loop'), }) %> <% } %> diff --git a/client/js/views/post_upload_view.js b/client/js/views/post_upload_view.js index b260381..51a035c 100644 --- a/client/js/views/post_upload_view.js +++ b/client/js/views/post_upload_view.js @@ -30,7 +30,7 @@ class Uploadable extends events.EventTarget { constructor() { super(); this.safety = 'safe'; - this.flags = ['loop']; + this.flags = []; this.anonymous = false; this.order = globalOrder; globalOrder++; @@ -54,6 +54,12 @@ class Uploadable extends events.EventTarget { get name() { throw new Error('Not implemented'); } + + _initComplete() { + if (['video'].includes(this.type)) { + this.flags.push('loop'); + } + } } class File extends Uploadable { @@ -73,6 +79,7 @@ class File extends Uploadable { new CustomEvent('finish', {detail: {uploadable: this}})); }); } + this._initComplete(); } destroy() { @@ -103,6 +110,7 @@ class Url extends Uploadable { super(); this.url = url; this.dispatchEvent(new CustomEvent('finish')); + this._initComplete(); } get mimeType() {