summaryrefslogtreecommitdiff
path: root/server.js
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2022-09-04 20:21:56 +0200
committerTom Smeding <tom@tomsmeding.com>2022-09-04 20:23:09 +0200
commit63712199736057d78a9adf19d57a9255aaf05307 (patch)
tree08f98763766b2ea8106e4b63e13b9c7a604caa1a /server.js
parent0116c966d3d6ea914ec4b9e3e5ec6e405d37f22d (diff)
New items have 1 vote
Diffstat (limited to 'server.js')
-rwxr-xr-xserver.js8
1 files changed, 4 insertions, 4 deletions
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);
});