Skip to content

Commit

Permalink
fix: keep poll toast open until user action
Browse files Browse the repository at this point in the history
  • Loading branch information
KaustubhKumar05 authored Jan 18, 2024
1 parent 7a4542b commit d059b6f
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ import { useIsNotificationDisabled, useSubscribedNotifications } from '../AppDat
import { getMetadata } from '../../common/utils';
// @ts-ignore: No implicit Any
import { ROLE_CHANGE_DECLINED } from '../../common/constants';

const pollToastKey: Record<string, string> = {};

export function Notifications() {
const localPeerID = useHMSStore(selectLocalPeerID);
const notification = useHMSNotifications();
Expand Down Expand Up @@ -151,7 +154,8 @@ export function Notifications() {
case HMSNotificationTypes.POLL_STARTED:
if (notification.data.startedBy !== localPeerID && screenProps.screenType !== 'hls_live_streaming') {
const pollStartedBy = vanillaStore.getState(selectPeerNameByID(notification.data.startedBy)) || 'Participant';
ToastManager.addToast({

const pollToastID = ToastManager.addToast({
title: `${pollStartedBy} started a ${notification.data.type}: ${notification.data.title}`,
action: (
<Button
Expand All @@ -167,7 +171,16 @@ export function Notifications() {
{notification.data.type === 'quiz' ? 'Answer' : 'Vote'}
</Button>
),
duration: Infinity,
});
pollToastKey[notification.data.id] = pollToastID;
}
break;
case HMSNotificationTypes.POLL_STOPPED:
const pollID = notification?.data.id;
if (pollID && pollToastKey?.[pollID]) {
ToastManager.removeToast(pollToastKey?.[notification.data.id]);
delete pollToastKey[notification?.data.id];
}
break;
default:
Expand Down

1 comment on commit d059b6f

@vercel
Copy link

@vercel vercel bot commented on d059b6f Jan 18, 2024

Choose a reason for hiding this comment

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

Please sign in to comment.