Skip to content

Commit

Permalink
Merge pull request #283 from leepeuker/280-rating-is-editable-when-no…
Browse files Browse the repository at this point in the history
…t-having-clicked-on-the-edit-button-in-the-movie-page

Fix UX issues with rating stars on movie detail page
  • Loading branch information
leepeuker authored Feb 15, 2023
2 parents f441fc3 + 98266cf commit 14e8332
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 7 additions & 0 deletions public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ if ('serviceWorker' in navigator) {
})
}

let ratingEditMode = false

async function searchTmdbWithLogModalSearchInput() {
resetLogModalSearchResults()
document.getElementById('logPlayModalSearchSpinner').classList.remove('d-none')
Expand Down Expand Up @@ -137,6 +139,7 @@ function updateLogPlayModalButtonState() {
}

document.getElementById('logPlayModalSearchInput').addEventListener('keypress', loadLogModalSearchResultsOnEnterPress);

function loadLogModalSearchResultsOnEnterPress(event) {
// 13=enter, works better to check the key code because the key is named differently on mobile
if (event.keyCode === 13) {
Expand Down Expand Up @@ -307,6 +310,10 @@ async function fetchRating(tmdbId) {
}

function setRatingStars(context, newRating) {
if (context === 'movie' && ratingEditMode === false) {
return
}

if (getRatingFromStars(context) == newRating) {
newRating = 0
}
Expand Down
3 changes: 1 addition & 2 deletions public/js/movie.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
let ratingEditMode = false
let originalRating

function deleteWatchDate() {
Expand Down Expand Up @@ -75,7 +74,7 @@ function saveRating() {
function resetRating(e) {
ratingEditMode = true

setRatingStars('logPlayModal', 0)
setRatingStars('movie', 0)
saveRating(e)

ratingEditMode = false
Expand Down

0 comments on commit 14e8332

Please sign in to comment.