Skip to content

Commit e07ce35

Browse files
fix(tables): drop the card image where no preview can be fetched
A preview is served against the viewer's session, so on a public link there is none to authenticate with and the image can never arrive. Cards still asked for one, leaving a broken image on every card of a shared tiles or gallery view. Ask for no preview at all when there is no session, and take the image area out of the card rather than leaving it empty, so a shared card reads as the text it can actually show. The title then has the whole card to use instead of a share of an image that is not there. Assisted-by: ClaudeCode:claude-opus-5 Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
1 parent f6858d8 commit e07ce35

1 file changed

Lines changed: 35 additions & 2 deletions

File tree

src/shared/components/ncTable/sections/CustomTable.vue

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
<div v-else
5757
ref="cardLayout"
5858
class="card-layout"
59-
:class="[`card-layout--${currentLayout}`, { 'card-layout--no-image': !hasCardBackground }]"
59+
:class="[`card-layout--${currentLayout}`, { 'card-layout--no-image': !hasCardBackground, 'card-layout--no-previews': !canRenderPreviews }]"
6060
:style="{ '--card-title-lines': cardTitleLines }">
6161
<button v-for="row in currentPageRows"
6262
:key="row.id"
@@ -105,6 +105,7 @@ import { NcRichText } from '@nextcloud/vue'
105105
import { ColumnTypes } from '../mixins/columnHandler.js'
106106
import { translate as t } from '@nextcloud/l10n'
107107
import { generateUrl } from '@nextcloud/router'
108+
import { getCurrentUser } from '@nextcloud/auth'
108109
109110
// Share of the card image the title banner may cover before the text is ellipsized.
110111
const MAX_TITLE_BANNER_SHARE = 0.6
@@ -177,8 +178,15 @@ export default {
177178
},
178179
179180
computed: {
181+
// A preview is served against the viewer's session. Without one, as on a public link,
182+
// it can never load, so the card is laid out as if it had no image at all rather than
183+
// reserving space for something that will stay empty.
184+
canRenderPreviews() {
185+
return getCurrentUser() !== null
186+
},
180187
hasCardBackground() {
181-
return this.localViewSetting?.viewSettings?.cardBackgroundSource !== null
188+
return this.canRenderPreviews
189+
&& this.localViewSetting?.viewSettings?.cardBackgroundSource !== null
182190
&& this.localViewSetting?.viewSettings?.cardBackgroundSource !== undefined
183191
},
184192
currentLayout() {
@@ -256,6 +264,12 @@ export default {
256264
},
257265
258266
updateCardTitleLines() {
267+
// With no image area to share, the title is simply the text of the card and the
268+
// geometry below would measure the title against itself.
269+
if (!this.canRenderPreviews) {
270+
this.cardTitleLines = MAX_TITLE_LINES
271+
return
272+
}
259273
const container = this.$refs.cardLayout
260274
const wrapper = container?.querySelector('.layout-card__image-wrapper')
261275
const banner = container?.querySelector('.layout-card__title-banner')
@@ -334,6 +348,9 @@ export default {
334348
return row?.data?.find(item => item?.columnId === columnId) ?? null
335349
},
336350
getPreviewUrl(row) {
351+
if (!this.canRenderPreviews) {
352+
return null
353+
}
337354
const backgroundColumn = this.getBackgroundColumn()
338355
const rawValue = this.getCell(row, backgroundColumn?.id)?.value
339356
if (rawValue === null || rawValue === undefined || rawValue === '') {
@@ -546,6 +563,22 @@ export default {
546563
bottom: auto;
547564
}
548565
566+
/* Without a session a preview can never arrive, so the image area is not just left empty but
567+
taken out of the card: the title flows straight into the card instead. */
568+
.card-layout--no-previews .layout-card__image-wrapper {
569+
aspect-ratio: auto;
570+
background: none;
571+
}
572+
573+
.card-layout--no-previews .layout-card__no-image {
574+
display: none;
575+
}
576+
577+
.card-layout--no-previews .layout-card__title-banner {
578+
position: static;
579+
max-height: none;
580+
}
581+
549582
.layout-card__title-text {
550583
display: -webkit-box;
551584
-webkit-line-clamp: var(--card-title-lines, 2);

0 commit comments

Comments
 (0)