Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change avatar toggle logic, all options off by default #190

Merged
merged 1 commit into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions frontend/App/SettingsPanel/Customization/Customization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import Icon from '/frontend/components/Icon';
import Modifier from '/frontend/components/Modifier';
import Toggle from '/frontend/components/Toggle';
import { setSizeModifier, toggleShowCompleted, toggleShowUserAvatars } from '/frontend/store/settings/actions';
import { getSizeModifier, isShowingCompleted, isShowingUserAvatars } from '/frontend/store/settings/selectors';
import { getSizeModifier, isHidingUserAvatars, isShowingCompleted } from '/frontend/store/settings/selectors';

const Customization = (): ReactElement => {
const showCompleted = useSelector(isShowingCompleted);
const sizeModifier = useSelector(getSizeModifier);
const showUserAvatars = useSelector(isShowingUserAvatars);
const isHidingAvatars = useSelector(isHidingUserAvatars);
const dispatch = useDispatch();

const server = <Icon icon="warning" state="warning" title="Server setting" />;
Expand All @@ -37,11 +37,11 @@ const Customization = (): ReactElement => {
</Setting>
<Setting>
<About>
<Title>Show user avatars</Title>
<Title>Hide user avatars</Title>
<Description>Do you want to see the user avatar images?</Description>
</About>
<Tool>
<Toggle onToggle={() => dispatch(toggleShowUserAvatars())} enabled={showUserAvatars} />
<Toggle onToggle={() => dispatch(toggleShowUserAvatars())} enabled={isHidingAvatars} />
</Tool>
</Setting>
<Setting>
Expand Down
6 changes: 3 additions & 3 deletions frontend/App/Statuses/Status/Status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useSelector } from 'react-redux';
import { Body, Box, Boxes, Container, Details, LinkBox, Project, UserImage } from './Status.style';

import Icon from '/frontend/components/Icon';
import { isShowingUserAvatars } from '/frontend/store/settings/selectors';
import { isHidingUserAvatars } from '/frontend/store/settings/selectors';

import Merge from './Merge';
import Process from './Process';
Expand All @@ -27,7 +27,7 @@ const pettyUrl = (url: string) =>
.replace(/\/$/, '');

const Statuses = ({ status }: Props): ReactElement => {
const showUserAvatar = useSelector(isShowingUserAvatars);
const hideUserAvatar = useSelector(isHidingUserAvatars);

return (
<Container key={status.id} state={status.state}>
Expand Down Expand Up @@ -59,7 +59,7 @@ const Statuses = ({ status }: Props): ReactElement => {
</Box>
</Boxes>
</Details>
{status.userImage && showUserAvatar && (
{status.userImage && !hideUserAvatar && (
<UserImage>
<img src={status.userImage} alt="User" />
</UserImage>
Expand Down
2 changes: 1 addition & 1 deletion frontend/store/settings/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const isSettingsPanelOpen = (state: RootState): boolean => state.setting.

export const isShowingCompleted = (state: RootState): boolean => state.setting.showCompleted;

export const isShowingUserAvatars = (state: RootState): boolean => state.setting.showUserAvatars;
export const isHidingUserAvatars = (state: RootState): boolean => !state.setting.showUserAvatars;

export const getSizeModifier = (state: RootState): number =>
state.setting.sizeModifier ? state.setting.sizeModifier : 1;