您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

functions.native.js 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. * @returns {Promise<Object>} - The promise will be resolved with the dropbox
  8. * access token or rejected with an error.
  9. */
  10. export function _authorizeDropbox(): Promise<Object> {
  11. return Dropbox.authorize();
  12. }
  13. /**
  14. * Gets a new acccess token based on the refresh token.
  15. *
  16. * @returns {Promise}
  17. */
  18. export function getNewAccessToken() {
  19. return _authorizeDropbox();
  20. }
  21. /**
  22. * Returns the display name for the current dropbox account.
  23. *
  24. * @param {string} token - The dropbox access token.
  25. * @returns {Promise<string>} - The promise will be resolved with the display
  26. * name or rejected with an error.
  27. */
  28. export function getDisplayName(token: string) {
  29. return Dropbox.getDisplayName(token);
  30. }
  31. /**
  32. * Returns information about the space usage for the current dropbox account.
  33. *
  34. * @param {string} token - The dropbox access token.
  35. * @returns {Promise<{ used: number, allocated: number}>} - The promise will be
  36. * resolved with the object with information about the space usage (the used
  37. * space and the allocated space) for the current dropbox account or rejected
  38. * with an error.
  39. */
  40. export function getSpaceUsage(token: string) {
  41. return Dropbox.getSpaceUsage(token);
  42. }
  43. /**
  44. * Returns <tt>true</tt> if the dropbox features is enabled and <tt>false</tt>
  45. * otherwise.
  46. *
  47. * @param {Object} state - The redux state.
  48. * @returns {boolean}
  49. */
  50. export function isEnabled(state: Object) {
  51. const { dropbox = {} } = state['features/base/config'];
  52. return Dropbox.ENABLED && typeof dropbox.appKey === 'string';
  53. }