Page MenuHomePhabricator

D7513.diff
No OneTemporary

D7513.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
@@ -272,6 +272,30 @@
return removeUserAvatar;
}
+function useRemoveThreadAvatar(threadID: string): () => Promise<void> {
+ const dispatchActionPromise = useDispatchActionPromise();
+ const changeThreadSettingsCall = useServerCall(changeThreadSettings);
+
+ const removeThreadAvatar = React.useCallback(async () => {
+ const removeAvatarRequest: UpdateUserAvatarRemoveRequest = {
+ type: 'remove',
+ };
+
+ const updateThreadRequest: UpdateThreadRequest = {
+ threadID,
+ changes: {
+ avatar: removeAvatarRequest,
+ },
+ };
+ dispatchActionPromise(
+ changeThreadSettingsActionTypes,
+ changeThreadSettingsCall(updateThreadRequest),
+ );
+ }, [changeThreadSettingsCall, dispatchActionPromise, threadID]);
+
+ return removeThreadAvatar;
+}
+
type ShowAvatarActionSheetOptions = {
+id: 'emoji' | 'image' | 'cancel' | 'remove',
+onPress?: () => mixed,
@@ -382,4 +406,5 @@
useSelectFromGalleryAndUpdateUserAvatar,
useSelectFromGalleryAndUpdateThreadAvatar,
useRemoveUserAvatar,
+ useRemoveThreadAvatar,
};
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
@@ -6,6 +6,7 @@
import type { RawThreadInfo, ThreadInfo } from 'lib/types/thread-types.js';
import {
+ useRemoveThreadAvatar,
useSelectFromGalleryAndUpdateThreadAvatar,
useShowAvatarActionSheet,
} from './avatar-hooks.js';
@@ -23,12 +24,19 @@
const selectFromGalleryAndUpdateThreadAvatar =
useSelectFromGalleryAndUpdateThreadAvatar(threadInfo.id);
+ const removeThreadAvatar = useRemoveThreadAvatar(threadInfo.id);
+
const actionSheetConfig = React.useMemo(
() => [
{ id: 'emoji', onPress: onPressEmojiAvatarFlow },
{ id: 'image', onPress: selectFromGalleryAndUpdateThreadAvatar },
+ { id: 'remove', onPress: removeThreadAvatar },
+ ],
+ [
+ onPressEmojiAvatarFlow,
+ removeThreadAvatar,
+ selectFromGalleryAndUpdateThreadAvatar,
],
- [onPressEmojiAvatarFlow, selectFromGalleryAndUpdateThreadAvatar],
);
const showAvatarActionSheet = useShowAvatarActionSheet(actionSheetConfig);

File Metadata

Mime Type
text/plain
Expires
Thu, Jan 9, 3:14 PM (7 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2836471
Default Alt Text
D7513.diff (2 KB)

Event Timeline