Fix #896 Port Send Android to choo
This commit is contained in:
parent
071e283f87
commit
7a48c5201a
10 changed files with 195 additions and 206 deletions
6
android/stores/.eslintrc.yaml
Normal file
6
android/stores/.eslintrc.yaml
Normal file
|
@ -0,0 +1,6 @@
|
|||
env:
|
||||
browser: true
|
||||
|
||||
parserOptions:
|
||||
sourceType: module
|
||||
|
17
android/stores/intents.js
Normal file
17
android/stores/intents.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
/* eslint-disable no-console */
|
||||
|
||||
export default function intentHandler(state, emitter) {
|
||||
window.addEventListener(
|
||||
'message',
|
||||
event => {
|
||||
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
|
||||
);
|
||||
}
|
39
android/stores/state.js
Normal file
39
android/stores/state.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
/* eslint-disable no-console */
|
||||
|
||||
export default function initialState(state, emitter) {
|
||||
const files = [];
|
||||
|
||||
Object.assign(state, {
|
||||
getAsset(name) {
|
||||
return `/android_asset/${name}`;
|
||||
},
|
||||
translate: (...toTranslate) => {
|
||||
return toTranslate.map(o => JSON.stringify(o)).toString();
|
||||
},
|
||||
raven: {
|
||||
captureException: e => {
|
||||
console.error('ERROR ' + e + ' ' + e.stack);
|
||||
}
|
||||
},
|
||||
storage: {
|
||||
files,
|
||||
remove: function(fileId) {
|
||||
console.log('REMOVE FILEID', fileId);
|
||||
},
|
||||
writeFile: function(file) {
|
||||
console.log('WRITEFILE', file);
|
||||
},
|
||||
addFile: function(file) {
|
||||
console.log('addfile' + JSON.stringify(file));
|
||||
files.push(file);
|
||||
emitter.emit('pushState', `/share/${file.id}`);
|
||||
},
|
||||
totalUploads: 0
|
||||
},
|
||||
transfer: null,
|
||||
uploading: false,
|
||||
settingPassword: false,
|
||||
passwordSetError: null,
|
||||
route: '/'
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue