Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion frontend/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { initCollectionsListeners } from '@frontend/composables/useCollections'
import { useAuthSocket } from '@frontend/composables/useAuthSocket'
import { initCollectionsListeners } from '@frontend/composables/useCollections'
import { useAuthStore } from '@frontend/stores/auth.store'
import { useCollectionsStore } from '@frontend/stores/collections.store'

Expand Down
8 changes: 8 additions & 0 deletions frontend/src/components/collection/CollectionsControls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ const ordinalSuffix = (n: number): string => ordinal(n).slice(-2)
:disabled="store.isBatchLoading"
@click="emit('select:currentPage')"
/>
<Button
class="hover-primary"
severity="secondary"
outlined
label="Unuploaded"
:disabled="store.isBatchLoading"
@click="store.selectUnuploaded()"
/>
Comment on lines +135 to +142

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 "Unuploaded" selects all items when status hasn't been checked

selectUnuploaded considers every item with existing.length === 0 as unuploaded. Before a Commons status check runs, all items have an empty existing array by default, so clicking this button is functionally identical to "All images" — but the label implies the system already knows which images are absent from Commons. The store already exposes anyItemsWithExistingFiles (true once at least one match has been found), which could gate the button's visibility via v-if="store.anyItemsWithExistingFiles" or at least disable it with a tooltip until status data is available.

Fix in Claude Code

<Button
v-if="store.selectedCount > 0"
class="hover-danger-filled"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/composables/__tests__/useAuthSocket.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const mockSocketImpl = () => ({
mock.module('@frontend/composables/useSocket', mockSocketImpl)
mock.module('../useSocket', mockSocketImpl)

import { useAuthStore } from '@frontend/stores/auth.store'
import type { useAuthSocket as UseAuthSocketType } from '@frontend/composables/useAuthSocket'
import { useAuthStore } from '@frontend/stores/auth.store'
import { resolve } from 'node:path'

describe('useAuthSocket', () => {
Expand Down
28 changes: 28 additions & 0 deletions frontend/src/stores/__tests__/collections.store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,34 @@ describe('selection methods', () => {
expect(store.itemsArray.map((i) => i.meta.selected)).toEqual([true, true, true])
})
})

describe('selectUnuploaded', () => {
it('selects items with no existing Commons file', () => {
const store = useCollectionsStore()
const notUploaded = makeItem(1)
const uploaded = makeItem(2)
uploaded.image.existing = [{ url: 'https://commons.wikimedia.org/wiki/File:Test.jpg' }]

store.replaceItems({ 'item-1': notUploaded, 'item-2': uploaded })

store.selectUnuploaded()

expect(store.itemsArray.map((i) => i.meta.selected)).toEqual([true, false])
})

it('deselects previously selected items that have an existing Commons file', () => {
const store = useCollectionsStore()
const selected = makeItem(1, true)
selected.image.existing = [{ url: 'https://commons.wikimedia.org/wiki/File:Test.jpg' }]
const unselected = makeItem(2, false)

store.replaceItems({ 'item-1': selected, 'item-2': unselected })

store.selectUnuploaded()

expect(store.itemsArray.map((i) => i.meta.selected)).toEqual([false, true])
})
})
})

describe('collections store — preset state', () => {
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/stores/collections.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ export const useCollectionsStore = defineStore('collections', () => {
}
}

const selectUnuploaded = () => {
for (const item of itemsArray.value) {
item.meta.selected = item.image.existing.length === 0
}
}

const toFilterItems = (storeItems: typeof chronoItems.value): FilterItem[] =>
storeItems.map((item) => ({
capturedAt: item.image.dates.taken,
Expand Down Expand Up @@ -408,6 +414,7 @@ export const useCollectionsStore = defineStore('collections', () => {
updateSelected,
selectAll,
deselectAll,
selectUnuploaded,
selectEveryNth,
selectByMinInterval,
selectByMinDistance,
Expand Down