Skip to content

Commit

Permalink
refactor: change function to a const variable
Browse files Browse the repository at this point in the history
  • Loading branch information
khushal87 committed Oct 27, 2023
1 parent 0be2af8 commit 3f00a8f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,9 @@ export const JoinLiveStream = ({
flexDirection: orientation === 'landscape' ? 'row' : 'column',
};

const isValidCallId = () => {
// Allows only alphabets, numbers, -(hyphen) and _(underscore)
const callIdRegex = /^[A-Za-z0-9_-]*$/g;
return callId && callId.match(callIdRegex);
};
// Allows only alphabets, numbers, -(hyphen) and _(underscore)
const callIdRegex = /^[A-Za-z0-9_-]*$/g;
const isValidCallId = callId && callId.match(callIdRegex);

return (
<KeyboardAvoidingView
Expand Down Expand Up @@ -91,13 +89,13 @@ export const JoinLiveStream = ({
<Button
onPress={enterBackstageHandler}
title={t('Enter Backstage')}
disabled={!isValidCallId()}
disabled={!isValidCallId}
/>
) : (
<Button
onPress={joinLiveStreamHandler}
title={t('Join Live stream')}
disabled={!isValidCallId()}
disabled={!isValidCallId}
/>
)}
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@ export const GuestModeScreen = ({
});
};

const isValidCallId = () => {
// Allows only alphabets, numbers, -(hyphen) and _(underscore)
const callIdRegex = /^[A-Za-z0-9_-]*$/g;
return callId && callId.match(callIdRegex);
};
// Allows only alphabets, numbers, -(hyphen) and _(underscore)
const callIdRegex = /^[A-Za-z0-9_-]*$/g;
const isValidCallId = callId && callId.match(callIdRegex);

return (
<View style={styles.container}>
Expand All @@ -68,12 +66,12 @@ export const GuestModeScreen = ({
</View>
<View>
<Button
disabled={!isValidCallId()}
disabled={!isValidCallId}
onPress={joinAsGuestHandler}
title={t('Join As Guest')}
/>
<Button
disabled={!isValidCallId()}
disabled={!isValidCallId}
onPress={joinAnonymously}
title={t('Continue Anonymously')}
buttonStyle={styles.anonymousButton}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,9 @@ const JoinMeetingScreen = (props: JoinMeetingScreenProps) => {
}
}, [linking, joinCallHandler]);

const isValidCallId = () => {
// Allows only alphabets, numbers, -(hyphen) and _(underscore)
const callIdRegex = /^[A-Za-z0-9_-]*$/g;
return callId && callId.match(callIdRegex);
};
// Allows only alphabets, numbers, -(hyphen) and _(underscore)
const callIdRegex = /^[A-Za-z0-9_-]*$/g;
const isValidCallId = callId && callId.match(callIdRegex);

const landscapeStyles: ViewStyle = {
flexDirection: orientation === 'landscape' ? 'row' : 'column',
Expand Down Expand Up @@ -103,7 +101,7 @@ const JoinMeetingScreen = (props: JoinMeetingScreenProps) => {
<Button
onPress={joinCallHandler}
title={t('Join Call')}
disabled={!isValidCallId()}
disabled={!isValidCallId}
buttonStyle={styles.joinCallButton}
/>
</View>
Expand Down

0 comments on commit 3f00a8f

Please sign in to comment.