refactor: initialize snippets storage with sample data and improve import handling

This commit is contained in:
2025-10-19 20:18:55 +03:00
parent 011fac5a47
commit e99b5e2dc2
3 changed files with 464 additions and 141 deletions

View File

@@ -8,27 +8,27 @@ document.addEventListener('DOMContentLoaded', function () {
const theme = getSetting('ui.theme') || 'light';
document.documentElement.setAttribute('data-theme', theme);
// Initialize snippet storage and render list
initializeSnippetsStorage();
// Initialize snippet storage and render list (async)
initializeSnippetsStorage().then(() => {
// Initialize sort controls
initializeSortControls();
// Initialize sort controls
initializeSortControls();
// Initialize search controls
initializeSearchControls();
// Initialize search controls
initializeSearchControls();
renderSnippetList();
renderSnippetList();
// Update storage monitor
updateStorageMonitor();
// Update storage monitor
updateStorageMonitor();
// Auto-select first snippet on page load (only if no hash in URL)
if (!window.location.hash) {
const firstSnippet = SnippetStorage.listSnippets()[0];
if (firstSnippet) {
selectSnippet(firstSnippet.id);
// Auto-select first snippet on page load (only if no hash in URL)
if (!window.location.hash) {
const firstSnippet = SnippetStorage.listSnippets()[0];
if (firstSnippet) {
selectSnippet(firstSnippet.id);
}
}
}
});
// Load saved layout
loadLayoutFromStorage();