Ghost/ghost/admin/app/components/modal-post-preview
Kevin Ansfield c646e78fff Made session.user a synchronous property rather than a promise
no issue

Having `session.user` return a promise made dealing with it in components difficult because you always had to remember it returned a promise rather than a model and had to handle the async behaviour. It also meant that you couldn't use any current user properties directly inside getters which made refactors to Glimmer/Octane idioms harder to reason about.

`session.user` was a cached computed property so it really made no sense for it to be a promise - it was loaded on first access and then always returned instantly but with a fulfilled promise rather than the  underlying model.

Refactoring to a synchronous property that is loaded as part of the authentication flows (we load the current user to check that we're logged in - we may as well make use of that!) means one less thing to be aware of/remember and provides a nicer migration process to Glimmer components. As part of the refactor, the auth flows and pre-load of required data across other services was also simplified to make it easier to find and follow.

- refactored app setup and `session.user`
  - added `session.populateUser()` that fetches a user model from the current user endpoint and sets it on `session.user`
  - removed knowledge of app setup from the `cookie` authenticator and moved it into = `session.postAuthPreparation()`, this means we have the same post-authentication setup no matter which authenticator is used so we have more consistent behaviour in tests which don't use the `cookie` authenticator
  - switched `session` service to native class syntax to get the expected `super()` behaviour
  - updated `handleAuthentication()` so it populate's `session.user` and performs post-auth setup before transitioning (handles sign-in after app load)
  - updated `application` route to remove duplicated knowledge of app preload behaviour that now lives in `session.postAuthPreparation()` (handles already-authed app load)
  - removed out-of-date attempt at pre-loading data from setup controller as that's now handled automatically via `session.handleAuthentication`
- updated app code to not treat `session.user` as a promise
  - predominant usage was router `beforeModel` hooks that transitioned users without valid permissions, this sets us up for an easier removal of the `current-user-settings` mixin in the future
2021-07-08 14:54:31 +01:00
..
browser.hbs Fixed Safari bug not showing full-height post preview 2021-03-09 09:52:35 +01:00
browser.js Added share/send preview footers to post preview modal 2021-02-02 16:08:05 +00:00
email.hbs Made session.user a synchronous property rather than a promise 2021-07-08 14:54:31 +01:00
email.js Made session.user a synchronous property rather than a promise 2021-07-08 14:54:31 +01:00
mobile.hbs Added link to preview-in-new-tab button 2021-02-16 11:51:32 +00:00
mobile.js Improved preview post modal design and added mobile view 2021-02-02 16:08:05 +00:00
social.hbs Updated metadata description preview cutoff point across admin 2021-05-05 17:33:59 +02:00
social.js Fixed url formatting in search engine result previews 2021-03-30 10:10:34 +01:00