Skip to content

Use list of own attachment files in AttachmentResolver #3974

@mejo-

Description

@mejo-

Summary

Currently AttachmentResolver.js misses important information about attachments, which leads to a lot of complexity in resolving attachments.

To make this more straight-forward (at least for "own attachment files" - a.k.a. the ones living in .attachments.<fileId>), we could do the following:

  • Add an API endpoint to get the list of files in the attachment folder along with their metadata (fileId, fileName, size, mimetype, timestamp, hasPreview, maybe even davUrl already). This endpoint would need to allow authentication both via Text session and via logged in user.
  • Always request this list when loading a Text document in Editor.vue (asynchronously, non-blocking).
  • When resolving attachments in AttachmentResolver.js, look up the attachment in the retained list and use all available information from there.

Implementation details

  • The list could either be stored in vuex store or the promise of the request could be passed to AttachmentResolver constructor.
  • When a new attachment is uploaded in Text, we either have to add it to the list in frontend, or retrieve an updated list as response and replace the list. (That might be arguments to maintain the list in vuex store 🤔)

Advantages

  • For "own attachments" we could return better first candidates from AttachmentResolver.
    • Non-image attachments would get a first candidate with type: media, resulting in fewer requests during <img> loads.
    • No extra requests required for getting metadata for attachments.
  • We would have the fileId of attachments available.

Disadvantages

  • One more backend request (at least for documents without attachments).

@juliushaertl @julien-nc @max-nextcloud for feedback.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

☑️ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions