Skip to content

Commit

Permalink
Update publish-alpha (#2520)
Browse files Browse the repository at this point in the history
* fix: show trophy only if peer has a score

* fix: preserve attempted polls
  • Loading branch information
KaustubhKumar05 authored Feb 13, 2024
1 parent d85daad commit b64edca
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useEffect, useMemo, useRef, useState } from 'react';
import {
HMSPoll,
HMSPollState,
selectLocalPeerRoleName,
selectPermissions,
selectPolls,
useHMSActions,
useHMSStore,
} from '@100mslive/react-sdk';
Expand Down Expand Up @@ -133,7 +133,7 @@ const AddMenu = () => {
active={interactionType === INTERACTION_TYPE.QUIZ}
/>
</Flex>
<Flex direction="column">
<Flex direction="column" css={{ mb: '$10' }}>
<Text variant="body2" css={{ mb: '$4' }}>{`Name this ${interactionType.toLowerCase()}`}</Text>
<Input
ref={inputRef}
Expand Down Expand Up @@ -194,42 +194,32 @@ const AddMenu = () => {

const PrevMenu = () => {
const hmsActions = useHMSActions();
const [polls, setPolls] = useState<HMSPoll[]>([]);
const polls = useHMSStore(selectPolls);
const permissions = useHMSStore(selectPermissions);

useEffect(() => {
const listPolls = async () => {
const polls = await hmsActions.interactivityCenter.getPolls();
const sortedPolls = await polls
?.sort((a, b) => (b.createdAt?.getTime() || 0) - (a.createdAt?.getTime() || 0))
?.sort((a, b) => (b.state === 'started' ? 1 : 0) - (a.state === 'started' ? 1 : 0));
return sortedPolls;
};

const updatePolls = async () => {
const sortedPolls = await listPolls();
setPolls(sortedPolls);
await hmsActions.interactivityCenter.getPolls();
};

updatePolls();
}, [hmsActions.interactivityCenter]);

return polls?.length ? (
<Flex
direction="column"
css={{
borderTop: '$space$px solid $border_bright',
mt: '$10',
pt: '$10',
width: '100%',
...(permissions?.pollWrite ? { borderTop: '$space$px solid $border_bright', paddingTop: '$10' } : {}),
}}
>
<Flex direction="column" css={{ w: '100%' }}>
<Text variant="h6" css={{ c: '$on_surface_high' }}>
Previous Polls and Quizzes
</Text>
<Flex direction="column" css={{ gap: '$10', mt: '$8' }}>
{polls?.map(poll => (
<InteractionCard key={poll.id} id={poll.id} title={poll.title} status={poll.state} />
))}
</Flex>
<Text variant="h6" css={{ c: '$on_surface_high' }}>
Previous Polls and Quizzes
</Text>
<Flex direction="column" css={{ gap: '$10', mt: '$8' }}>
{polls?.map(poll => (
<InteractionCard key={poll.id} id={poll.id} title={poll.title} status={poll.state} />
))}
</Flex>
</Flex>
) : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const LeaderboardEntry = ({
</Flex>

<Flex align="center" css={{ gap: '$4', color: '$on_surface_medium' }}>
{position === 1 ? <TrophyFilledIcon height={16} width={16} /> : null}
{position === 1 && score ? <TrophyFilledIcon height={16} width={16} /> : null}
{questionCount ? (
<>
<CheckCircleIcon height={16} width={16} />
Expand Down

0 comments on commit b64edca

Please sign in to comment.