From 93337c20f83146bb702a5af8cf9cdb37f4c53443 Mon Sep 17 00:00:00 2001 From: Romulus Urakagi Tsai Date: Tue, 24 Dec 2019 08:57:34 +0000 Subject: Change upload routine, add upload popup --- client/lib/utils.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'client/lib/utils.js') diff --git a/client/lib/utils.js b/client/lib/utils.js index 8503b035..213124f1 100644 --- a/client/lib/utils.js +++ b/client/lib/utils.js @@ -25,12 +25,7 @@ Utils = { }, MAX_IMAGE_PIXEL: Meteor.settings.public.MAX_IMAGE_PIXEL, COMPRESS_RATIO: Meteor.settings.public.IMAGE_COMPRESS_RATIO, - processUploadedAttachment(card, fileObj, callback) { - const next = attachment => { - if (typeof callback === 'function') { - callback(attachment); - } - }; + processUploadedAttachment(card, fileObj, callbacks) { if (!card) { return onUploaded(); } @@ -50,7 +45,16 @@ Utils = { settings.meta.cardId = card._id; } settings.meta.userId = Meteor.userId(); - Attachments.insert(settings).on('end', next); + if (typeof callbacks === 'function') { + settings.onEnd = callbacks; + } else { + for (const key in callbacks) { + if (key.substring(0, 2) === 'on') { + settings[key] = callbacks[key]; + } + } + } + Attachments.insert(settings); }, shrinkImage(options) { // shrink image to certain size -- cgit v1.2.3-1-g7c22