Skip to content

Commit e9d4d84

Browse files
committed
Passing shouldDirty to setValue
1 parent 2dc07bd commit e9d4d84

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

app/views/RoomInfoEditView/index.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { BlockContext } from '@rocket.chat/ui-kit';
33
import { dequal } from 'dequal';
44
import { AccessibilityInfo, Alert, Keyboard, ScrollView, Text, View } from 'react-native';
55
import { useForm } from 'react-hook-form';
6+
import { type SetValueConfig } from 'react-hook-form';
67
import * as yup from 'yup';
78
import { yupResolver } from '@hookform/resolvers/yup';
89

@@ -39,6 +40,10 @@ const MESSAGE_TYPE_VALUES = MessageTypeValues.map(m => ({
3940
text: { text: I18n.t('Hide_type_messages', { type: I18n.t(m.text) }) }
4041
}));
4142

43+
const dirtyOptions: SetValueConfig = {
44+
shouldDirty: true
45+
};
46+
4247
const schema = yup.object().shape({
4348
name: yup.string().required(I18n.t('Name_required'))
4449
});
@@ -283,29 +288,29 @@ const RoomInfoEditView = ({ navigation, route }: IRoomInfoEditViewProps) => {
283288

284289
const toggleRoomType = (value: boolean) => {
285290
logEvent(events.RI_EDIT_TOGGLE_ROOM_TYPE);
286-
setValue('t', value);
287-
setValue('encrypted', value && encrypted);
291+
setValue('t', value, dirtyOptions);
292+
setValue('encrypted', value && encrypted, dirtyOptions);
288293
};
289294

290295
const toggleReadOnly = (value: boolean) => {
291296
logEvent(events.RI_EDIT_TOGGLE_READ_ONLY);
292-
setValue('readOnly', value);
297+
setValue('readOnly', value, dirtyOptions);
293298
};
294299

295300
const toggleReactions = (value: boolean) => {
296301
logEvent(events.RI_EDIT_TOGGLE_REACTIONS);
297-
setValue('reactWhenReadOnly', value);
302+
setValue('reactWhenReadOnly', value, dirtyOptions);
298303
};
299304

300305
const toggleHideSystemMessages = (value: boolean) => {
301306
logEvent(events.RI_EDIT_TOGGLE_SYSTEM_MSG);
302-
setValue('enableSysMes', value);
303-
setValue('systemMessages', value ? systemMessages : []);
307+
setValue('enableSysMes', value, dirtyOptions);
308+
setValue('systemMessages', value ? systemMessages : [], dirtyOptions);
304309
};
305310

306311
const toggleEncrypted = (value: boolean) => {
307312
logEvent(events.RI_EDIT_TOGGLE_ENCRYPTED);
308-
setValue('encrypted', value);
313+
setValue('encrypted', value, dirtyOptions);
309314
};
310315

311316
const onResetPress = () => {

0 commit comments

Comments
 (0)