Skip to content

Commit

Permalink
fix: remove unnecessary config check, add default avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
naumovski-filip committed Sep 7, 2023
1 parent e418746 commit 57d02df
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"lint:stylelint": "stylelint '**/*.{css,scss}'",
"commit-msg": "commitlint --edit $1",
"codecept:mobile": "cd test-e2e && rm -rf \"./output/mobile\" && codeceptjs --config ./codecept.mobile.js run-workers --suites ${WORKER_COUNT:=8} ",
"codecept:desktop": "cd test-e2e && rm -rf \"./output/desktop\" && codeceptjs --config ./codecept.desktop.js run-workers --suites ${WORKER_COUNT:=8} ",
"codecept:desktop": "cd test-e2e && rm -rf \"./output/desktop\" && codeceptjs --config ./codecept.desktop.js run-workers --suites ${WORKER_COUNT:=2} ",
"serve-report:mobile": "cd test-e2e && allure serve \"./output/mobile\"",
"serve-report:desktop": "cd test-e2e && allure serve \"./output/desktop\"",
"codecept-serve:mobile": "yarn codecept:mobile ; yarn serve-report:mobile",
Expand Down
Binary file added src/assets/profiles/default_avatar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/components/ProfileBox/ProfileBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import styles from './ProfileBox.module.scss';
import Edit from '#src/icons/Edit';
import Check from '#src/icons/Check';
import IconButton from '#components/IconButton/IconButton';
import defaultAvatar from '#src/assets/profiles/default_avatar.png';

type Props = {
name?: string;
Expand All @@ -22,7 +23,7 @@ const ProfileBox = ({ name, image, editMode = false, onClick, onEdit, selected =
<div className={styles.wrapper}>
<div className={classNames(styles.inner, selected && styles.selected)}>
<div onClick={onClick} className={styles.box}>
<img className={styles.image} src={image} alt="" />
<img className={styles.image} src={image || defaultAvatar} alt="" />
</div>
{editMode && (
<IconButton aria-label="edit-profile-button" onClick={onEdit} className={styles.overlay}>
Expand Down
5 changes: 3 additions & 2 deletions src/components/UserMenu/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { useSelectProfile } from '#src/hooks/useProfiles';
import ProfileCircle from '#src/icons/ProfileCircle';
import type { AccessModel } from '#types/Config';
import type { Profile } from '#types/account';
import defaultAvatar from '#src/assets/profiles/default_avatar.png';

type Props = {
small?: boolean;
Expand Down Expand Up @@ -58,7 +59,7 @@ const UserMenu = ({ showPaymentsItem, small = false, onClick, accessModel, curre
small={small}
onClick={() => selectProfile.mutate({ id: profile.id, avatarUrl: profile.avatar_url })}
label={profile.name}
startIcon={<ProfileCircle src={profile.avatar_url} alt={profile.name} />}
startIcon={<ProfileCircle src={profile.avatar_url || defaultAvatar} alt={profile.name} />}
/>
</li>
))
Expand All @@ -83,7 +84,7 @@ const UserMenu = ({ showPaymentsItem, small = false, onClick, accessModel, curre
onClick={onClick}
to={`/u/my-profile/${currentProfile?.id ?? ''}`}
label={t('nav.profile')}
startIcon={<ProfileCircle src={currentProfile?.avatar_url ?? ''} alt={currentProfile?.name ?? ''} />}
startIcon={<ProfileCircle src={currentProfile?.avatar_url || defaultAvatar} alt={currentProfile?.name ?? ''} />}
/>
</li>
)}
Expand Down
4 changes: 1 addition & 3 deletions src/hooks/useProfiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useNavigate } from 'react-router';

import { initializeAccount } from '#src/stores/AccountController';
import { useAccountStore } from '#src/stores/AccountStore';
import { useConfigStore } from '#src/stores/ConfigStore';
import { useFavoritesStore } from '#src/stores/FavoritesStore';
import { createProfile, deleteProfile, enterProfile, listProfiles, updateProfile } from '#src/stores/ProfileController';
import { useProfileStore } from '#src/stores/ProfileStore';
Expand Down Expand Up @@ -110,6 +109,5 @@ export const useListProfiles = (

export const useProfilesFeatureEnabled = (): boolean => {
const canManageProfiles = useAccountStore((s) => s.canManageProfiles);
const profilesFeatureEnabled = useConfigStore((s) => s.config.custom?.profilesFeatureEnabled);
return canManageProfiles && !!profilesFeatureEnabled;
return canManageProfiles;
};
9 changes: 8 additions & 1 deletion src/services/inplayer.profile.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ export const listProfiles: ListProfiles = async () => {
errors: [],
};
} catch {
throw new Error('Unable to fetch profiles.');
console.error('Unable to list profiles.');
return {
responseData: {
canManageProfiles: false,
collection: [],
},
errors: ['Unable to list profiles.'],
};
}
};

Expand Down
3 changes: 0 additions & 3 deletions src/stores/ConfigStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ export const useConfigStore = createStore<ConfigState>('ConfigStore', (_, get) =
styling: {
footerText: '',
},
custom: {
profiles_feature_enabled: false,
},
},
accessModel: 'SVOD',
adScheduleData: null,
Expand Down

0 comments on commit 57d02df

Please sign in to comment.