1
0
mirror of https://gitlab.com/timvisee/send.git synced 2024-11-10 21:22:35 +01:00
send/android/stores/intents.js

21 lines
524 B
JavaScript
Raw Normal View History

2018-08-16 18:07:12 +02:00
/* eslint-disable no-console */
export default function intentHandler(state, emitter) {
window.addEventListener(
'message',
event => {
if (typeof event.data !== 'string' || !event.data.startsWith('data:')) {
return;
}
2018-08-16 18:07:12 +02:00
fetch(event.data)
.then(res => res.blob())
.then(blob => {
emitter.emit('addFiles', { files: [blob] });
emitter.emit('upload', {});
})
.catch(e => console.error('ERROR ' + e + ' ' + e.stack));
},
false
);
}