Skip to content

Open-source and local-first Slack and Notion alternative that puts you in control of your data

Bug fixes and improvements in database views

Hakan Shehua9e028af5248
diff --git a/apps/desktop/src/main/databases/workspace/schema.ts b/apps/desktop/src/main/databases/workspace/schema.ts
index b3510d74..5ace6245 100644
--- a/apps/desktop/src/main/databases/workspace/schema.ts
+++ b/apps/desktop/src/main/databases/workspace/schema.ts
@@ -152,7 +152,7 @@ export type UpdateMutation = Updateable<MutationTable>;
interface TombstoneTable {
id: ColumnType<string, string, never>;
data: ColumnType<string, string, never>;
- created_at: ColumnType<string, string, never>;
+ deleted_at: ColumnType<string, string, never>;
}
export type SelectTombsonte = Selectable<TombstoneTable>;
diff --git a/apps/desktop/src/main/mutations/databases/view-create.ts b/apps/desktop/src/main/mutations/databases/view-create.ts
index 65bda6be..5594b161 100644
--- a/apps/desktop/src/main/mutations/databases/view-create.ts
+++ b/apps/desktop/src/main/mutations/databases/view-create.ts
@@ -49,6 +49,7 @@ export class ViewCreateMutationHandler
index: generateNodeIndex(maxIndex, null),
layout: input.viewType,
parentId: input.databaseId,
+ groupBy: input.groupBy,
};
await workspace.nodes.createNode({
diff --git a/apps/desktop/src/main/services/workspaces/node-reaction-service.ts b/apps/desktop/src/main/services/workspaces/node-reaction-service.ts
index cb84f335..497884d5 100644
--- a/apps/desktop/src/main/services/workspaces/node-reaction-service.ts
+++ b/apps/desktop/src/main/services/workspaces/node-reaction-service.ts
@@ -210,7 +210,7 @@ export class NodeReactionService {
.values({
id: tombstoneId,
data: JSON.stringify(deletedNodeReaction),
- created_at: new Date().toISOString(),
+ deleted_at: new Date().toISOString(),
})
.executeTakeFirst();
diff --git a/apps/desktop/src/main/services/workspaces/node-service.ts b/apps/desktop/src/main/services/workspaces/node-service.ts
index a77fc908..79bf6e64 100644
--- a/apps/desktop/src/main/services/workspaces/node-service.ts
+++ b/apps/desktop/src/main/services/workspaces/node-service.ts
@@ -375,7 +375,7 @@ export class NodeService {
.values({
id: deletedNode.id,
data: JSON.stringify(deletedNode),
- created_at: new Date().toISOString(),
+ deleted_at: new Date().toISOString(),
})
.execute();
diff --git a/apps/desktop/src/renderer/components/databases/boards/board-view.tsx b/apps/desktop/src/renderer/components/databases/boards/board-view.tsx
index 00ac97a3..7ce4eaea 100644
--- a/apps/desktop/src/renderer/components/databases/boards/board-view.tsx
+++ b/apps/desktop/src/renderer/components/databases/boards/board-view.tsx
@@ -17,11 +17,11 @@ export const BoardView = () => {
(field) => field.id === view.groupBy
);
- if (!groupByField || groupByField.type !== 'select') {
- return null;
- }
+ const selectOptions =
+ groupByField && groupByField.type === 'select'
+ ? Object.values(groupByField.options ?? {})
+ : [];
- const selectOptions = Object.values(groupByField.options ?? {});
return (
<React.Fragment>
<div className="flex flex-row justify-between border-b">
@@ -34,15 +34,17 @@ export const BoardView = () => {
</div>
<ViewSearchBar />
<div className="mt-2 flex w-full min-w-full max-w-full flex-row gap-2 overflow-auto pr-5">
- {selectOptions.map((option) => {
- return (
- <BoardViewColumn
- key={option.id}
- field={groupByField}
- option={option}
- />
- );
- })}
+ {groupByField &&
+ groupByField.type === 'select' &&
+ selectOptions.map((option) => {
+ return (
+ <BoardViewColumn
+ key={option.id}
+ field={groupByField}
+ option={option}
+ />
+ );
+ })}
</div>
</React.Fragment>
);
diff --git a/apps/desktop/src/renderer/components/databases/database-views.tsx b/apps/desktop/src/renderer/components/databases/database-views.tsx
index 5b647999..48b8e8fe 100644
--- a/apps/desktop/src/renderer/components/databases/database-views.tsx
+++ b/apps/desktop/src/renderer/components/databases/database-views.tsx
@@ -20,14 +20,15 @@ export const DatabaseViews = () => {
databaseId: database.id,
});
+ const views = data ?? [];
+ const activeView = views.find((view) => view.id === activeViewId);
+
React.useEffect(() => {
- if (!activeViewId) {
- setActiveViewId(data?.[0]?.id ?? null);
+ if (views.length > 0 && !views.some((view) => view.id === activeViewId)) {
+ setActiveViewId(views[0]?.id ?? null);
}
- }, [data, activeViewId]);
+ }, [views, activeViewId]);
- const views = data ?? [];
- const activeView = views.find((view) => view.id === activeViewId);
return (
<DatabaseViewsContext.Provider
value={{ views, activeViewId: activeViewId ?? '', setActiveViewId }}