Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update live edit feature to protect against overwriting modified content #1466

Merged
merged 4 commits into from
Nov 17, 2023

Conversation

caendesilva
Copy link
Member

Updates the live edit feature to protect against overwriting content modified in other tabs/editors. This works by restoring the JavaScript form handler together with a hidden input for the source file hash as it is on the page load. The backend returns a 409 response when the supplied content hash does not match the current one. The frontend then catches the 409 response, prints a JavaScript alert to ask the user if they want to overwrite the page, if they select yes, then the request is send again with a force parameter.

Updates the live edit feature to protect against overwriting content modified in other tabs/editors
Copy link

codecov bot commented Nov 17, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (c0df45b) 100.00% compared to head (56be457) 100.00%.

Additional details and impacted files
@@              Coverage Diff              @@
##              master     #1466     +/-   ##
=============================================
  Coverage     100.00%   100.00%             
- Complexity      1728      3456   +1728     
=============================================
  Files            180       360    +180     
  Lines           4693      9386   +4693     
=============================================
+ Hits            4693      9386   +4693     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Hashing the file takes over 0.100ms (due to having to load the file again), which arguably is not much, but considering that hashing the content already stored in memory is less than 0.007ms which is an order of magnitude faster, for something that does not affect the feature.
@caendesilva caendesilva marked this pull request as ready for review November 17, 2023 14:38
@caendesilva caendesilva merged commit e49ff4c into master Nov 17, 2023
19 checks passed
@caendesilva caendesilva deleted the realtime-compiler-live-edit branch November 17, 2023 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant