diff --git a/Journal.App/scripts/tauri-prebuild.mjs b/Journal.App/scripts/tauri-prebuild.mjs index cf1378a..1c92fcc 100644 --- a/Journal.App/scripts/tauri-prebuild.mjs +++ b/Journal.App/scripts/tauri-prebuild.mjs @@ -30,11 +30,15 @@ function runtimeForCurrentPlatform() { if (arch === "arm64") return "osx-arm64"; return "osx-x64"; } - throw new Error(`Unsupported platform '${process.platform}' for sidecar publish.`); + throw new Error( + `Unsupported platform '${process.platform}' for sidecar publish.`, + ); } function sidecarFileName() { - return process.platform === "win32" ? "Journal.Sidecar.exe" : "Journal.Sidecar"; + return process.platform === "win32" + ? "Journal.Sidecar.exe" + : "Journal.Sidecar"; } const runtime = runtimeForCurrentPlatform(); @@ -42,7 +46,9 @@ const sidecarName = sidecarFileName(); const publishedSidecar = path.join(publishOutputDir, sidecarName); const bundledSidecar = path.join(tauriBinDir, sidecarName); -console.log(`Publishing sidecar for ${process.platform}/${process.arch} (${runtime})...`); +console.log( + `Publishing sidecar for ${process.platform}/${process.arch} (${runtime})...`, +); const publishArgs = [ "publish", diff --git a/Journal.App/src-tauri/tauri.conf.json b/Journal.App/src-tauri/tauri.conf.json index 4b23224..6506fa3 100644 --- a/Journal.App/src-tauri/tauri.conf.json +++ b/Journal.App/src-tauri/tauri.conf.json @@ -24,9 +24,7 @@ "bundle": { "active": true, "targets": "all", - "resources": [ - "bin" - ], + "resources": ["bin"], "icon": [ "icons/32x32.png", "icons/128x128.png", diff --git a/Journal.App/src/lib/components/SidePanel.svelte b/Journal.App/src/lib/components/SidePanel.svelte index 650048b..3b9d0c4 100644 --- a/Journal.App/src/lib/components/SidePanel.svelte +++ b/Journal.App/src/lib/components/SidePanel.svelte @@ -30,6 +30,7 @@ todoListsStore, todosStore, } from "$lib/stores/todos"; + import { vaultUnlocked } from "$lib/stores/session"; import { extractEntryTags } from "$lib/utils/metadata"; export let activeSection = "entries"; @@ -338,6 +339,10 @@ calendarError = ""; try { if (requestId !== calendarRefreshRequestId) return; + if (!$vaultUnlocked) { + calendarTimelineItems = []; + return; + } const { startDate, endDate } = getActiveDateRange(); const entryItems = await searchEntriesAsItems({ @@ -616,6 +621,12 @@ async function refreshTemplates() { if (activeSection !== "entries") return; + if (!$vaultUnlocked) { + templatesBusy = false; + templateError = ""; + templateItems = []; + return; + } templatesBusy = true; templateError = ""; try { diff --git a/Journal.App/src/routes/+page.svelte b/Journal.App/src/routes/+page.svelte index 79dcba4..ee1470a 100644 --- a/Journal.App/src/routes/+page.svelte +++ b/Journal.App/src/routes/+page.svelte @@ -176,7 +176,9 @@ function pruneDocumentCache(preserveIds: string[] = []) { const preserve = new Set( - preserveIds.filter(Boolean).concat(activeDocumentId ? [activeDocumentId] : []), + preserveIds + .filter(Boolean) + .concat(activeDocumentId ? [activeDocumentId] : []), ); const cachedIds = Object.keys(openDocuments); if (cachedIds.length <= MAX_CACHED_DOCUMENTS) return; diff --git a/Journal.Core/Repositories/InMemoryFragmentRepository.cs b/Journal.Core/Repositories/InMemoryFragmentRepository.cs index 22bf26a..d8c20af 100644 --- a/Journal.Core/Repositories/InMemoryFragmentRepository.cs +++ b/Journal.Core/Repositories/InMemoryFragmentRepository.cs @@ -25,7 +25,7 @@ public class InMemoryFragmentRepository : IFragmentRepository public void Add(Fragment fragment) { - if (fragment is null) throw new ArgumentNullException(nameof(fragment)); + ArgumentNullException.ThrowIfNull(fragment); lock (_lock) { if (fragment.Tags != null) diff --git a/Journal.Core/Repositories/SqliteFragmentRepository.cs b/Journal.Core/Repositories/SqliteFragmentRepository.cs index 52e7d3a..c58d402 100644 --- a/Journal.Core/Repositories/SqliteFragmentRepository.cs +++ b/Journal.Core/Repositories/SqliteFragmentRepository.cs @@ -266,19 +266,16 @@ public sealed class SqliteFragmentRepository(IDatabaseSessionService session) : foreach (var tag in tags) { - // Upsert into tags table using var upsert = conn.CreateCommand(); upsert.CommandText = "INSERT OR IGNORE INTO tags (name) VALUES (@name);"; upsert.Parameters.AddWithValue("@name", tag); upsert.ExecuteNonQuery(); - // Get tag id using var getTagId = conn.CreateCommand(); getTagId.CommandText = "SELECT id FROM tags WHERE name = @name;"; getTagId.Parameters.AddWithValue("@name", tag); var tagId = (long)getTagId.ExecuteScalar()!; - // Link fragment to tag using var link = conn.CreateCommand(); link.CommandText = "INSERT OR IGNORE INTO fragment_tags (fragment_id, tag_id) VALUES (@fid, @tid);"; link.Parameters.AddWithValue("@fid", fragmentRowId); @@ -289,7 +286,6 @@ public sealed class SqliteFragmentRepository(IDatabaseSessionService session) : private static Fragment MapRow(SqliteDataReader reader) { - // columns: id (int), guid (text), type (text), description (text), time (text) var guid = Guid.Parse(reader.GetString(1)); var type = reader.GetString(2); var description = reader.IsDBNull(3) ? "" : reader.GetString(3); diff --git a/Journal.Core/Services/Database/DatabaseSessionService.cs b/Journal.Core/Services/Database/DatabaseSessionService.cs index c8b7163..80ddee6 100644 --- a/Journal.Core/Services/Database/DatabaseSessionService.cs +++ b/Journal.Core/Services/Database/DatabaseSessionService.cs @@ -75,8 +75,5 @@ public sealed class DatabaseSessionService(IJournalDatabaseService database) : I } } - public void Dispose() - { - CloseConnection(); - } + public void Dispose() => CloseConnection(); } diff --git a/Journal.Core/Services/Database/JournalDatabaseService.cs b/Journal.Core/Services/Database/JournalDatabaseService.cs index a042753..d762eab 100644 --- a/Journal.Core/Services/Database/JournalDatabaseService.cs +++ b/Journal.Core/Services/Database/JournalDatabaseService.cs @@ -136,15 +136,15 @@ public sealed class JournalDatabaseService(IJournalConfigService config) : IJour public JournalDatabaseStatus GetStatus(string password) { var tables = GetSchemaStatements().Keys.OrderBy(x => x, StringComparer.Ordinal).ToArray(); - var runtime = ProbeRuntime(password); + var (Ready, Message) = ProbeRuntime(password); return new JournalDatabaseStatus( DatabasePath: GetDatabasePath(), KeyLengthBytes: DeriveDatabaseKey(password).Length, Iterations: Iterations, KeyDerivation: "PBKDF2-HMAC-SHA256", SchemaTables: tables, - RuntimeReady: runtime.Ready, - RuntimeMessage: runtime.Message); + RuntimeReady: Ready, + RuntimeMessage: Message); } public JournalDatabaseHydrationResult HydrateWorkspace(string password) diff --git a/Journal.Core/Services/Entries/HtmlSanitizer.cs b/Journal.Core/Services/Entries/HtmlSanitizer.cs index 7b31c48..0057e83 100644 --- a/Journal.Core/Services/Entries/HtmlSanitizer.cs +++ b/Journal.Core/Services/Entries/HtmlSanitizer.cs @@ -76,6 +76,6 @@ public static partial class HtmlSanitizer ]; if (markers.Any(marker => lowered.Contains(marker, StringComparison.Ordinal))) return true; - return HtmlTagCountRegex().Matches(lowered).Count >= 8; + return HtmlTagCountRegex().Count(lowered) >= 8; } } diff --git a/Journal.Core/Services/Speech/DisabledSpeechBridgeService.cs b/Journal.Core/Services/Speech/DisabledSpeechBridgeService.cs index 027ddc1..4f1959b 100644 --- a/Journal.Core/Services/Speech/DisabledSpeechBridgeService.cs +++ b/Journal.Core/Services/Speech/DisabledSpeechBridgeService.cs @@ -17,8 +17,7 @@ public sealed class DisabledSpeechBridgeService(string provider = "none", string SpeechTranscribeRequestDto request, CancellationToken cancellationToken = default) { - if (request is null) - throw new ArgumentNullException(nameof(request)); + ArgumentNullException.ThrowIfNull(request); var engine = string.IsNullOrWhiteSpace(request.Engine) ? "none" : request.Engine.Trim(); var warning = $"{_message} (provider={_provider})"; return Task.FromResult(new SpeechTranscribeResultDto("", engine, warning));