fix: sablony cenoviek len z databazy, stara kopia v prehliadaci sa zmaze
Neulozene alebo zmazane sablony z localStorage sa uz neukazuju v roletkach. Ked sa sablonu nepodari ulozit do databazy, editor to ohlasi (predtym ju potichu ulozil len do prehliadaca). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b747a3ba74
commit
d17c9277ff
2 files changed
+17
-37
No files matched your search
+3
-17
@@ -10,7 +10,7 @@ import { getBrevoCampaignUrl } from '@/lib/brevo';
|
||||
import { TopBar } from '@/components/editor/TopBar';
|
||||
import { ConfigPanel } from '@/components/editor/ConfigPanel';
|
||||
import { ProductImportModal } from '@/components/editor/ProductImportModal';
|
||||
import { BadgeEditorModal } from '@/components/editor/BadgeEditorModal';
|
||||
import { BadgeEditorModal, clearLocalBadges } from '@/components/editor/BadgeEditorModal';
|
||||
import { SavedCampaignsModal } from '@/components/editor/SavedCampaignsModal';
|
||||
import { NameDialog } from '@/components/editor/NameDialog';
|
||||
import JSZip from 'jszip';
|
||||
@@ -64,22 +64,8 @@ export default function Home() {
|
||||
console.warn('Error fetching badges in page:', e);
|
||||
}
|
||||
|
||||
try {
|
||||
const local = localStorage.getItem('coop_custom_badges');
|
||||
if (local) {
|
||||
const parsed = JSON.parse(local);
|
||||
if (Array.isArray(parsed)) {
|
||||
const existingIds = new Set(loaded.map((b) => b.id));
|
||||
for (const b of parsed) {
|
||||
// len šablóny neuložené do databázy – zmazané šablóny sa z prehliadača nesmú vrátiť
|
||||
if (!existingIds.has(b.id) && String(b.id).startsWith('badge-')) {
|
||||
loaded.push(b);
|
||||
existingIds.add(b.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
// šablóny sú len v databáze; starú kópiu z prehliadača zmažeme
|
||||
clearLocalBadges();
|
||||
|
||||
const all = [...loaded];
|
||||
const existingIds = new Set(all.map((b) => b.id));
|
||||
|
||||
Reference in new issue
Block a user