Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3723105
D7513.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D7513.id.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 9, 3:17 PM (8 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2836471
Default Alt Text
D7513.id.diff (2 KB)
Attached To
Mode
D7513: [native] Introduce `useRemoveThreadAvatar` hook
Attached
Detach File
Event Timeline
Log In to Comment