v3 : interface d'une version retenue — « Contre » et « Retirer mon vote », jamais « Pour »
Sous l'article, une version retenue montre « Contre » et le retrait, avec la phrase qui dit pourquoi. Dans le panier, elle se choisit en « contre » ou en retrait ; « Tout pour » la saute et le dit, « Tout contre » la prend ; un « pour » gardé d'avant l'objection quitte le panier (basket.kept). Les phrases qui disaient « ne se vote plus » disent la règle d'Yvv, en fr, en et es. C28 ajusté. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,15 +1,18 @@
|
||||
// The basket of the reader: the choices not sent yet, kept for the tab (a reload
|
||||
// or a look at another article does not lose them), one basket per document.
|
||||
|
||||
import type { Picks } from './basket';
|
||||
import { kept, type Picks, type Votable } from './basket';
|
||||
import type { Choice } from './types';
|
||||
|
||||
export class BasketState {
|
||||
picks = $state<Picks>({});
|
||||
#key = '';
|
||||
|
||||
/** Takes back the basket of this document, keeping only the versions still open to vote. */
|
||||
load(docId: string, known: Set<string>) {
|
||||
/**
|
||||
* Takes back the basket of this document, keeping only the choices still open: a
|
||||
* version gone leaves it, and so does a « for » on a version an objection holds back.
|
||||
*/
|
||||
load(docId: string, known: Votable) {
|
||||
const key = `ld:basket:${docId}`;
|
||||
if (key === this.#key) {
|
||||
this.#keep(known);
|
||||
@@ -27,9 +30,9 @@ export class BasketState {
|
||||
this.#keep(known);
|
||||
}
|
||||
|
||||
#keep(known: Set<string>) {
|
||||
const kept = Object.fromEntries(Object.entries(this.picks).filter(([id]) => known.has(id)));
|
||||
if (Object.keys(kept).length !== Object.keys(this.picks).length) this.set(kept);
|
||||
#keep(known: Votable) {
|
||||
const still = kept(this.picks, known);
|
||||
if (Object.keys(still).length !== Object.keys(this.picks).length) this.set(still);
|
||||
}
|
||||
|
||||
set(picks: Picks) {
|
||||
|
||||
Reference in New Issue
Block a user