|
|
|
@ -2,11 +2,14 @@ import { Meteor } from 'meteor/meteor'; |
|
|
|
|
import { Tracker } from 'meteor/tracker'; |
|
|
|
|
import { Session } from 'meteor/session'; |
|
|
|
|
import s from 'underscore.string'; |
|
|
|
|
|
|
|
|
|
import { mountReply } from './chatMessages'; |
|
|
|
|
import { fileUploadHandler } from 'meteor/rocketchat:file-upload'; |
|
|
|
|
import { Handlebars } from 'meteor/ui'; |
|
|
|
|
import { t, fileUploadIsValidContentType } from 'meteor/rocketchat:utils'; |
|
|
|
|
import { modal } from 'meteor/rocketchat:ui-utils'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const readAsDataURL = (file, callback) => { |
|
|
|
|
const reader = new FileReader(); |
|
|
|
|
reader.onload = (e) => callback(e.target.result, file); |
|
|
|
@ -136,11 +139,15 @@ const getUploadPreview = async(file, preview) => { |
|
|
|
|
return getGenericUploadPreview(file, preview); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
export const fileUpload = async(files) => { |
|
|
|
|
export const fileUpload = async(files, input) => { |
|
|
|
|
files = [].concat(files); |
|
|
|
|
|
|
|
|
|
const roomId = Session.get('openedRoom'); |
|
|
|
|
|
|
|
|
|
let msg = ''; |
|
|
|
|
|
|
|
|
|
msg += await mountReply(msg, input); |
|
|
|
|
|
|
|
|
|
const uploadNextFile = () => { |
|
|
|
|
const file = files.pop(); |
|
|
|
|
if (!file) { |
|
|
|
@ -226,7 +233,11 @@ export const fileUpload = async(files) => { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Meteor.call('sendFileMessage', roomId, storage, file, () => { |
|
|
|
|
Meteor.call('sendFileMessage', roomId, storage, file, { msg }, () => { |
|
|
|
|
$(input) |
|
|
|
|
.removeData('reply') |
|
|
|
|
.trigger('dataChange'); |
|
|
|
|
|
|
|
|
|
Meteor.setTimeout(() => { |
|
|
|
|
const uploads = Session.get('uploading') || []; |
|
|
|
|
Session.set('uploading', uploads.filter((u) => u.id !== upload.id)); |
|
|
|
|