-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ complete change in the way projects are stored, to provide unlimite…
…d storage capacity
- Loading branch information
Showing
7 changed files
with
114 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import type { ProjectDesc } from '$lib/models/Project'; | ||
|
||
/** | ||
* From v2.0.0 to v2.1.0, the project system was changed. | ||
*/ | ||
export function newProjectSystemMigration() { | ||
const projects: any[] = JSON.parse(localStorage.getItem('projects') || '[]'); | ||
if (projects.length > 0) { | ||
if (projects[0].timeline !== undefined) { | ||
// backup and download the old projects | ||
const data = JSON.stringify(projects, null, 2); | ||
const blob = new Blob([data], { type: 'application/json' }); | ||
const url = URL.createObjectURL(blob); | ||
const a = document.createElement('a'); | ||
a.href = url; | ||
a.download = 'BACKUP FILE IN CASE EVERYTHING BROKE.qcb'; | ||
a.click(); | ||
|
||
// Make each project occupy one different localstorage item | ||
let projectsDesc: ProjectDesc[] = []; | ||
for (let i = 0; i < projects.length; i++) { | ||
const element = projects[i]; | ||
|
||
localStorage.setItem(element.id, JSON.stringify(element)); | ||
projectsDesc.push({ | ||
name: element.name, | ||
updatedAt: element.updatedAt, | ||
id: element.id | ||
}); | ||
} | ||
|
||
localStorage.setItem('projects', JSON.stringify(projectsDesc)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters