Skip to content

Commit c46f996

Browse files
committed
refactor: align boolean state variable names
Signed-off-by: Adam Setch <adam.setch@outlook.com>
1 parent f9188f8 commit c46f996

8 files changed

Lines changed: 69 additions & 49 deletions

File tree

src/renderer/components/avatars/AvatarWithFallback.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const AvatarWithFallback: React.FC<AvatarWithFallbackProps> = ({
2323
size = Size.MEDIUM,
2424
userType = 'User',
2525
}) => {
26-
const [isBroken, setIsBroken] = useState(false);
26+
const [hasBrokenAvatarSource, setHasBrokenAvatarSource] = useState(false);
2727

2828
const isNonHuman = isNonHumanUser(userType);
2929
const DefaultUserIcon = getDefaultUserIcon(userType);
@@ -36,12 +36,12 @@ export const AvatarWithFallback: React.FC<AvatarWithFallbackProps> = ({
3636
direction="horizontal"
3737
gap="condensed"
3838
>
39-
{!src || isBroken ? (
39+
{!src || hasBrokenAvatarSource ? (
4040
<DefaultUserIcon size={size} />
4141
) : (
4242
<Avatar
4343
alt={alt}
44-
onError={() => setIsBroken(true)}
44+
onError={() => setHasBrokenAvatarSource(true)}
4545
size={size}
4646
square={isNonHuman}
4747
src={src}

src/renderer/components/fields/Tooltip.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ export interface TooltipProps {
1111
}
1212

1313
export const Tooltip: FC<TooltipProps> = (props: TooltipProps) => {
14-
const [showTooltip, setShowTooltip] = useState(false);
14+
const [shouldShowTooltipContents, setShouldShowTooltipContents] =
15+
useState(false);
16+
1517
const scrollContainerRef = useRef<HTMLElement | null>(null);
1618
const overlayRef = useRef<HTMLDivElement>(null);
1719

1820
useEffect(() => {
19-
if (!showTooltip) {
21+
if (!shouldShowTooltipContents) {
2022
return;
2123
}
2224

@@ -42,7 +44,7 @@ export const Tooltip: FC<TooltipProps> = (props: TooltipProps) => {
4244
scrollContainerRef.current = findScrollContainer(tooltipButton);
4345

4446
const handleScroll = () => {
45-
setShowTooltip(false);
47+
setShouldShowTooltipContents(false);
4648
};
4749

4850
const handleClickOutside = (event: MouseEvent) => {
@@ -51,7 +53,7 @@ export const Tooltip: FC<TooltipProps> = (props: TooltipProps) => {
5153
!overlayRef.current.contains(event.target as Node) &&
5254
!tooltipButton?.contains(event.target as Node)
5355
) {
54-
setShowTooltip(false);
56+
setShouldShowTooltipContents(false);
5557
}
5658
};
5759

@@ -67,19 +69,21 @@ export const Tooltip: FC<TooltipProps> = (props: TooltipProps) => {
6769
}
6870
document.removeEventListener('mousedown', handleClickOutside);
6971
};
70-
}, [showTooltip, props.name]);
72+
}, [shouldShowTooltipContents, props.name]);
7173

7274
return (
7375
<AnchoredOverlay
7476
align="center"
75-
open={showTooltip}
77+
open={shouldShowTooltipContents}
7678
renderAnchor={(anchorProps) => (
7779
<button
7880
{...anchorProps}
7981
aria-label={props.name}
8082
data-testid={`tooltip-icon-${props.name}`}
8183
id={props.name}
82-
onClick={() => setShowTooltip(!showTooltip)}
84+
onClick={() =>
85+
setShouldShowTooltipContents(!shouldShowTooltipContents)
86+
}
8387
type="button"
8488
>
8589
<QuestionIcon className="text-gitify-tooltip-icon" />

src/renderer/components/filters/TokenSearchInput.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ export const TokenSearchInput: FC<TokenSearchInputProps> = ({
3232
onRemove,
3333
}) => {
3434
const [inputValue, setInputValue] = useState('');
35-
const [showSuggestions, setShowSuggestions] = useState(false);
35+
const [shouldShowFilterSuggestions, setShouldShowFilterSuggestions] =
36+
useState(false);
3637

3738
const tokenItems = tokens.map((text, id) => ({ id, text }));
3839

@@ -54,9 +55,9 @@ export const TokenSearchInput: FC<TokenSearchInputProps> = ({
5455
function onKeyDown(e: React.KeyboardEvent<HTMLInputElement>) {
5556
if (INPUT_KEY_EVENTS.has(e.key)) {
5657
tryAddToken(e);
57-
setShowSuggestions(false);
58+
setShouldShowFilterSuggestions(false);
5859
} else if (e.key === 'ArrowDown') {
59-
setShowSuggestions(true);
60+
setShouldShowFilterSuggestions(true);
6061
}
6162
}
6263

@@ -78,7 +79,7 @@ export const TokenSearchInput: FC<TokenSearchInputProps> = ({
7879
block
7980
onBlur={(e) => {
8081
tryAddToken(e);
81-
setShowSuggestions(false);
82+
setShouldShowFilterSuggestions(false);
8283
}}
8384
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
8485
setInputValue(e.target.value);
@@ -87,17 +88,17 @@ export const TokenSearchInput: FC<TokenSearchInputProps> = ({
8788
!val.includes(SEARCH_DELIMITER) ||
8889
val.endsWith(SEARCH_DELIMITER)
8990
) {
90-
setShowSuggestions(true);
91+
setShouldShowFilterSuggestions(true);
9192
} else {
92-
setShowSuggestions(false);
93+
setShouldShowFilterSuggestions(false);
9394
}
9495
}}
9596
onFocus={(e) => {
9697
if (
9798
showSuggestionsOnFocusIfEmpty &&
9899
(e.target as HTMLInputElement).value.trim() === ''
99100
) {
100-
setShowSuggestions(true);
101+
setShouldShowFilterSuggestions(true);
101102
}
102103
}}
103104
onKeyDown={onKeyDown}
@@ -114,7 +115,7 @@ export const TokenSearchInput: FC<TokenSearchInputProps> = ({
114115
/>
115116
<SearchFilterSuggestions
116117
inputValue={inputValue}
117-
open={showSuggestions}
118+
open={shouldShowFilterSuggestions}
118119
/>
119120
</div>
120121
</Stack>

src/renderer/components/notifications/AccountNotifications.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const AccountNotifications: FC<AccountNotificationsProps> = (
4747

4848
const { auth, settings } = useAppContext();
4949

50-
const [showAccountNotifications, setShowAccountNotifications] =
50+
const [isAccountNotificationsVisible, setIsAccountNotificationsVisible] =
5151
useState(true);
5252

5353
const sortedNotifications = useMemo(
@@ -67,12 +67,12 @@ export const AccountNotifications: FC<AccountNotificationsProps> = (
6767
);
6868

6969
const actionToggleAccountNotifications = () => {
70-
setShowAccountNotifications(!showAccountNotifications);
70+
setIsAccountNotificationsVisible(!isAccountNotificationsVisible);
7171
};
7272

7373
const Chevron = getChevronDetails(
7474
hasNotifications,
75-
showAccountNotifications,
75+
isAccountNotificationsVisible,
7676
'account',
7777
);
7878

@@ -132,7 +132,7 @@ export const AccountNotifications: FC<AccountNotificationsProps> = (
132132
</Stack>
133133
)}
134134

135-
{showAccountNotifications && (
135+
{isAccountNotificationsVisible && (
136136
<>
137137
{props.error && (
138138
<Oops error={props.error} fullHeight={!hasMultipleAccounts(auth)} />

src/renderer/components/notifications/NotificationRow.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ export const NotificationRow: FC<NotificationRowProps> = ({
3434
unsubscribeNotification,
3535
} = useAppContext();
3636

37-
const [animateExit, setAnimateExit] = useState(false);
37+
const [shouldAnimateExitTransition, setShouldAnimateExitTransition] =
38+
useState(false);
3839

3940
const shouldAnimateExit = shouldRemoveNotificationsFromState(settings);
4041

4142
const handleNotification = useCallback(() => {
42-
setAnimateExit(shouldAnimateExit);
43+
setShouldAnimateExitTransition(shouldAnimateExit);
4344
openNotification(notification);
4445

4546
if (settings.markAsDoneOnOpen) {
@@ -56,12 +57,12 @@ export const NotificationRow: FC<NotificationRowProps> = ({
5657
]);
5758

5859
const actionMarkAsDone = () => {
59-
setAnimateExit(shouldAnimateExit);
60+
setShouldAnimateExitTransition(shouldAnimateExit);
6061
markNotificationsAsDone([notification]);
6162
};
6263

6364
const actionMarkAsRead = () => {
64-
setAnimateExit(shouldAnimateExit);
65+
setShouldAnimateExitTransition(shouldAnimateExit);
6566
markNotificationsAsRead([notification]);
6667
};
6768

@@ -78,7 +79,7 @@ export const NotificationRow: FC<NotificationRowProps> = ({
7879
'group relative border-b',
7980
'pl-2.75 pr-1 py-0.75',
8081
'text-gitify-font border-gitify-notification-border hover:bg-gitify-notification-hover',
81-
(isAnimated || animateExit) &&
82+
(isAnimated || shouldAnimateExitTransition) &&
8283
'translate-x-full opacity-0 transition duration-350 ease-in-out',
8384
isNotificationRead && Opacity.READ,
8485
)}
@@ -136,7 +137,7 @@ export const NotificationRow: FC<NotificationRowProps> = ({
136137
</Stack>
137138
</Stack>
138139

139-
{!animateExit && (
140+
{!shouldAnimateExitTransition && (
140141
<HoverGroup bgColor="group-hover:bg-gitify-notification-hover">
141142
<HoverButton
142143
action={actionMarkAsRead}

src/renderer/components/notifications/RepositoryNotifications.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,28 @@ export const RepositoryNotifications: FC<RepositoryNotificationsProps> = ({
3030
const { settings, markNotificationsAsRead, markNotificationsAsDone } =
3131
useAppContext();
3232

33-
const [animateExit, setAnimateExit] = useState(false);
34-
const [showRepositoryNotifications, setShowRepositoryNotifications] =
35-
useState(true);
33+
const [shouldAnimateExitTransition, setShouldAnimateExitTransition] =
34+
useState(false);
35+
const [
36+
isRepositoryNotificationsVisible,
37+
setIsRepositoryNotificationsVisible,
38+
] = useState(true);
3639

3740
const avatarUrl = repoNotifications[0].repository.owner.avatarUrl;
3841
const shouldAnimateExit = shouldRemoveNotificationsFromState(settings);
3942

4043
const actionMarkAsDone = () => {
41-
setAnimateExit(shouldAnimateExit);
44+
setShouldAnimateExitTransition(shouldAnimateExit);
4245
markNotificationsAsDone(repoNotifications);
4346
};
4447

4548
const actionMarkAsRead = () => {
46-
setAnimateExit(shouldAnimateExit);
49+
setShouldAnimateExitTransition(shouldAnimateExit);
4750
markNotificationsAsRead(repoNotifications);
4851
};
4952

5053
const actionToggleRepositoryNotifications = () => {
51-
setShowRepositoryNotifications(!showRepositoryNotifications);
54+
setIsRepositoryNotificationsVisible(!isRepositoryNotificationsVisible);
5255
};
5356

5457
const areAllRepoNotificationsRead = repoNotifications.every(
@@ -57,7 +60,7 @@ export const RepositoryNotifications: FC<RepositoryNotificationsProps> = ({
5760

5861
const Chevron = getChevronDetails(
5962
true,
60-
showRepositoryNotifications,
63+
isRepositoryNotificationsVisible,
6164
'repository',
6265
);
6366

@@ -67,7 +70,7 @@ export const RepositoryNotifications: FC<RepositoryNotificationsProps> = ({
6770
className={cn(
6871
'group relative pr-1 py-0.5',
6972
'bg-gitify-repository',
70-
animateExit &&
73+
shouldAnimateExitTransition &&
7174
'translate-x-full opacity-0 transition duration-350 ease-in-out',
7275
areAllRepoNotificationsRead && Opacity.READ,
7376
)}
@@ -95,7 +98,7 @@ export const RepositoryNotifications: FC<RepositoryNotificationsProps> = ({
9598
/>
9699
</Button>
97100

98-
{!animateExit && (
101+
{!shouldAnimateExitTransition && (
99102
<HoverGroup bgColor="group-hover:bg-gitify-repository">
100103
<HoverButton
101104
action={actionMarkAsRead}
@@ -126,10 +129,10 @@ export const RepositoryNotifications: FC<RepositoryNotificationsProps> = ({
126129
)}
127130
</Stack>
128131

129-
{showRepositoryNotifications &&
132+
{isRepositoryNotificationsVisible &&
130133
repoNotifications.map((notification) => (
131134
<NotificationRow
132-
isAnimated={animateExit}
135+
isAnimated={shouldAnimateExitTransition}
133136
key={notification.id}
134137
notification={notification}
135138
/>

src/renderer/routes/LoginWithOAuthApp.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export const LoginWithOAuthAppRoute: FC = () => {
8181

8282
const { loginWithOAuthApp } = useAppContext();
8383

84-
const [maskToken, setMaskToken] = useState(true);
84+
const [shouldMaskClientSecret, setShouldMaskClientSecret] = useState(true);
8585
const [isVerifyingCredentials, setIsVerifyingCredentials] = useState(false);
8686

8787
const [formData, setFormData] = useState({
@@ -224,12 +224,16 @@ export const LoginWithOAuthAppRoute: FC = () => {
224224
placeholder="Your generated client secret (40 characters)"
225225
trailingAction={
226226
<TextInput.Action
227-
aria-label={maskToken ? 'Show token' : 'Hide token'}
228-
icon={maskToken ? EyeIcon : EyeClosedIcon}
229-
onClick={() => setMaskToken(!maskToken)}
227+
aria-label={
228+
shouldMaskClientSecret ? 'Show token' : 'Hide token'
229+
}
230+
icon={shouldMaskClientSecret ? EyeIcon : EyeClosedIcon}
231+
onClick={() =>
232+
setShouldMaskClientSecret(!shouldMaskClientSecret)
233+
}
230234
/>
231235
}
232-
type={maskToken ? 'password' : 'text'}
236+
type={shouldMaskClientSecret ? 'password' : 'text'}
233237
value={formData.clientSecret}
234238
/>
235239
{errors.clientSecret && (

src/renderer/routes/LoginWithPersonalAccessToken.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ export const LoginWithPersonalAccessTokenRoute: FC = () => {
7373

7474
const { loginWithPersonalAccessToken } = useAppContext();
7575

76-
const [maskClientSecret, setMaskClientSecret] = useState(true);
76+
const [shouldMaskPersonalAccessToken, setShouldMaskPersonalAccessToken] =
77+
useState(true);
7778
const [isVerifyingCredentials, setIsVerifyingCredentials] = useState(false);
7879

7980
const [formData, setFormData] = useState({
@@ -214,12 +215,18 @@ export const LoginWithPersonalAccessTokenRoute: FC = () => {
214215
placeholder="Your generated token (40 characters)"
215216
trailingAction={
216217
<TextInput.Action
217-
aria-label={maskClientSecret ? 'Show token' : 'Hide token'}
218-
icon={maskClientSecret ? EyeIcon : EyeClosedIcon}
219-
onClick={() => setMaskClientSecret(!maskClientSecret)}
218+
aria-label={
219+
shouldMaskPersonalAccessToken ? 'Show token' : 'Hide token'
220+
}
221+
icon={shouldMaskPersonalAccessToken ? EyeIcon : EyeClosedIcon}
222+
onClick={() =>
223+
setShouldMaskPersonalAccessToken(
224+
!shouldMaskPersonalAccessToken,
225+
)
226+
}
220227
/>
221228
}
222-
type={maskClientSecret ? 'password' : 'text'}
229+
type={shouldMaskPersonalAccessToken ? 'password' : 'text'}
223230
value={formData.token}
224231
/>
225232
{errors.token && (

0 commit comments

Comments
 (0)