From 63712199736057d78a9adf19d57a9255aaf05307 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sun, 4 Sep 2022 20:21:56 +0200 Subject: New items have 1 vote --- server.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'server.js') diff --git a/server.js b/server.js index e9d0761..da29e0a 100755 --- a/server.js +++ b/server.js @@ -37,14 +37,14 @@ class Database { this.#lastbackup = new Date(); } - add_new(string) { + add_new(votes, string) { for (let i = 0; i < this.#list.length; i++) { if (this.#list[i][1] == string) { return "already existed"; } } - this.#list.push([0, string]); + this.#list.push([votes, string]); this.#sort(); this.#persist(); @@ -162,9 +162,9 @@ io.on("connection", socket => { } }); - socket.on("new", string => { + socket.on("new", (votes, string) => { if (!logged_in) { socket.emit("unauth"); return; } - const res = database.add_new(string); + const res = database.add_new(votes, string); if (res != null) socket.emit("error", res); }); -- cgit v1.2.3-70-g09d2