localStorage is apparently not working anymore on AnkiDesktop

Apparently AnkiDesktops localStorage is not working anymore?
I updated to the newest version and certain options from my templates are not being saved anymore.

If anyone wants to recreate this problem:

<script>
var STORAGE_KEY = "example-storage-location";

var existing_storage = localStorage.getItem(STORAGE_KEY);
if (existing_storage === null) 
{
    existing_storage = 0;
} else 
{
    existing_storage = parseInt(existing_storage);
}

console.log("This template has been accessed " + existing_storage + " times.");

existing_storage = existing_storage + 1;

localStorage.setItem(STORAGE_KEY, existing_storage);
console.log(STORAGE_KEY + " set to " + existing_storage);
</script>

This is a modification of the code from a testcase for the same bug on AnkiDroid: [BUG]: localStorage does not seem to be persistent in version 2.17.5 · Issue #15911 · ankidroid/Anki-Android · GitHub.

This here is happening on AnkiDesktop too! After restarting Anki completely, the localStorage is wiped.

Is anyone able to recreate this problem? I don’t want to open a bug entry on gitHub, when there is still a chance that I am the only one affected by it.

I am using the newest Version of Anki (24.06.2-windows-qt6)

localStorage has never been persistent between runs in Anki Desktop as far as I know. Using a persistent QWebEngineProfile will probably solve this.

1 Like

Oh. Yeah well. Then maybe I got confused along with AnkiDroid. This feature on AnkiDroid is really great for settings created with JavaScript for the template itself.

For anyone that wants localStorage to be integrated into AnkiDesktop.
Here is an older thread: Can Anki provide cross platform local persistent storage functionality? - #4 by dae.
You can voice your ideas or approval for localStorage on AnkiDesktop there.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.