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

now able to remove user feedback after given #183

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions scripts/yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

polish: should remove this from the PR. Don't think we need a yarn.lock in our scripts directory

# yarn lockfile v1


19 changes: 11 additions & 8 deletions webapp/src/components/chat/chat-history/UserFeedbackActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,36 @@ export const UserFeedbackActions: React.FC<IUserFeedbackProps> = ({ messageId, w
const classes = useClasses();

const { instance, inProgress } = useMsal();

const dispatch = useAppDispatch();
const { selectedId } = useAppSelector((state: RootState) => state.conversations);

const onUserFeedbackProvided = useCallback(
async (positive: boolean) => {
const chatService = new ChatService();
const userRating = positive ? UserFeedback.Positive : UserFeedback.Negative;
const currentFeedback = positive ? UserFeedback.Positive : UserFeedback.Negative;

// Determine if we're toggling the current selection off
const newFeedback = wasHelpful === currentFeedback ? undefined : currentFeedback;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we prefer setting this to undefined or null ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whatever gets decided here can cascade into each of my comments

const token = await AuthHelper.getSKaaSAccessToken(instance, inProgress);

chatService
.rateMessageAync(selectedId, messageId, positive, token)
.rateMessageAync(selectedId, messageId, newFeedback === UserFeedback.Positive, token)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: newFeedback === UserFeedback.Positive evaluates to either true or false. We are going to need to pass undefined here if we want to remove a rating.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on testing I see that the frontend does update to allow you to remove a "like" or "dislike" but, the payload going to the backend is still either true or false

.then(() => {
dispatch(
updateMessageProperty({
chatId: selectedId,
messageIdOrIndex: messageId,
property: 'userFeedback',
value: userRating,
value: newFeedback,
frontLoad: true,
}),
})
);
})
.catch((e) => {
console.error(e);
});
},
[instance, inProgress, selectedId, messageId, dispatch],
[instance, inProgress, selectedId, messageId, wasHelpful, dispatch]
);

return (
Expand All @@ -66,7 +68,7 @@ export const UserFeedbackActions: React.FC<IUserFeedbackProps> = ({ messageId, w
<Button
icon={wasHelpful === UserFeedback.Positive ? <ThumbLike20Filled /> : <ThumbLike20Regular />}
appearance="transparent"
aria-label="Edit"
aria-label="Like"
onClick={() => {
void onUserFeedbackProvided(true);
}}
Expand All @@ -76,7 +78,7 @@ export const UserFeedbackActions: React.FC<IUserFeedbackProps> = ({ messageId, w
<Button
icon={wasHelpful === UserFeedback.Negative ? <ThumbDislike20Filled /> : <ThumbDislike20Regular />}
appearance="transparent"
aria-label="Edit"
aria-label="Dislike"
onClick={() => {
void onUserFeedbackProvided(false);
}}
Expand All @@ -85,3 +87,4 @@ export const UserFeedbackActions: React.FC<IUserFeedbackProps> = ({ messageId, w
</div>
);
};

Loading