Page MenuHomePhabricator

D7497.diff
No OneTemporary

D7497.diff

diff --git a/native/avatars/avatar-hooks.js b/native/avatars/avatar-hooks.js
--- a/native/avatars/avatar-hooks.js
+++ b/native/avatars/avatar-hooks.js
@@ -3,10 +3,17 @@
import * as React from 'react';
import { uploadMultimedia } from 'lib/actions/upload-actions.js';
-import type { UploadMultimediaResult } from 'lib/types/media-types.js';
+import type {
+ MediaLibrarySelection,
+ MediaMissionFailure,
+ UploadMultimediaResult,
+} from 'lib/types/media-types.js';
import { useServerCall } from 'lib/utils/action-utils.js';
import type { MediaResult } from '../media/media-utils.js';
+import { processMedia } from '../media/media-utils.js';
+import { useSelector } from '../redux/redux-utils.js';
+import { useStaffCanSee } from '../utils/staff-utils.js';
function useUploadProcessedMedia(): MediaResult => Promise<UploadMultimediaResult> {
const callUploadMultimedia = useServerCall(uploadMultimedia);
@@ -28,4 +35,25 @@
return uploadProcessedMultimedia;
}
-export { useUploadProcessedMedia };
+function useProcessSelectedMedia(): MediaLibrarySelection => Promise<
+ MediaMissionFailure | MediaResult,
+> {
+ const hasWiFi = useSelector(state => state.connectivity.hasWiFi);
+ const staffCanSee = useStaffCanSee();
+
+ const processSelectedMedia = React.useCallback(
+ async (selection: MediaLibrarySelection) => {
+ const { resultPromise } = processMedia(selection, {
+ hasWiFi,
+ finalFileHeaderCheck: staffCanSee,
+ });
+
+ return await resultPromise;
+ },
+ [hasWiFi, staffCanSee],
+ );
+
+ return processSelectedMedia;
+}
+
+export { useUploadProcessedMedia, useProcessSelectedMedia };
diff --git a/native/avatars/edit-thread-avatar.react.js b/native/avatars/edit-thread-avatar.react.js
--- a/native/avatars/edit-thread-avatar.react.js
+++ b/native/avatars/edit-thread-avatar.react.js
@@ -12,14 +12,14 @@
} from 'lib/media/file-utils.js';
import type { MediaLibrarySelection } from 'lib/types/media-types.js';
-import { useUploadProcessedMedia } from './avatar-hooks.js';
+import {
+ useProcessSelectedMedia,
+ useUploadProcessedMedia,
+} from './avatar-hooks.js';
import CommIcon from '../components/comm-icon.react.js';
import SWMansionIcon from '../components/swmansion-icon.react.js';
import { getCompatibleMediaURI } from '../media/identifier-utils.js';
-import { processMedia } from '../media/media-utils.js';
-import { useSelector } from '../redux/redux-utils.js';
import { useColors, useStyles } from '../themes/colors.js';
-import { useStaffCanSee } from '../utils/staff-utils.js';
type Props = {
+children: React.Node,
@@ -33,22 +33,9 @@
const colors = useColors();
const styles = useStyles(unboundStyles);
- const hasWiFi = useSelector(state => state.connectivity.hasWiFi);
- const staffCanSee = useStaffCanSee();
-
const uploadProcessedMedia = useUploadProcessedMedia();
- const processSelectedMedia = React.useCallback(
- async (selection: MediaLibrarySelection) => {
- const { resultPromise } = processMedia(selection, {
- hasWiFi,
- finalFileHeaderCheck: staffCanSee,
- });
-
- return await resultPromise;
- },
- [hasWiFi, staffCanSee],
- );
+ const processSelectedMedia = useProcessSelectedMedia();
// eslint-disable-next-line no-unused-vars
const openPhotoGallery = React.useCallback(async () => {
diff --git a/native/avatars/edit-user-avatar.react.js b/native/avatars/edit-user-avatar.react.js
--- a/native/avatars/edit-user-avatar.react.js
+++ b/native/avatars/edit-user-avatar.react.js
@@ -12,14 +12,14 @@
} from 'lib/media/file-utils.js';
import type { MediaLibrarySelection } from 'lib/types/media-types.js';
-import { useUploadProcessedMedia } from './avatar-hooks.js';
+import {
+ useProcessSelectedMedia,
+ useUploadProcessedMedia,
+} from './avatar-hooks.js';
import CommIcon from '../components/comm-icon.react.js';
import SWMansionIcon from '../components/swmansion-icon.react.js';
import { getCompatibleMediaURI } from '../media/identifier-utils.js';
-import { processMedia } from '../media/media-utils.js';
-import { useSelector } from '../redux/redux-utils.js';
import { useColors, useStyles } from '../themes/colors.js';
-import { useStaffCanSee } from '../utils/staff-utils.js';
type Props = {
+children: React.Node,
@@ -33,22 +33,9 @@
const colors = useColors();
const styles = useStyles(unboundStyles);
- const hasWiFi = useSelector(state => state.connectivity.hasWiFi);
- const staffCanSee = useStaffCanSee();
-
const uploadProcessedMedia = useUploadProcessedMedia();
- const processSelectedMedia = React.useCallback(
- async (selection: MediaLibrarySelection) => {
- const { resultPromise } = processMedia(selection, {
- hasWiFi,
- finalFileHeaderCheck: staffCanSee,
- });
-
- return await resultPromise;
- },
- [hasWiFi, staffCanSee],
- );
+ const processSelectedMedia = useProcessSelectedMedia();
// eslint-disable-next-line no-unused-vars
const openPhotoGallery = React.useCallback(async () => {

File Metadata

Mime Type
text/plain
Expires
Fri, Jan 10, 7:37 AM (15 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2846391
Default Alt Text
D7497.diff (4 KB)

Event Timeline