Add autosaving to the editor #688

Yhdistetty
epsilon-phase yhdistetty 6 committia lähteestä confirmation-autosave kohteeseen master 5 vuotta sitten
epsilon-phase kommentoi 5 vuotta sitten (Migrated from github.com)

This should fix #686 Confirmation prior to navigating away is easy enough to add, but it'd be good to know if it's wanted first since this seems like it might serve the same purpose

This should fix #686 Confirmation prior to navigating away is easy enough to add, but it'd be good to know if it's wanted first since this seems like it might serve the same purpose
codecov[bot] kommentoi 5 vuotta sitten (Migrated from github.com)

Codecov Report

Merging #688 into master will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #688   +/-   ##
=======================================
  Coverage   39.35%   39.35%           
=======================================
  Files          72       72           
  Lines        9494     9494           
  Branches     2263     2263           
=======================================
  Hits         3736     3736           
  Misses       4702     4702           
  Partials     1056     1056
# [Codecov](https://codecov.io/gh/Plume-org/Plume/pull/688?src=pr&el=h1) Report > Merging [#688](https://codecov.io/gh/Plume-org/Plume/pull/688?src=pr&el=desc) into [master](https://codecov.io/gh/Plume-org/Plume/commit/865f372d5a9c0866c7ec5215afb69d2916740c07?src=pr&el=desc) will **not change** coverage. > The diff coverage is `n/a`. ```diff @@ Coverage Diff @@ ## master #688 +/- ## ======================================= Coverage 39.35% 39.35% ======================================= Files 72 72 Lines 9494 9494 Branches 2263 2263 ======================================= Hits 3736 3736 Misses 4702 4702 Partials 1056 1056 ```
trinity-1686a reviewed 5 vuotta sitten
trinity-1686a jätti kommentin
Omistaja

👀

:eyes:
Omistaja

while content is probably the most annoying to loose, if we do a local save, we should as well save everything (including subtitle, tags...)

