You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

functions.native.js 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // @flow
  2. import { NativeModules } from 'react-native';
  3. const { Dropbox } = NativeModules;
  4. /**
  5. * Action to authorize the Jitsi Recording app in dropbox.
  6. *
  7. * @param {string} appKey - The Jitsi Recorder dropbox app key.
  8. * @param {string} redirectURI - The return URL.
  9. * @returns {Promise<string>} - The promise will be resolved with the dropbox
  10. * access token or rejected with an error.
  11. */
  12. export function _authorizeDropbox(): Promise<string> {
  13. return Dropbox.authorize();
  14. }
  15. /**
  16. * Returns the display name for the current dropbox account.
  17. *
  18. * @param {string} token - The dropbox access token.
  19. * @returns {Promise<string>} - The promise will be resolved with the display
  20. * name or rejected with an error.
  21. */
  22. export function getDisplayName(token: string) {
  23. return Dropbox.getDisplayName(token);
  24. }
  25. /**
  26. * Returns information about the space usage for the current dropbox account.
  27. *
  28. * @param {string} token - The dropbox access token.
  29. * @returns {Promise<{ used: number, allocated: number}>} - The promise will be
  30. * resolved with the object with information about the space usage (the used
  31. * space and the allocated space) for the current dropbox account or rejected
  32. * with an error.
  33. */
  34. export function getSpaceUsage(token: string) {
  35. return Dropbox.getSpaceUsage(token);
  36. }
  37. /**
  38. * Returns <tt>true</tt> if the dropbox features is enabled and <tt>false</tt>
  39. * otherwise.
  40. *
  41. * @param {Object} state - The redux state.
  42. * @returns {boolean}
  43. */
  44. export function isEnabled(state: Object) {
  45. const { dropbox = {} } = state['features/base/config'];
  46. return Dropbox.ENABLED && typeof dropbox.appKey === 'string';
  47. }