Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

Commit

Permalink
use count instead of find
Browse files Browse the repository at this point in the history
  • Loading branch information
archywillhe committed Oct 8, 2023
1 parent 90e50de commit 5fa940b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/insomnia/src/plugins/context/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export const getWorkspaces = (activeProjectId?: string) => {
if (activeProjectId) {
return models.workspace.findByParentId(activeProjectId);
} else {
// ARCHY NOTE: HMMM need to investigate this

// This code path was kept in case there was ever a time when the app wouldn't have an active project.
// In over 5 months of monitoring in production, we never saw this happen.
// Keeping it for defensive purposes, but it's not clear if it's necessary.
Expand Down
6 changes: 3 additions & 3 deletions packages/insomnia/src/ui/renderApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import { Workspace } from '../models/workspace';

export async function renderApp() {

const workspaces = await database.find<Workspace>(models.workspace.type)
console.log("workspaces.length detected _", workspaces.length);
if (workspaces.length === 0) await importPure(dummyStartingWorkspace())
const workspaceNumber = await database.count<Workspace>(models.workspace.type)
console.log("workspaces detected ~>", workspaceNumber);
if (workspaceNumber === 0) await importPure(dummyStartingWorkspace())


const router = setupRouterStuff();
Expand Down

0 comments on commit 5fa940b

Please sign in to comment.