gristlabs_grist-core/app
Alex Hall 546096fcc9 (core) Clean up and refactor uses of HomeDBManager.getDoc
Summary:
Firstly I just wanted some more consistency and less repetition in places where Documents are retrieved from the DB, so it's more obvious when code differs from the norm. Main changes for that part:

- Let HomeDBManager accept a `Request` directly and convert it to a `Scope`, and use this in a few places.
- `getScope` tries `req.docAuth.docId` if `req.params` doesn't have a docId.

I also refactored how `_createActiveDoc` gets the document URL, separating out getting the document from getting a URL for it. This is because I want to use that document object in a future diff, but I also just find it cleaner. Notable changes for that:

- Extracted a new method `HomeDBManager.getRawDocById` as an alternative to `getDoc` that's explicitly for when you only have a document ID.
- Removed the interface method `GristServer.getDocUrl` and its two implementations because it wasn't used elsewhere and it didn't really add anything on top of getting a doc (now done by `getRawDocById`) and `getResourceUrl`.
- Between `cachedDoc` and `getRawDocById` (which represent previously existing code paths) also try `getDoc(getScope(docSession.req))`, which is new, because it seems better to only `getRawDocById` as a last resort.

Test Plan: Existing tests

Reviewers: georgegevoian

Reviewed By: georgegevoian

Differential Revision: https://phab.getgrist.com/D3328
2022-03-24 13:42:36 +02:00
..
client (core) Conditional formatting rules 2022-03-23 13:15:02 +01:00
common (core) Conditional formatting rules 2022-03-23 13:15:02 +01:00
gen-server (core) Clean up and refactor uses of HomeDBManager.getDoc 2022-03-24 13:42:36 +02:00
plugin (core) add grist.getTable(tableId) and a getTableId() method in plugin api 2022-03-17 16:31:19 -04:00
server (core) Clean up and refactor uses of HomeDBManager.getDoc 2022-03-24 13:42:36 +02:00
tsconfig.json (core) move home server into core 2020-07-21 20:39:10 -04:00