Skip to content

Commit

Permalink
Merge pull request #62 from pvdthings/fix-bookmarks-bug
Browse files Browse the repository at this point in the history
Web - Fix bookmarks bug
  • Loading branch information
dillonfagan authored Sep 9, 2024
2 parents 9c7eaee + cd6c419 commit fd8ca7d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@library_os/web",
"version": "0.15.6",
"version": "0.15.7",
"private": true,
"scripts": {
"dev": "vite dev",
Expand Down
9 changes: 8 additions & 1 deletion apps/web/src/lib/stores/bookmarks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@ import { derived, writable } from "svelte/store";
const defaultValue = [];

function createBookmarks() {
const initialValue = browser ? JSON.parse(window.localStorage.getItem('myList'))
let initialValue = browser ? JSON.parse(window.localStorage.getItem('myList'))
?? defaultValue : defaultValue;

// convert from old format to new
if (initialValue.length && (typeof initialValue[0]) !== 'string') {
console.log('Converting old bookmarks...');
initialValue = initialValue.map(b => b.id);
window.localStorage.setItem('myList', JSON.stringify(initialValue));
}

const things = writable<ThingID[]>(initialValue);

things.subscribe((value) => {
Expand Down

0 comments on commit fd8ca7d

Please sign in to comment.