Align Journal.App with SQLCipher backend contract (remove dataDirectory coupling)
This commit is contained in:
parent
aafb08e63f
commit
b60f42f6fe
@ -8,14 +8,11 @@ export function hydrateWorkspace(password: string): Promise<unknown> {
|
||||
}
|
||||
|
||||
type RuntimeConfigRaw = {
|
||||
dataDirectory?: string;
|
||||
vaultDirectory?: string;
|
||||
DataDirectory?: string;
|
||||
VaultDirectory?: string;
|
||||
};
|
||||
|
||||
type RuntimeConfig = {
|
||||
dataDirectory: string;
|
||||
vaultDirectory: string;
|
||||
};
|
||||
|
||||
@ -34,7 +31,6 @@ async function getRuntimeConfig(
|
||||
);
|
||||
|
||||
return {
|
||||
dataDirectory: pickCase(data, "dataDirectory", "DataDirectory", ""),
|
||||
vaultDirectory: pickCase(data, "vaultDirectory", "VaultDirectory", ""),
|
||||
};
|
||||
}
|
||||
@ -46,7 +42,6 @@ export async function unlockVaultWorkspace(password: string): Promise<void> {
|
||||
payload: {
|
||||
password,
|
||||
vaultDirectory: config.vaultDirectory,
|
||||
dataDirectory: config.dataDirectory,
|
||||
},
|
||||
});
|
||||
|
||||
@ -58,7 +53,6 @@ export async function unlockVaultWorkspace(password: string): Promise<void> {
|
||||
action: "db.hydrate_workspace",
|
||||
payload: {
|
||||
password,
|
||||
dataDirectory: config.dataDirectory,
|
||||
},
|
||||
});
|
||||
}
|
||||
@ -75,7 +69,6 @@ export async function persistAndClearVault(
|
||||
payload: {
|
||||
password,
|
||||
vaultDirectory: config.vaultDirectory,
|
||||
dataDirectory: config.dataDirectory,
|
||||
},
|
||||
},
|
||||
options,
|
||||
@ -84,9 +77,7 @@ export async function persistAndClearVault(
|
||||
await sendCommand<boolean>(
|
||||
{
|
||||
action: "vault.clear_data_directory",
|
||||
payload: {
|
||||
dataDirectory: config.dataDirectory,
|
||||
},
|
||||
payload: {},
|
||||
},
|
||||
options,
|
||||
);
|
||||
|
||||
@ -35,7 +35,6 @@ export type EntrySaveResultDto = {
|
||||
};
|
||||
|
||||
export type EntrySearchRequestDto = {
|
||||
dataDirectory: string;
|
||||
query?: string;
|
||||
section?: string;
|
||||
startDate?: string;
|
||||
@ -214,12 +213,10 @@ function normalizeEntrySearchResult(
|
||||
};
|
||||
}
|
||||
|
||||
export async function listEntries(
|
||||
dataDirectory?: string,
|
||||
): Promise<EntryListItemDto[]> {
|
||||
export async function listEntries(): Promise<EntryListItemDto[]> {
|
||||
const data = await sendCommand<EntryListItemDtoRaw[]>({
|
||||
action: "entries.list",
|
||||
payload: { dataDirectory },
|
||||
payload: {},
|
||||
});
|
||||
|
||||
return data
|
||||
|
||||
@ -46,12 +46,10 @@ function normalizeTemplateItem(
|
||||
};
|
||||
}
|
||||
|
||||
export async function listEntryTemplates(
|
||||
dataDirectory?: string,
|
||||
): Promise<EntryTemplateItemDto[]> {
|
||||
export async function listEntryTemplates(): Promise<EntryTemplateItemDto[]> {
|
||||
const data = await sendCommand<EntryTemplateItemDtoRaw[]>({
|
||||
action: "templates.list",
|
||||
payload: { dataDirectory },
|
||||
payload: {},
|
||||
});
|
||||
|
||||
return data
|
||||
@ -78,7 +76,6 @@ export async function saveEntryTemplate(payload: {
|
||||
name: string;
|
||||
content: string;
|
||||
filePath?: string;
|
||||
dataDirectory?: string;
|
||||
}): Promise<EntryTemplateSaveResultDto> {
|
||||
const data = await sendCommand<EntryTemplateSaveResultDtoRaw>({
|
||||
action: "templates.save",
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
import { listFragments, type FragmentDto } from "$lib/backend/fragments";
|
||||
import { listLists, type ListDocumentDto } from "$lib/backend/lists";
|
||||
import { listTodoLists, type TodoListDto } from "$lib/backend/todos";
|
||||
import { sendCommand } from "$lib/backend/client";
|
||||
import CalendarWidget from "$lib/components/CalendarWidget.svelte";
|
||||
import {
|
||||
entriesBusyStore,
|
||||
@ -231,16 +230,6 @@
|
||||
return { startDate: toIsoDate(monthStart), endDate: toIsoDate(monthEnd) };
|
||||
}
|
||||
|
||||
async function getDataDirectory(): Promise<string> {
|
||||
const config = await sendCommand<{
|
||||
dataDirectory?: string;
|
||||
DataDirectory?: string;
|
||||
}>({
|
||||
action: "config.get",
|
||||
});
|
||||
return (config.dataDirectory ?? config.DataDirectory ?? "").trim();
|
||||
}
|
||||
|
||||
function toFragmentTimelineItem(fragment: FragmentDto): SidePanelItem {
|
||||
const split = fragment.description.split(/\n{2,}/);
|
||||
const title = (split[0] ?? "").trim() || "Untitled Fragment";
|
||||
@ -348,16 +337,10 @@
|
||||
calendarBusy = true;
|
||||
calendarError = "";
|
||||
try {
|
||||
const dataDirectory = await getDataDirectory();
|
||||
if (requestId !== calendarRefreshRequestId) return;
|
||||
if (!dataDirectory) {
|
||||
calendarTimelineItems = [];
|
||||
return;
|
||||
}
|
||||
|
||||
const { startDate, endDate } = getActiveDateRange();
|
||||
const entryItems = await searchEntriesAsItems({
|
||||
dataDirectory,
|
||||
query: calendarQuery.trim() || undefined,
|
||||
});
|
||||
if (requestId !== calendarRefreshRequestId) return;
|
||||
|
||||
@ -88,10 +88,10 @@ export function createEntryDraft(): EntryItem {
|
||||
};
|
||||
}
|
||||
|
||||
export async function hydrateEntries(dataDirectory?: string): Promise<void> {
|
||||
export async function hydrateEntries(): Promise<void> {
|
||||
entriesBusyStore.set(true);
|
||||
try {
|
||||
const items = await listEntriesCommand(dataDirectory);
|
||||
const items = await listEntriesCommand();
|
||||
const mapped = items.map(fromListDto);
|
||||
entriesStore.set(mapped);
|
||||
} catch (error) {
|
||||
@ -162,18 +162,13 @@ export async function searchEntriesAsItems(
|
||||
payload: EntrySearchRequestDto,
|
||||
): Promise<EntryItem[]> {
|
||||
const results = await searchEntriesCommand(payload);
|
||||
const dataDirectory = payload.dataDirectory?.trim() ?? "";
|
||||
const separator = dataDirectory.includes("\\") ? "\\" : "/";
|
||||
const basePath = dataDirectory.replace(/[\\/]+$/, "");
|
||||
const toSearchPath = (fileName: string): string =>
|
||||
`db://entry/${encodeURIComponent(fileName)}`;
|
||||
const mapped = results.map((result) => ({
|
||||
id: basePath
|
||||
? toStoreId(`${basePath}${separator}${result.fileName}`)
|
||||
: `entries/search/${encodeURIComponent(result.fileName)}`,
|
||||
id: toStoreId(toSearchPath(result.fileName)),
|
||||
label: toLabel(result.fileName),
|
||||
initialContent: result.entry.rawContent,
|
||||
filePath: basePath
|
||||
? `${basePath}${separator}${result.fileName}`
|
||||
: undefined,
|
||||
filePath: toSearchPath(result.fileName),
|
||||
date: result.entry.date,
|
||||
}));
|
||||
return mapped;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user