From df861ef3f9e9c5c86b7a9a638c48409ffda4ab47 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Z=C3=A9fling?= <zefling@ikilote.net>
Date: Mon, 9 Sep 2024 21:58:23 +0200
Subject: [PATCH] Ajout du nombre de bulletins

---
 src/app/app.component.html | 2 +-
 src/app/app.component.ts   | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/app/app.component.html b/src/app/app.component.html
index 233cf7d..bdccdb3 100644
--- a/src/app/app.component.html
+++ b/src/app/app.component.html
@@ -120,7 +120,7 @@
                         </div>
                     }
                 </div>
-                <p>Votants : {{ users.length }} | Votes : {{ total() || 0 }}</p>
+                <p>Votants : {{ users.length }} | Votes : {{ total() || 0 }} | Bulletins : {{ ballot() }}</p>
             </section>
         }
         <section class="live-chat">
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index f96a546..53a2a33 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -21,6 +21,7 @@ export class AppComponent {
     choices: Record<string, Choice | undefined> = {};
     users: User[] = [];
     total = signal(0);
+    ballot = signal(0);
 
     client?: Client;
 
@@ -139,6 +140,7 @@ export class AppComponent {
         this.messages = [];
         this.users = [];
         this.total.set(0);
+        this.ballot.set(0);
     }
 
     private status(tags: ChatUserstate): Status {
@@ -185,6 +187,7 @@ export class AppComponent {
                     if (!choice.details.find(e => e.username === tags.username) && this.testAcceptVotesByUser(user)) {
                         choice.details.push(user);
                         choice.total += weight;
+                        this.ballot.update(v => v + weight);
                         user.choices.push(choice);
                         tag = `<span>${number}</span>`;
                     }
@@ -195,6 +198,7 @@ export class AppComponent {
                         total: weight,
                         details: [user],
                     };
+                    this.ballot.update(v => v + weight);
                     user.choices.push(choice);
                     this.choices[number] = choice;
                     tag = `<span>${number}</span>`;
-- 
GitLab