Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/api error #112

Merged
merged 2 commits into from
Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/store/modules/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,22 @@ const getters = {
recent_images_condensed: state => {
// First, generate a map of maximum SSTKNUM for each SMARTSTK
const maxSSTKNUMs = state.recent_images.reduce((acc, cur) => {
if (!cur.header || !cur.header.SMARTSTK || !cur.header.SSTKNUM) return acc // Skip if missing header, SMARTSTK or SSTKNUM
if (!cur.SMARTSTK || !cur.SSTKNUM) return acc // Skip if missing SMARTSTK or SSTKNUM

const num = parseInt(cur.header.SSTKNUM) // convert string to number
if (!acc[cur.header.SMARTSTK] || num > acc[cur.header.SMARTSTK]) {
acc[cur.header.SMARTSTK] = num
const num = parseInt(cur.SSTKNUM) // convert string to number
if (!acc[cur.SMARTSTK] || num > acc[cur.SMARTSTK]) {
acc[cur.SMARTSTK] = num
}
return acc
}, {})

// Now, filter the original array
const filteredArr = state.recent_images.filter(el => {
// Keep if missing header, SMARTSTK or SSTKNUM
if (!el.header || !el.header.SMARTSTK || !el.header.SSTKNUM) return true
// Keep if missing SMARTSTK or SSTKNUM
if (!el.SMARTSTK || !el.SSTKNUM) return true

// Keep if SSTKNUM is the maximum for its SMARTSTK
return el.header.SSTKNUM >= maxSSTKNUMs[el.header.SMARTSTK]
return el.SSTKNUM >= maxSSTKNUMs[el.SMARTSTK]
})
return filteredArr
},
Expand Down Expand Up @@ -200,8 +200,8 @@ const actions = {
// Reassigning value of current_image to new_image
// If a user takes smart stack photos and they select the image as it's updating,
// then the selected image (i.e. the thumbnail with the surrounding yellow border) keeps the yellow border
const current_image_SMARTSTK = state.current_image.header && state.current_image.header.SMARTSTK
const new_image_SMARTSTK = new_image.header && new_image.header.SMARTSTK
const current_image_SMARTSTK = state.current_image.SMARTSTK
const new_image_SMARTSTK = new_image.SMARTSTK
if (current_image_SMARTSTK && current_image_SMARTSTK !== 'no' && current_image_SMARTSTK === new_image_SMARTSTK) {
commit('setCurrentImage', new_image)
}
Expand Down
Loading