mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-02 21:12:02 +08:00
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
|
(rl => {
|
||
|
// if (rl.settings.get('Nextcloud'))
|
||
|
|
||
|
addEventListener('rl-view-model.create', e => {
|
||
|
if ('PopupsCompose' === e.detail.viewModelTemplateID) {
|
||
|
let view = e.detail;
|
||
|
view.nextcloudAttach = () => {
|
||
|
rl.ncFiles.selectFiles().then(files => {
|
||
|
files.forEach(file => {
|
||
|
let id = Jua?.randomId() || file.etag,
|
||
|
attachment = view.addAttachmentHelper(
|
||
|
id.etag,
|
||
|
file.name.replace(/^.*\/([^/]+)$/, '$1'),
|
||
|
file.size
|
||
|
);
|
||
|
attachment
|
||
|
.waiting(false)
|
||
|
.uploading(true)
|
||
|
.complete(false);
|
||
|
|
||
|
rl.pluginRemoteRequest(
|
||
|
(iError, data) => {
|
||
|
attachment
|
||
|
.uploading(false)
|
||
|
.complete(true);
|
||
|
if (iError) {
|
||
|
attachment.error(data?.Result?.error || 'failed');
|
||
|
} else {
|
||
|
attachment.tempName(data.Result.tempName);
|
||
|
}
|
||
|
},
|
||
|
'NextcloudAttachFile',
|
||
|
{
|
||
|
'file': file.name
|
||
|
}
|
||
|
);
|
||
|
|
||
|
});
|
||
|
});
|
||
|
};
|
||
|
}
|
||
|
});
|
||
|
|
||
|
let template = document.getElementById('PopupsCompose');
|
||
|
const uploadBtn = template.content.querySelector('#composeUploadButton');
|
||
|
if (uploadBtn) {
|
||
|
uploadBtn.after(Element.fromHTML('<a class="btn fontastic"'
|
||
|
+ ' data-bind="click: nextcloudAttach" data-i18n="[title]NEXTCLOUD/ATTACH_FILES">◦◯◦</a>'));
|
||
|
}
|
||
|
|
||
|
})(window.rl);
|