Skip to content

Commit

Permalink
implement loading of saved preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffrey-wu committed Oct 12, 2024
1 parent e3982a6 commit c079bde
Show file tree
Hide file tree
Showing 17 changed files with 199 additions and 1,007 deletions.
4 changes: 2 additions & 2 deletions client/database/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import BonusCard from '../scripts/components/BonusCard.min.js';
import CategoryModal from '../scripts/components/CategoryModal.min.js';
import DifficultyDropdown from '../scripts/components/DifficultyDropdown.min.js';
import Star from '../scripts/components/Star.min.js';
import CategoryManager from '../scripts/utilities/category-manager.js';
import CategoryManager from '../../quizbowl/category-manager.js';
import { getDropdownValues } from '../scripts/utilities/dropdown-checklist.js';
import { insertTokensIntoHTML } from '../insert-tokens-into-html.js';
import insertTokensIntoHTML from '../../quizbowl/insert-tokens-into-html.js';

const starredTossupIds = new Set(await star.getStarredTossupIds());
const starredBonusIds = new Set(await star.getStarredBonusIds());
Expand Down
2 changes: 1 addition & 1 deletion client/database/index.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/multiplayer/room.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import account from '../scripts/accounts.js';
import questionStats from '../scripts/auth/question-stats.js';
import api from '../scripts/api/index.js';
import audio from '../audio/index.js';
import CategoryManager from '../scripts/utilities/category-manager.js';
import CategoryManager from '../../quizbowl/category-manager.js';
import { getDropdownValues } from '../scripts/utilities/dropdown-checklist.js';
import { arrayToRange, createTossupCard, rangeToArray } from '../scripts/utilities/index.js';
import { escapeHTML } from '../scripts/utilities/strings.js';
Expand Down
6 changes: 3 additions & 3 deletions client/multiplayer/room.min.js

Large diffs are not rendered by default.

40 changes: 0 additions & 40 deletions client/scripts/Timer.js

This file was deleted.

33 changes: 29 additions & 4 deletions client/singleplayer/ClientTossupRoom.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import api from '../scripts/api/index.js';
// import TossupRoom from '../../quizbowl/TossupRoom.js';
import TossupRoom from '../TossupRoom.js';
import TossupRoom from '../../quizbowl/TossupRoom.js';

export default class ClientTossupRoom extends TossupRoom {
constructor (name, categories = [], subcategories = [], alternateSubcategories = []) {
Expand All @@ -15,24 +14,40 @@ export default class ClientTossupRoom extends TossupRoom {
powerValue: 15,
tossup: {}
};
this.settings.skip = true;
this.settings = {
...this.settings,
skip: true,
showHistory: true,
typeToAnswer: true
};

this.checkAnswer = api.checkAnswer;
this.getRandomTossups = async (args) => await api.getRandomTossup({ number: 20, ...args });
this.getSet = async ({ setName, packetNumbers }) => setName ? await api.getPacketTossups(setName, packetNumbers[0] ?? 1) : [];
this.getSetList = api.getSetList;
this.getNumPackets = api.getNumPackets;

this.setList = this.getSetList().concat('');
this.setList = this.getSetList();
}

async message (userId, message) {
switch (message.type) {
case 'toggle-correct': return this.toggleCorrect(userId, message);
case 'toggle-show-history': return this.toggleShowHistory(userId, message);
case 'toggle-type-to-answer': return this.toggleTypeToAnswer(userId, message);
default: super.message(userId, message);
}
}

buzz (userId) {
if (!this.settings.typeToAnswer && this.buzzes.includes(userId)) {
this.giveAnswer(userId, { givenAnswer: this.tossup.answer_sanitized });
return;
}

super.buzz(userId);
}

get liveAnswer () {
return document.getElementById('answer-input').value;
}
Expand Down Expand Up @@ -74,4 +89,14 @@ export default class ClientTossupRoom extends TossupRoom {

this.emitMessage({ type: 'toggle-correct', correct, userId });
}

toggleShowHistory (userId, { showHistory }) {
this.settings.showHistory = showHistory;
this.emitMessage({ type: 'toggle-show-history', showHistory, userId });
}

toggleTypeToAnswer (userId, { typeToAnswer }) {
this.settings.typeToAnswer = typeToAnswer;
this.emitMessage({ type: 'toggle-type-to-answer', typeToAnswer, userId });
}
}
2 changes: 1 addition & 1 deletion client/singleplayer/bonuses/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import questionStats from '../../scripts/auth/question-stats.js';
import api from '../../scripts/api/index.js';
import audio from '../../audio/index.js';
import { arrayToRange, createBonusCard, rangeToArray } from '../../scripts/utilities/index.js';
import CategoryManager from '../../scripts/utilities/category-manager.js';
import CategoryManager from '../../../quizbowl/category-manager.js';
import { getDropdownValues } from '../../scripts/utilities/dropdown-checklist.js';
import CategoryModal from '../../scripts/components/CategoryModal.min.js';
import DifficultyDropdown from '../../scripts/components/DifficultyDropdown.min.js';
Expand Down
2 changes: 1 addition & 1 deletion client/singleplayer/bonuses/index.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c079bde

Please sign in to comment.