Repository navigation
Todo
Labels
enhancementNew feature or request
Description
Is your feature request related to a problem? Please describe.
- Every widget and view calls the API on its own today. A page with four widgets on one table makes four calls for the same data. Proposal P13, with P16 for the
api/2part.
Why this is needed
- A page with four widgets on one table makes four calls for the same rows, because every widget and view calls the API on its own.
- buildiq parity: buildiq renders on nextcloud-vue, whose object store caches per source, coalesces requests and invalidates on change. Proposal P13 takes that store as the model.
- Plan: P13 with P16 (every new capability on
api/2, the internal routes retire once nothing calls them). It depends on the rows listing (Rows listing endpoint on api/2 with filter, sort, search and paging #3095) and on theapi/2routes that are missing today (api/2 routes for capabilities that are internal-only today #3205, Update and delete columns on api/2 #3467). Server-side paging (Server-side paging, filter and search in the table view above a row threshold #3430) and the widgets read through it. Moved to a later sprint on 30 November, owner open.
Describe the solution you'd like
- One store in the Tables frontend for rows and their sources. It caches collections and items per table or view, shares one request when two widgets ask for the same page, and drops the cache of a source when a row in it is created, updated or deleted. It calls
api/2only.
Diagram
sequenceDiagram
participant W1 as Data widget
participant W2 as Stat widget
participant S as Tables store (new)
participant API as api/2 rows routes
W1->>S: page 1 of table 12
W2->>S: page 1 of table 12
S->>API: one request
API-->>S: rows
S-->>W1: rows from the cache
S-->>W2: rows from the cache
W1->>S: update a row
S->>API: PUT the row
S->>S: drop cached pages of table 12 and its views
S-->>W2: refresh
Acceptance Criteria
- Collections and single rows are cached per source and per query.
- Two identical requests in flight lead to one network call.
- A row change through the store invalidates the cached pages of its table and of the views on it.
- The store uses
api/2routes only; where a route is missing it is added there first (api/2 routes for capabilities that are internal-only today #3205). - Unit tests for the cache, the coalescing and the invalidation.
- A route added to
api/2for the store declares its permission with#[RequirePermission]using a fixed node type, and the service checks the same right before it writes. A test runs every write as a reader and expects 403 (or 404 where the reader may not know the object exists), as learned in the review of feat(contexts): give applications a menu with its own API #3135.
Components
- useObjectStore (rewrite, week 44): the store of this issue. Its methods (
registerType,fetchSchema,fetchCollection,fetchObject,saveObject,deleteObject,resolveReferences) are rewritten on theapi/2rows and schema routes of Tables, and the per-source cache, the shared request and the invalidation live in it. Every adapt component reaches Tables through it.
Out of scope
- Subscribing to row events: later, by P13.
- Moving every component onto the store at once.
- Slicing, in landing order: one PR for the store with rows, then one PR per consumer, the data widget first, then the table view.
Describe alternatives you've considered
Questions for maintainers
- Grow the existing Pinia store
src/store/data.js, or add a store beside it? Options: (a) growdata.js, (b) a new store forapi/2and move consumers one by one. We would go with (a): one place knows rows, and consumers do not change their imports. - What happens to the cache when one row changes? Options: (a) drop every cached page of the table and its views, (b) patch the row in every cached page. We would go with (a) for pages and patch the cached single row: (b) cannot know whether the row still matches a page's filter.
Additional context
Linking to other objects
- Object: rows and collections, cached in the browser per source and query.
- Today: relation and link cells come back as cell values; there is no client cache, and no links outside the cells.
- What this issue must do: key a cached row by its id (inside one instance the id is enough, as agreed on UUIDs for rows #3093), so a row reached through a list, a relation or a link of Link a row to objects in other apps: mails, Deck cards, files, rows of other tables #3468 is one cache entry. Leave room for a
linkscollection per row in the same cache, and drop a row's cached links when the row is deleted, because Link a row to objects in other apps: mails, Deck cards, files, rows of other tables #3468 deletes them with it.
Relevant files:
Related issues
- api/2 routes for capabilities that are internal-only today #3205
- Rows listing endpoint on api/2 with filter, sort, search and paging #3095
Drafted with AI assistance from the project plan; @remko48 reviews it. Part of #3419.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity