Skip to content

Commit

Permalink
[lib] fix changing thread description on native for thick threads
Browse files Browse the repository at this point in the history
Summary:
[ENG-9316](https://linear.app/comm/issue/ENG-9316/its-not-possible-to-change-description-on-native).

The `description` is a nullable field ([link](https://github.com/CommE2E/comm/blob/d25e29a0be1e70953f0c6b34808a66438661905a/lib/types/minimally-encoded-thread-permissions-types.js#L266)), so whenever clicking editing button for not edited or not set description [here](https://github.com/CommE2E/comm/blob/3909f7edd16fdc159bf558515ee538b9dcf8deaa/native/chat/settings/thread-settings-description.react.js#L231) it causes changing value from `undefined` to `undefined` and a result nothing changes. We're not entering [this](https://github.com/CommE2E/comm/blob/3909f7edd16fdc159bf558515ee538b9dcf8deaa/native/chat/settings/thread-settings-description.react.js#L115-L148) branch which renders `TextInput`.

For thin threads, it works only because for some reason keyserver is replacing `undefined` description with an empty string [here](https://github.com/CommE2E/comm/blob/5c7f994b92c1042dd057a8453362ea9437a4c945/keyserver/src/fetchers/thread-fetchers.js#L148).

The alternative solution is to create a thick thread with an empty string as a description (instead of `undefined`), but I don't like this because types still allow for descryption to be nullable so this bug might be caused again in the future.

Test Plan:
1. Change thread settings on native works for thin and thick threads.
2. Notifs works.
3. Changing the description to the same value is a no-op.

Reviewers: tomek, ashoat

Reviewed By: tomek

Differential Revision: https://phab.comm.dev/D13447
  • Loading branch information
xsanm committed Sep 25, 2024
1 parent cfc5daf commit ecb034a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/shared/dm-ops/create-thread-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function createThickRawThreadInfo(
repliesCount: repliesCount ?? 0,
name,
avatar,
description,
description: description ?? '',
containingThreadID,
timestamps,
};
Expand Down
2 changes: 1 addition & 1 deletion native/chat/settings/thread-settings-description.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class ThreadSettingsDescription extends React.PureComponent<Props> {
};

onPressEdit = () => {
this.props.setDescriptionEditValue(this.props.threadInfo.description);
this.props.setDescriptionEditValue(this.props.threadInfo.description ?? '');
};

onSubmit = () => {
Expand Down

0 comments on commit ecb034a

Please sign in to comment.