From 3e194d0b1bd6254c31c2863fa6b8a253a7384b22 Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Tue, 24 Jan 2023 15:06:20 -0500 Subject: [PATCH] cache changes --- public/js/home.js | 4 ++-- src/cache.js | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/public/js/home.js b/public/js/home.js index c6f8a86..47d3e13 100644 --- a/public/js/home.js +++ b/public/js/home.js @@ -78,7 +78,7 @@ function parsePost(post) { function getPost(id) { for (let i = 0; i < data.posts.length; i++) { if (data.posts[i].id === id) { - return i + return id } } return -1 @@ -90,7 +90,7 @@ async function like(span) { const current = post.likes[data.user.id] const response = await postlike(id, !current) if (response.status != 200) return; - post.likes[data.user.id] = !current + post.likes[data.user.id] = !currentg render() } diff --git a/src/cache.js b/src/cache.js index fac8aa8..d6aa790 100644 --- a/src/cache.js +++ b/src/cache.js @@ -88,6 +88,8 @@ const register = (first, last, email, password, gender, month, day, year) => { } newest_user = data.user.id session_links[data.key] = data.user.id + password_links[data.user.password] = data.user.id + email_links[data.user.email] = data.id users[data.user.id] = data.user return data.key } @@ -104,8 +106,8 @@ const login = (email, pass) => { const logout = (token) => { - if (session_links[token] === NO_VALUE) { - return false + if (session_links[token] === NO_VALUE || session_links[token] === NO_CACHE) { + return true } if (!database.deleteSession(token)) {