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

[stable4.0] fix: select multiple envelopes by holding shift directly #10171

Merged
merged 1 commit into from
Sep 18, 2024
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
7 changes: 4 additions & 3 deletions src/components/Envelope.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
:name="addresses"
:details="formatted()"
:one-line="oneLineLayout"
@click="onClick"
@click.ctrl.prevent="toggleSelected"
@click.exact="onClick"
@click.ctrl.exact.prevent="toggleSelected"
@click.shift.exact.prevent="onSelectMultiple"
@update:menuOpen="closeMoreAndSnoozeOptions">
<template #icon>
<Star v-if="data.flags.flagged"
Expand All @@ -35,7 +36,7 @@
:class="{ 'important-one-line': oneLineLayout, 'icon-important': !oneLineLayout }"
:data-starred="isImportant ? 'true' : 'false'"
@click.prevent="hasWriteAcl ? onToggleImportant() : false"
v-html="importantSvg" />

Check warning on line 39 in src/components/Envelope.vue

View workflow job for this annotation

GitHub Actions / NPM lint

'v-html' directive can lead to XSS attack
<JunkIcon v-if="data.flags.$junk"
:size="18"
class="app-content-list-item-star junk-icon-style"
Expand All @@ -51,7 +52,7 @@
:checked="selected">
<label :for="`select-checkbox-${data.uid}`"
@click.exact.prevent="toggleSelected"
@click.shift.prevent="onSelectMultiple" />
@click.shift.exact.prevent="onSelectMultiple" />
</p>
</div>
</template>
Expand Down Expand Up @@ -482,7 +483,7 @@

window.addEventListener('resize', this.onWindowResize)
},
computed: {

Check warning on line 486 in src/components/Envelope.vue

View workflow job for this annotation

GitHub Actions / NPM lint

The "computed" property should be above the "mounted" property on line 481
...mapGetters([
'isSnoozeDisabled',
]),
Expand Down
24 changes: 21 additions & 3 deletions src/components/EnvelopeList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -548,12 +548,15 @@
this.setEnvelopeSelected(envelope, selected)
},
onEnvelopeSelectMultiple(envelope, index) {
if (this.lastToggledIndex === undefined) {
const lastToggledIndex = this.lastToggledIndex
?? this.findSelectionIndex(parseInt(this.$route.params.threadId))
?? undefined
if (lastToggledIndex === undefined) {
return
}

const start = Math.min(this.lastToggledIndex, index)
const end = Math.max(this.lastToggledIndex, index)
const start = Math.min(lastToggledIndex, index)
const end = Math.max(lastToggledIndex, index)
const selected = this.selection.includes(envelope.databaseId)
for (let i = start; i <= end; i++) {
this.setEnvelopeSelected(this.sortedEnvelops[i], !selected)
Expand Down Expand Up @@ -585,6 +588,21 @@
this.showMoveModal = false
this.unselectAll()
},
/**
* Find the envelope list index of a given envelope's database id.
*
* @param {int} databaseId

Check warning on line 594 in src/components/EnvelopeList.vue

View workflow job for this annotation

GitHub Actions / NPM lint

The type 'int' is undefined

Check warning on line 594 in src/components/EnvelopeList.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Missing JSDoc @param "databaseId" description
* @return {int|undefined} Index or undefined if not found in the envelope list

Check warning on line 595 in src/components/EnvelopeList.vue

View workflow job for this annotation

GitHub Actions / NPM lint

The type 'int' is undefined
*/
findSelectionIndex(databaseId) {
for (const [index, envelope] of this.sortedEnvelops.entries()) {
if (envelope.databaseId === databaseId) {
return index
}
}

return undefined
},
},
}
</script>
Expand Down
Loading