From d511117e1cdaeed38639b68cc4b91c1ae3f710d1 Mon Sep 17 00:00:00 2001 From: Daniel Metcalfe Date: Wed, 6 Nov 2024 21:39:16 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=91=EF=B8=8F=20Remove=20references=20t?= =?UTF-8?q?o=20important=20list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/db.ts | 14 ++++++++------ components/pages/Home.tsx | 24 ------------------------ 2 files changed, 8 insertions(+), 30 deletions(-) diff --git a/components/db.ts b/components/db.ts index d92632f..d6ac4a0 100644 --- a/components/db.ts +++ b/components/db.ts @@ -26,11 +26,6 @@ export interface Icon { name: string } -export interface List { - order: string[] // Todo IDs - type: '#important' -} - export enum ListType { wayfinder, icebox, @@ -43,7 +38,6 @@ export interface Setting { export class DexieStarfocus extends Dexie { wayfinderOrder!: DexieCloudTable<{ todoId: string; order: string }, 'todoId'> - lists!: Table settings!: DexieCloudTable starRoles: DexieCloudTable starRolesOrder!: DexieCloudTable< @@ -80,6 +74,14 @@ export class DexieStarfocus extends Dexie { starRolesOrder: '&starRoleId, &order', todos: '@id, createdAt, completedAt, starRole, title', }) + this.version(5).stores({ + lists: null, + wayfinderOrder: '&todoId, &order', + settings: '&key', + starRoles: '@id, title', + starRolesOrder: '&starRoleId, &order', + todos: '@id, createdAt, completedAt, starRole, title', + }) this.cloud.configure({ databaseUrl: process.env.NEXT_PUBLIC_DATABASE_URL!, requireAuth: false, diff --git a/components/pages/Home.tsx b/components/pages/Home.tsx index 63d6bf0..f88b7b0 100644 --- a/components/pages/Home.tsx +++ b/components/pages/Home.tsx @@ -336,30 +336,6 @@ export const MiscMenu = () => { // Remove empty todos await db.todos.where('title').equals('').delete() - - // Remove todos from important list that don't exist - const important = await db.lists.get('#important') - const todos = await db.todos.bulkGet(important?.order || []) - const cleanedImportantOrder = _.zip(important!.order, todos) - .filter(([_id, todo]) => todo !== undefined) - .map(([id, _todo]) => id) as string[] - await db.lists.update('#important', { - order: cleanedImportantOrder, - }) - - // Migrate to new important order - const wayfinderOrder = await db.wayfinderOrder - .orderBy('order') - .keys() - if (wayfinderOrder.length === 0) { - const oldOrder = await db.lists.get('#important') - const orderKeys = starMudder(oldOrder?.order.length) - const records = oldOrder?.order.map(todoId => ({ - todoId, - order: orderKeys.shift(), - })) - db.wayfinderOrder.bulkAdd(records as any) - } }} > Clean database