Skip to content

Commit

Permalink
feat(user-header): fire total rewards viewed when opening user profile (
Browse files Browse the repository at this point in the history
#1879)

* feat(dialog-manager): add rewards dialog

* feat(user-profile-overview-panel): add rewards item container

* feat(user-header): update profile flow - replace settings menu and render user profile

* feat: test coverage

* refactor: remove settings menu

* feat(user-header): fire total rewards viewed when opening user profile
  • Loading branch information
domw30 authored May 15, 2024
1 parent b5c094a commit 3e6c2f5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/components/messenger/list/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ describe('messenger-list', () => {
onFavoriteRoom: () => null,
onUnfavoriteRoom: () => null,
openUserProfile: () => null,
totalRewardsViewed: () => null,

...props,
};
Expand Down
5 changes: 4 additions & 1 deletion src/components/messenger/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { UserHeader } from './user-header';
import { getUserSubHandle } from '../../../lib/user';
import { VerifyIdDialog } from '../../verify-id-dialog';
import { RewardsModalContainer } from '../../rewards-modal/container';
import { closeRewardsDialog } from '../../../store/rewards';
import { closeRewardsDialog, totalRewardsViewed } from '../../../store/rewards';
import { InviteDialogContainer } from '../../invite-dialog/container';
import { openUserProfile } from '../../../store/edit-profile';

Expand Down Expand Up @@ -72,6 +72,7 @@ export interface Properties extends PublicProperties {
onFavoriteRoom: (payload: { roomId: string }) => void;
onUnfavoriteRoom: (payload: { roomId: string }) => void;
openUserProfile: () => void;
totalRewardsViewed: () => void;
}

interface State {
Expand Down Expand Up @@ -124,6 +125,7 @@ export class Container extends React.Component<Properties, State> {
onFavoriteRoom,
onUnfavoriteRoom,
openUserProfile,
totalRewardsViewed,
};
}

Expand Down Expand Up @@ -238,6 +240,7 @@ export class Container extends React.Component<Properties, State> {
showRewardsTooltip={this.props.showRewardsTooltip}
openUserProfile={this.props.openUserProfile}
hasUnviewedRewards={this.props.hasUnviewedRewards}
totalRewardsViewed={this.props.totalRewardsViewed}
/>
);
}
Expand Down
10 changes: 10 additions & 0 deletions src/components/messenger/list/user-header/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe(UserHeader, () => {
onVerifyId: () => null,
startConversation: () => null,
openUserProfile: () => null,
totalRewardsViewed: () => null,
...props,
};

Expand Down Expand Up @@ -86,4 +87,13 @@ describe(UserHeader, () => {

expect(openUserProfile).toHaveBeenCalled();
});

it('fires totalRewardsViewed when user avatar is clicked', function () {
const totalRewardsViewed = jest.fn();
const wrapper = subject({ totalRewardsViewed });

wrapper.find(c('avatar-container')).simulate('click');

expect(totalRewardsViewed).toHaveBeenCalled();
});
});
2 changes: 2 additions & 0 deletions src/components/messenger/list/user-header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface Properties {
onVerifyId: () => void;
startConversation: () => void;
openUserProfile: () => void;
totalRewardsViewed: () => void;
}

export class UserHeader extends React.Component<Properties> {
Expand All @@ -39,6 +40,7 @@ export class UserHeader extends React.Component<Properties> {

openProfile = () => {
this.props.openUserProfile();
this.props.totalRewardsViewed();
};

renderVerifyIdButton() {
Expand Down

0 comments on commit 3e6c2f5

Please sign in to comment.