Skip to content

Commit

Permalink
mobile: fix dialog calling onClose after pressing positive button
Browse files Browse the repository at this point in the history
  • Loading branch information
ammarahm-ed committed Feb 11, 2025
1 parent 33d6948 commit 0cd3bd5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
13 changes: 7 additions & 6 deletions apps/mobile/app/components/dialog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ export const Dialog = ({ context = "global" }) => {
return;
}
}

hide();
setChecked(false);
values.current.inputValue = undefined;
setVisible(false);
};

const show = useCallback(
Expand All @@ -104,14 +105,14 @@ export const Dialog = ({ context = "global" }) => {
eUnSubscribeEvent(eOpenSimpleDialog, show);
eUnSubscribeEvent(eCloseSimpleDialog, hide);
};
}, [show]);
}, [hide, show]);

const hide = () => {
const hide = React.useCallback(() => {
setChecked(false);
values.current.inputValue = undefined;
setVisible(false);
dialogInfo.onClose();
};
dialogInfo.onClose?.();
}, [dialogInfo]);

const onNegativePress = async () => {
if (dialogInfo.onClose) {
Expand Down
7 changes: 5 additions & 2 deletions apps/mobile/app/screens/settings/section-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ import { RouteParams, SettingSection } from "./types";

const _SectionItem = ({ item }: { item: SettingSection }) => {
const { colors } = useThemeColors();
const settings = useSettingStore((state) => state.settings);
const [settings, itemProperty] = useSettingStore((state) => [
state.settings,
item.property ? state.settings[item.property] : null
]);
const navigation = useNavigation<NavigationProp<RouteParams>>();
const current = item.useHook && item.useHook(item);
const [isHidden, setIsHidden] = useState(
Expand Down Expand Up @@ -106,7 +109,7 @@ const _SectionItem = ({ item }: { item: SettingSection }) => {
useEffect(() => {
setIsHidden(item.hidden && item.hidden(item.property || current));
setIsDisabled(item.disabled && item.disabled(item.property || current));
}, [current, item]);
}, [current, item, itemProperty]);

return isHidden ? null : (
<Pressable
Expand Down

0 comments on commit 0cd3bd5

Please sign in to comment.