Skip to content

Commit

Permalink
fix(FilePreviewDialog): make path property optional (#1380)
Browse files Browse the repository at this point in the history
Signed-off-by: Mathis Mensing <github@matmen.dev>
  • Loading branch information
matmen committed Mar 2, 2024
1 parent 04abea4 commit 85facaa
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/components/widgets/filesystem/FilePreviewDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,15 @@ import StateMixin from '@/mixins/state'
import type { AppFile } from '@/store/files/types'
import { Marked, type MarkedExtension } from 'marked'
import { baseUrl } from 'marked-base-url'
import { consola } from 'consola'
@Component({})
export default class FilePreviewDialog extends Mixins(StateMixin) {
@VModel({ type: Boolean })
open?: boolean
@Prop({ type: String, required: true })
readonly path!: string
@Prop({ type: String })
readonly path?: string
@Prop({ type: Object })
readonly file?: AppFile
Expand Down Expand Up @@ -128,6 +129,12 @@ export default class FilePreviewDialog extends Mixins(StateMixin) {
}
async LoadMarkdown () {
if (!this.path) {
// refuse rendering markdown if no base path has been supplied
consola.error('[FilePreviewDialog] missing path property in markdown viewer')
return
}
const response = await fetch(this.src)
const data = await response.text()
Expand Down

0 comments on commit 85facaa

Please sign in to comment.