while content is probably the most annoying to loose, if we do a local save, we should as well save everything (including subtitle, tags...)
@ -66,0 +212,4 @@
fn autosave_debounce() {
let timeout = &mut AUTOSAVE_TIMEOUT.lock().unwrap();
if let Some(timeout) = timeout.take() {
timeout.clear();
Omistaja

I guess set_interval does not exist? 😕

I guess set_interval does not exist? :confused:
epsilon-phase (Migrated from github.com) reviewed 5 vuotta sitten
@ -66,0 +212,4 @@
fn autosave_debounce() {
let timeout = &mut AUTOSAVE_TIMEOUT.lock().unwrap();
if let Some(timeout) = timeout.take() {
timeout.clear();
epsilon-phase (Migrated from github.com) kommentoi 5 vuotta sitten

It doesn't look like it, oddly.

It doesn't look like it, oddly.
epsilon-phase (Migrated from github.com) reviewed 5 vuotta sitten
epsilon-phase (Migrated from github.com) kommentoi 5 vuotta sitten

True enough, easy enough to add too

True enough, easy enough to add too
epsilon-phase (Migrated from github.com) reviewed 5 vuotta sitten
@ -66,0 +212,4 @@
fn autosave_debounce() {
let timeout = &mut AUTOSAVE_TIMEOUT.lock().unwrap();
if let Some(timeout) = timeout.take() {
timeout.clear();
epsilon-phase (Migrated from github.com) kommentoi 5 vuotta sitten

Okay, works fine in the js!

Okay, works fine in the `js!`
elegaanz (Migrated from github.com) reviewed 5 vuotta sitten
elegaanz (Migrated from github.com) jätti kommentin

I didn't tested yet, but I left a few comments about the code itself.

I didn't tested yet, but I left a few comments about the code itself.
elegaanz (Migrated from github.com) kommentoi 5 vuotta sitten

Is the type hint really needed?

Is the type hint really needed?
elegaanz (Migrated from github.com) kommentoi 5 vuotta sitten

Maybe this line should be removed ?

Maybe this line should be removed ?
elegaanz (Migrated from github.com) kommentoi 5 vuotta sitten

This one too

This one too
elegaanz (Migrated from github.com) kommentoi 5 vuotta sitten

You should use i18n! for formatting, to allow the date to be placed somewhere else in the sentence if translators need to do so.

i18n!(
    CATALOG,
    "Do you want to load the local autosave last edited at {}";
    Date::from_time(autosave_info.last_saved).to_date_string()
)
You should use `i18n!` for formatting, to allow the date to be placed somewhere else in the sentence if translators need to do so. ```rust i18n!( CATALOG, "Do you want to load the local autosave last edited at {}"; Date::from_time(autosave_info.last_saved).to_date_string() ) ```
elegaanz (Migrated from github.com) kommentoi 5 vuotta sitten

Why does it need to be unsafe?

Why does it need to be `unsafe`?
epsilon-phase (Migrated from github.com) reviewed 5 vuotta sitten
epsilon-phase (Migrated from github.com) kommentoi 5 vuotta sitten

Oh, probably not

Oh, probably not
epsilon-phase (Migrated from github.com) reviewed 5 vuotta sitten
epsilon-phase (Migrated from github.com) kommentoi 5 vuotta sitten

Oh, it should probably just be unsafe on the lines that refer to the static mut

Oh, it should probably just be unsafe on the lines that refer to the `static mut`
elegaanz (Migrated from github.com) reviewed 5 vuotta sitten
elegaanz (Migrated from github.com) kommentoi 5 vuotta sitten

No, I don't know much about unsafe, so maybe you are right and whole function should be. But also, I feel like there is a better way to do this, like going with lazy_static for instance.

No, I don't know much about unsafe, so maybe you are right and whole function should be. But also, I feel like there is a better way to do this, like going with lazy_static for instance.
epsilon-phase (Migrated from github.com) reviewed 5 vuotta sitten
epsilon-phase (Migrated from github.com) kommentoi 5 vuotta sitten

That option looked off to us too tbh.. At least on its own
Maybe it'd be better to use a RefCell or something?

That option looked off to us too tbh.. At least on its own Maybe it'd be better to use a RefCell or something?
elegaanz (Migrated from github.com) reviewed 5 vuotta sitten
elegaanz (Migrated from github.com) kommentoi 5 vuotta sitten

Anything that will prevent having unsafe code is fine (not that it is really unsafe, we only have one thread when running in the browser).

Anything that will prevent having `unsafe` code is fine (not that it is really unsafe, we only have one thread when running in the browser).
epsilon-phase (Migrated from github.com) reviewed 5 vuotta sitten
epsilon-phase (Migrated from github.com) kommentoi 5 vuotta sitten

Didn't realize it was possible to do that with i18n!, that's nifty :)

Didn't realize it was possible to do that with `i18n!`, that's nifty :)
elegaanz (Migrated from github.com) hyväksyi nämä muutokset 5 vuotta sitten
elegaanz (Migrated from github.com) jätti kommentin

Works as expected, thank you!

Works as expected, thank you!

Reviewers

The pull request has been merged as c0469c69c1.
You can also view command line instructions.

Vaihe 1:

From your project repository, check out a new branch and test the changes.
git checkout -b confirmation-autosave master
git pull origin confirmation-autosave

Vaihe 2:

Merge the changes and update on Forgejo.
git checkout master
git merge --no-ff confirmation-autosave
git push origin master
Sign in to join this conversation.
No reviewers
Ei merkkipaalua
Ei käsittelijää
2 osallistujaa
Ilmoitukset
Määräpäivä
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

Määräpäivää ei asetettu.

Riippuvuudet

Riippuvuuksia ei asetettu.

Reference: Plume/Plume#688
Ladataan…
Sisältöä ei vielä ole.