Skip to content

Commit

Permalink
correctly display if question is starred
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffrey-wu committed Jul 27, 2024
1 parent aa1209b commit afab556
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
5 changes: 4 additions & 1 deletion client/database/BonusCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import account from '../scripts/accounts.js';
import { stringifyBonus } from './stringify.js';
import { getBonusPartLabel } from '../scripts/utilities/index.js';
import Star from './Star.js';
import star from '../scripts/auth/star.js';
const starredBonusIds = new Set(await star.getStarredBonusIds());
export default function BonusCard({
bonus,
highlightedBonus,
Expand Down Expand Up @@ -96,9 +98,10 @@ export default function BonusCard({
"data-bs-toggle": "collapse",
"data-bs-target": `#question-${_id}`
}, "Packet ", bonus.packet.number, " |"), /*#__PURE__*/React.createElement("span", null, " "), /*#__PURE__*/React.createElement(Star, {
key: _id,
_id: _id,
questionType: "bonus",
initiallyStarred: false
initiallyStarred: starredBonusIds.has(_id)
}))), /*#__PURE__*/React.createElement("div", {
className: "card-container collapse show",
id: `question-${_id}`
Expand Down
5 changes: 4 additions & 1 deletion client/database/BonusCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import account from '../scripts/accounts.js';
import { stringifyBonus } from './stringify.js';
import { getBonusPartLabel } from '../scripts/utilities/index.js';
import Star from './Star.js';
import star from '../scripts/auth/star.js';

const starredBonusIds = new Set(await star.getStarredBonusIds());

export default function BonusCard ({ bonus, highlightedBonus, hideAnswerlines, showCardFooter, fontSize = 16 }) {
const _id = bonus._id;
Expand Down Expand Up @@ -97,7 +100,7 @@ export default function BonusCard ({ bonus, highlightedBonus, hideAnswerlines, s
Packet {bonus.packet.number} |
</b>
<span> </span>
<Star _id={_id} questionType='bonus' initiallyStarred={false} />
<Star key={_id} _id={_id} questionType='bonus' initiallyStarred={starredBonusIds.has(_id)} />
</span>
</div>
<div className='card-container collapse show' id={`question-${_id}`}>
Expand Down
5 changes: 4 additions & 1 deletion client/database/TossupCard.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import account from '../scripts/accounts.js';
import { stringifyTossup } from './stringify.js';
import Star from './Star.js';
import star from '../scripts/auth/star.js';
const starredTossupIds = new Set(await star.getStarredTossupIds());
export default function TossupCard({
tossup,
highlightedTossup,
Expand Down Expand Up @@ -91,9 +93,10 @@ export default function TossupCard({
"data-bs-toggle": "collapse",
"data-bs-target": `#question-${_id}`
}, "Packet ", tossup.packet.number, " |"), /*#__PURE__*/React.createElement("span", null, " "), /*#__PURE__*/React.createElement(Star, {
key: _id,
_id: _id,
questionType: "tossup",
initiallyStarred: false
initiallyStarred: starredTossupIds.has(_id)
}))), /*#__PURE__*/React.createElement("div", {
className: "card-container collapse show",
id: `question-${_id}`
Expand Down
5 changes: 4 additions & 1 deletion client/database/TossupCard.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import account from '../scripts/accounts.js';
import { stringifyTossup } from './stringify.js';
import Star from './Star.js';
import star from '../scripts/auth/star.js';

const starredTossupIds = new Set(await star.getStarredTossupIds());

export default function TossupCard ({ tossup, highlightedTossup, hideAnswerline, showCardFooter, fontSize = 16 }) {
const _id = tossup._id;
Expand Down Expand Up @@ -91,7 +94,7 @@ export default function TossupCard ({ tossup, highlightedTossup, hideAnswerline,
Packet {tossup.packet.number} |
</b>
<span> </span>
<Star _id={_id} questionType='tossup' initiallyStarred={false} />
<Star key={_id} _id={_id} questionType='tossup' initiallyStarred={starredTossupIds.has(_id)} />
</span>
</div>
<div className='card-container collapse show' id={`question-${_id}`}>
Expand Down

0 comments on commit afab556

Please sign in to comment.