state.js 971 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* eslint-disable no-console */
  2. import User from '../user';
  3. import storage from '../../app/storage';
  4. export default function initialState(state, emitter) {
  5. const files = [];
  6. Object.assign(state, {
  7. prefix: '/android_asset',
  8. user: new User(storage),
  9. getAsset(name) {
  10. return `${state.prefix}/${name}`;
  11. },
  12. sentry: {
  13. captureException: e => {
  14. console.error('ERROR ' + e + ' ' + e.stack);
  15. }
  16. },
  17. storage: {
  18. files,
  19. remove: function(fileId) {
  20. console.log('REMOVE FILEID', fileId);
  21. },
  22. writeFile: function(file) {
  23. console.log('WRITEFILE', file);
  24. },
  25. addFile: function(file) {
  26. console.log('addfile' + JSON.stringify(file));
  27. files.push(file);
  28. emitter.emit('pushState', `/share/${file.id}`);
  29. },
  30. totalUploads: 0
  31. },
  32. transfer: null,
  33. uploading: false,
  34. settingPassword: false,
  35. passwordSetError: null,
  36. route: '/'
  37. });
  38. }