Ghost/ghost
Chris Raible cc88757e2a
Added local revisions to the editor as backstop against data loss (#21044)
ref https://app.incident.io/ghost/incidents/107

- We have a rare bug that causes the initial `POST` request to create a
new post from the editor to be skipped or fail. Subsequent `PUT`
requests then fail because there is no post ID, potentially resulting in
data loss. The aim of this commit is to start saving revisions of posts
in the editor to the browser's localStorage, as a last-ditch option to
restore lost work.
- Since we don't know where the bug is yet, and to protect against
future bugs, we've deliberately avoided depending too heavily on the
`lexical-editor` controller or the ember store. We've aimed to create a
direct route to the state in the editor, by hooking into the
`updateScratch` method (effectively the `onChange` handler for the
editor).
- The `scheduleSave` function on the new `local-revisions` service is
called immediately upon any changes to the state of the lexical editor,
which is effectively every keystroke. The service has some logic and
timeouts, so it doesn't actually save a revision on every change to the
editor.
- The "schema" of the datastore is a simple key-value store, where the
key is of the format: `post-revision-${postId}-${timestamp}` if the post
has an ID, or `post-revision-draft-${timestamp}` for an unsaved draft.
There is also an array of all the revisions' keys, which allows us to
clear all the revisions without having to loop over every key in
localStorage (along with some other conveniences, like filtering).
- There is currently no UI for viewing/restoring revisions. In the event
that you need to restore a revision, you can access the service in the
browser console. You can access all the saved revisions using the
`list()` method, which logs all the revisions to the console by title &
timestamp. You can then choose a revision to restore, and call
`restore(revision_key)`, which will `POST` the revision's data to the
server to create a new post.
- Since localStorage data is limited to a 5mb quota in most browsers,
the service has a mechanism for evicting the oldest revisions once it
meets the quota. If a save fails because it would exceed the quota, the
`performSave` method will evict the oldest revision, then recursively
try to save again.

---------

Co-authored-by: Steve Larson <9larsons@gmail.com>
2024-09-20 00:08:28 -07:00
..
adapter-cache-memory-ttl Configured all unit tests to use dot reporter 2023-10-05 12:24:24 +02:00
adapter-cache-redis Added an optional timeout parameter to AdapterCacheRedis (#20131) 2024-05-02 20:39:23 -07:00
adapter-manager Update TryGhost packages 2024-08-05 12:12:34 +02:00
admin Added local revisions to the editor as backstop against data loss (#21044) 2024-09-20 00:08:28 -07:00
announcement-bar-settings Configured all unit tests to use dot reporter 2023-10-05 12:24:24 +02:00
api-framework Update TryGhost packages 2024-08-05 12:12:34 +02:00
api-version-compatibility-service Fixed handling requests with mismatching version and missing key 2024-05-02 13:03:26 +02:00
audience-feedback 🔒 Added uuid verification to member endpoints not requiring a session 2024-08-20 16:24:02 +02:00
bookshelf-repository 🐛 Fixed member filtering for "Unsubscribed from newsletter" filters (#20926) 2024-09-16 11:16:49 +02:00
bootstrap-socket Update TryGhost packages 2024-08-05 12:12:34 +02:00
collections 🐛 Fixed member filtering for "Unsubscribed from newsletter" filters (#20926) 2024-09-16 11:16:49 +02:00
constants Configured all unit tests to use dot reporter 2023-10-05 12:24:24 +02:00
core 🐛 Fixed fetching and storing bookmark card icons and thumbnails (#21036) 2024-09-19 15:52:08 +05:30
custom-theme-settings-service 🐛 Fixed member filtering for "Unsubscribed from newsletter" filters (#20926) 2024-09-16 11:16:49 +02:00
data-generator Update TryGhost packages 2024-08-05 12:12:34 +02:00
domain-events Update TryGhost packages 2024-08-05 12:12:34 +02:00
donations Switched build and build:ts scripts 2024-09-02 15:20:03 +02:00
dynamic-routing-events Configured all unit tests to use dot reporter 2023-10-05 12:24:24 +02:00
email-addresses Update dependency nodemailer to v6.9.15 2024-09-03 16:26:49 +00:00
email-analytics-provider-mailgun Reimplemented email analytics prioritizing email opens (#20914) 2024-09-05 08:10:07 -05:00
email-analytics-service Reimplemented email analytics prioritizing email opens (#20914) 2024-09-05 08:10:07 -05:00
email-content-generator Lazyloaded several required dependencies 2024-07-26 09:52:26 +02:00
email-events Configured all unit tests to use dot reporter 2023-10-05 12:24:24 +02:00
email-service Update dependency html-validate to v8.22.0 2024-09-11 12:03:53 +02:00
email-suppression-list Configured all unit tests to use dot reporter 2023-10-05 12:24:24 +02:00
express-dynamic-redirects Configured all unit tests to use dot reporter 2023-10-05 12:24:24 +02:00
external-media-inliner Add Lexical support to the external-media-inliner (#19149) 2023-11-29 17:56:03 +00:00
extract-api-key Configured all unit tests to use dot reporter 2023-10-05 12:24:24 +02:00
ghost Update dependency express to v4.21.0 2024-09-12 07:37:27 +02:00
html-to-plaintext Configured all unit tests to use dot reporter 2023-10-05 12:24:24 +02:00
i18n 🎨 wrapped missing i18n strings in portal (#21042) 2024-09-19 13:30:45 +01:00
importer-handler-content-files Configured all unit tests to use dot reporter 2023-10-05 12:24:24 +02:00
importer-revue Update Koenig packages 2024-08-14 15:34:44 +01:00
in-memory-repository 🐛 Fixed member filtering for "Unsubscribed from newsletter" filters (#20926) 2024-09-16 11:16:49 +02:00
job-manager Update dependency @sinonjs/fake-timers to v11.3.1 2024-08-26 14:08:32 +02:00
link-redirects Updated documentation for LinkRedirects (#20378) 2024-06-12 23:27:15 +00:00
link-replacer Pinned dependencies (#20257) 2024-05-27 15:29:32 +00:00
link-tracking 🐛 Fixed member filtering for "Unsubscribed from newsletter" filters (#20926) 2024-09-16 11:16:49 +02:00
magic-link Added Sentry message logging for generating magic links (#20789) 2024-08-20 08:38:12 +01:00
mail-events Switched build and build:ts scripts 2024-09-02 15:20:03 +02:00
mailgun-client Added configurable target delivery window for batch sending (#20719) 2024-09-05 22:28:40 -07:00
member-attribution Fixed extra arguments being supplied to function calls 2024-05-07 11:44:07 +02:00
member-events 🎨 Added staff notification when a sub is canceled due to failed payments (#20534) 2024-07-15 08:07:18 +02:00
members-api 🎨 Added a maximum limit of 100 for GET members admin endpoint (#20643) 2024-09-18 11:17:56 +00:00
members-csv Update dependency pump to v3.0.2 2024-09-11 10:16:42 +00:00
members-events-service Added caching to LastSeenAtUpdater (#20964) 2024-09-13 00:54:43 -07:00
members-importer Update TryGhost packages 2024-08-05 12:12:34 +02:00
members-ssr Update TryGhost packages 2024-08-05 12:12:34 +02:00
mentions-email-report Configured all unit tests to use dot reporter 2023-10-05 12:24:24 +02:00
milestones Update TryGhost packages 2024-08-05 12:12:34 +02:00
minifier Update dependency terser to v5.33.0 2024-09-17 12:27:26 +00:00
model-to-domain-event-interceptor Switched build and build:ts scripts 2024-09-02 15:20:03 +02:00
mw-api-version-mismatch Update TryGhost packages 2024-08-05 12:12:34 +02:00
mw-cache-control Configured all unit tests to use dot reporter 2023-10-05 12:24:24 +02:00
mw-error-handler Update TryGhost packages 2024-08-05 12:12:34 +02:00
mw-session-from-token Update dependency express to v4.21.0 2024-09-12 07:37:27 +02:00
mw-update-user-last-seen Configured all unit tests to use dot reporter 2023-10-05 12:24:24 +02:00
mw-version-match Update TryGhost packages 2024-08-05 12:12:34 +02:00
mw-vhost Configured all unit tests to use dot reporter 2023-10-05 12:24:24 +02:00
nql-filter-expansions Switched build and build:ts scripts 2024-09-02 15:20:03 +02:00
oembed-service 🐛 Fixed fetching and storing bookmark card icons and thumbnails (#21036) 2024-09-19 15:52:08 +05:30
offers Update TryGhost packages 2024-08-05 12:12:34 +02:00
package-json Update TryGhost packages 2024-08-05 12:12:34 +02:00
payments 🐛 Fixed Tips & Donations checkout error for sites with long titles 2024-09-03 21:08:24 +01:00
post-events Switched build and build:ts scripts 2024-09-02 15:20:03 +02:00
post-revisions Switched build and build:ts scripts 2024-09-02 15:20:03 +02:00
posts-service 🐛 Fixed member filtering for "Unsubscribed from newsletter" filters (#20926) 2024-09-16 11:16:49 +02:00
recommendations Switched build and build:ts scripts 2024-09-02 15:20:03 +02:00
referrers Configured all unit tests to use dot reporter 2023-10-05 12:24:24 +02:00
security Updated uuid to crypto.randomUUID() (#20821) 2024-09-12 09:09:30 +07:00
session-service Update dependency express to v4.21.0 2024-09-12 07:37:27 +02:00
settings-path-manager Update TryGhost packages 2024-08-05 12:12:34 +02:00
slack-notifications Update TryGhost packages 2024-08-05 12:12:34 +02:00
staff-service Updated notification email mobile styles 2024-08-29 17:15:45 +01:00
stats-service Update dependency luxon to v3.5.0 2024-08-05 09:19:48 +02:00
stripe Cleaned up comments after Stripe Controller refactor (#20943) 2024-09-09 05:31:52 +00:00
tiers Update TryGhost packages 2024-08-05 12:12:34 +02:00
tinybird Updated KPI pipe to fill missing data 2024-09-19 11:32:49 +01:00
update-check-service Updated uuid to crypto.randomUUID() (#20821) 2024-09-12 09:09:30 +07:00
verification-trigger Update TryGhost packages 2024-08-05 12:12:34 +02:00
version-notifications-data-service Fixed handling requests with mismatching version and missing key 2024-05-02 13:03:26 +02:00
webmentions Update TryGhost packages 2024-08-05 12:12:34 +02:00
tsconfig.json Disabled TypeScript incremental building 2023-08-09 18:27:56 +02:00