- remove unnecessary / deprecated code

This commit is contained in:
2026-05-06 19:34:13 +02:00
parent 5ecb5f1076
commit 424799692a
4 changed files with 9 additions and 138 deletions

View File

@@ -2,10 +2,9 @@ import { getUserId } from "./identity";
import {
addOption,
toggleVote,
deleteOption,
setDeadline,
clearDeadline,
createViewModel,
getDeadline,
} from "./state";
import { initSync } from "./sync";
import { StatusBar } from "./components/StatusBar";
@@ -48,18 +47,13 @@ export function initApp(container: HTMLElement): () => void {
const actions = {
addOption: (label: string) => {
const vm = createViewModel(getViewModelParams());
if (vm.votingClosed) return;
if (isVotingClosed()) return;
return addOption(sync.options, label, userId);
},
toggleVote: (optionId: string) => {
const vm = createViewModel(getViewModelParams());
if (vm.votingClosed) return;
if (isVotingClosed()) return;
toggleVote(sync.votes, userId, optionId);
},
deleteOption: (optionId: string) => {
deleteOption(sync.options, sync.votes, optionId);
},
startDeadline: (durationMs: number) => {
setDeadline(sync.deadlineMap, durationMs);
},
@@ -68,18 +62,10 @@ export function initApp(container: HTMLElement): () => void {
},
};
function getViewModelParams() {
return {
yTitle: sync.yTitle,
options: sync.options,
votes: sync.votes,
deadlineMap: sync.deadlineMap,
roomId,
shareUrl,
connectionStatus: sync.getConnectionStatus(),
peerCount: sync.getPeerCount(),
userId,
};
function isVotingClosed() {
const deadline = getDeadline(sync.deadlineMap);
const votingClosed = deadline !== null && Date.now() >= deadline;
return votingClosed;
}
// --- Build UI ---
@@ -112,10 +98,7 @@ export function initApp(container: HTMLElement): () => void {
if (result && !result.ok) return result.error;
return null;
});
const pollList = PollList(sync.options, sync.votes, userId, () => {
const vm = createViewModel(getViewModelParams());
return vm.votingClosed;
}, actions.toggleVote, actions.deleteOption);
const pollList = PollList(sync.options, sync.votes, userId, isVotingClosed, actions.toggleVote);
const deadlineTimer = DeadlineTimer(
sync.deadlineMap,
actions.startDeadline,