timestamp when enabling persitence

Hello,


I have a richtext bound to a value in the database.

But I want to use the persistence, in case the user doesn't save his draft or in case his browser crashed,

So far so good.

Now I'd like to compare the date of the content stored locally vs the date this bound field has been last saved in the database. And depending on this I will show the value in the database or the persistent value saved locally.

Is this something we can achieve? and if yes, how do I get the date of the persistent data?

Any piece of advise would be very welcomed :)

Kind Regards,

Yvan Blancmunier


2 Replies

YB Yvan Blancmunier May 19, 2023 08:12 AM UTC

Can anybody put some light on my problem?




VJ Vinitha Jeyakumar Syncfusion Team May 19, 2023 09:27 AM UTC

Hi Yvan,

By default, the data persistent in RichTextEditor works based on the local storage mechanism. here, we have passed the key-value pair of date and time while saving the data into the local storage using the unload event to achieve your requirement. Please check the code and sample below,

Code snippet:
ngOnInit() {
    setTimeout(() => {
      window.addEventListener('unload'function () {
        localStorage.setItem('Date'new Date().toString());
      });
    });
  }





In the above image, you can see that both the persisted data and date time are stored in the local storage and you can store that date value into your database.

Regards,
Vinitha

Loader.
Up arrow icon