-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added restriction to the like button. A user can now only like a sess…
…ion one time
- Loading branch information
Showing
5 changed files
with
93 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const preferences_name = "liked_sessions"; | ||
|
||
export function isLiked(id) { | ||
const liked_sessions = JSON.parse(localStorage.getItem(preferences_name)); | ||
if (liked_sessions === null) { | ||
return false; | ||
} | ||
return liked_sessions.includes(id); | ||
} | ||
|
||
export function addSession(id) { | ||
let liked_sessions = JSON.parse(localStorage.getItem(preferences_name)); | ||
if (liked_sessions === null) { | ||
liked_sessions = [id]; | ||
} | ||
liked_sessions.push(id); | ||
localStorage.setItem(preferences_name, JSON.stringify(liked_sessions)); | ||
} | ||
|
||
export function removeSession(id) { | ||
let liked_sessions = JSON.parse(localStorage.getItem(preferences_name)); | ||
if (liked_sessions === null) { | ||
return; | ||
} | ||
liked_sessions = liked_sessions.filter((session) => session !== id); | ||
localStorage.setItem(preferences_name, JSON.stringify(liked_sessions)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters