Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

functions.native.ts 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import { NativeModules } from 'react-native';
  2. import { IReduxState } from '../app/types';
  3. // eslint-disable-next-line lines-around-comment
  4. // @ts-ignore
  5. import { setPictureInPictureEnabled } from '../mobile/picture-in-picture/functions';
  6. const { Dropbox } = NativeModules;
  7. /**
  8. * Action to authorize the Jitsi Recording app in dropbox.
  9. *
  10. * @param {any} _appKey - Used on web.
  11. * @param {any} _redirectURI - Used on web.
  12. * @returns {Promise<Object>} - The promise will be resolved with the dropbox
  13. * access token or rejected with an error.
  14. */
  15. export async function _authorizeDropbox(_appKey?: any, _redirectURI?: any): Promise<any> {
  16. setPictureInPictureEnabled(false);
  17. try {
  18. return await Dropbox.authorize();
  19. } finally {
  20. setPictureInPictureEnabled(true);
  21. }
  22. }
  23. /**
  24. * Gets a new access token based on the refresh token.
  25. *
  26. * @param {string} _appKey - The dropbox appKey.
  27. * @param {string} _rToken - The refresh token.
  28. * @returns {Promise}
  29. */
  30. export function getNewAccessToken(_appKey: string, _rToken: string) {
  31. return _authorizeDropbox();
  32. }
  33. /**
  34. * Returns the display name for the current dropbox account.
  35. *
  36. * @param {string} token - The dropbox access token.
  37. * @param {any} _appKey - Used on web.
  38. * @returns {Promise<string>} - The promise will be resolved with the display
  39. * name or rejected with an error.
  40. */
  41. export function getDisplayName(token: string, _appKey?: any) {
  42. return Dropbox.getDisplayName(token);
  43. }
  44. /**
  45. * Returns information about the space usage for the current dropbox account.
  46. *
  47. * @param {string} token - The dropbox access token.
  48. * @param {any} _appKey - Used on web.
  49. * @returns {Promise<{ used: number, allocated: number}>} - The promise will be
  50. * resolved with the object with information about the space usage (the used
  51. * space and the allocated space) for the current dropbox account or rejected
  52. * with an error.
  53. */
  54. export function getSpaceUsage(token: string, _appKey?: any) {
  55. return Dropbox.getSpaceUsage(token);
  56. }
  57. /**
  58. * Returns <tt>true</tt> if the dropbox features is enabled and <tt>false</tt>
  59. * otherwise.
  60. *
  61. * @param {Object} state - The redux state.
  62. * @returns {boolean}
  63. */
  64. export function isEnabled(state: IReduxState) {
  65. const { dropbox = {} } = state['features/base/config'];
  66. // @ts-ignore
  67. return Boolean(Dropbox?.ENABLED && typeof dropbox.appKey === 'string');
  68. }