Add 'Show dates' setting to toggle the note-list date

This commit is contained in:
Yuri Karamian
2026-06-08 01:00:25 +02:00
parent a400eeefed
commit 6115ad4ab6
6 changed files with 25 additions and 4 deletions
+2
View File
@@ -830,9 +830,11 @@ pub fn set_general_settings(
show_tray_icon: bool, show_tray_icon: bool,
close_to_tray: bool, close_to_tray: bool,
enable_wiki_links: bool, enable_wiki_links: bool,
show_note_dates: bool,
) -> Result<(), String> { ) -> Result<(), String> {
let mut config = state.config.lock().map_err(|e| e.to_string())?; let mut config = state.config.lock().map_err(|e| e.to_string())?;
config.compact_notes = compact_notes; config.compact_notes = compact_notes;
config.show_note_dates = show_note_dates;
config.time_format = time_format; config.time_format = time_format;
config.gpu_acceleration = gpu_acceleration; config.gpu_acceleration = gpu_acceleration;
config.autostart = autostart; config.autostart = autostart;
+3
View File
@@ -73,6 +73,8 @@ pub struct AppConfig {
pub ui_scale: Option<f64>, pub ui_scale: Option<f64>,
#[serde(default)] #[serde(default)]
pub compact_notes: bool, pub compact_notes: bool,
#[serde(default = "default_true")]
pub show_note_dates: bool,
#[serde(default)] #[serde(default)]
pub time_format: String, pub time_format: String,
#[serde(default)] #[serde(default)]
@@ -188,6 +190,7 @@ impl Default for AppConfig {
line_height: None, line_height: None,
ui_scale: None, ui_scale: None,
compact_notes: false, compact_notes: false,
show_note_dates: true,
time_format: "relative".to_string(), time_format: "relative".to_string(),
gpu_acceleration: true, gpu_acceleration: true,
autostart: false, autostart: false,
+2
View File
@@ -225,6 +225,7 @@ export async function setGeneralSettings(
showTrayIcon: boolean, showTrayIcon: boolean,
closeToTray: boolean, closeToTray: boolean,
enableWikiLinks: boolean, enableWikiLinks: boolean,
showNoteDates: boolean,
): Promise<void> { ): Promise<void> {
return invoke("set_general_settings", { return invoke("set_general_settings", {
compactNotes, compactNotes,
@@ -240,6 +241,7 @@ export async function setGeneralSettings(
showTrayIcon, showTrayIcon,
closeToTray, closeToTray,
enableWikiLinks, enableWikiLinks,
showNoteDates,
}); });
} }
+4 -3
View File
@@ -132,6 +132,7 @@
} }
let compact = $derived($appConfig?.compact_notes ?? false); let compact = $derived($appConfig?.compact_notes ?? false);
let showDates = $derived($appConfig?.show_note_dates !== false);
let contextMenu = $state<{ x: number; y: number; note: NoteEntry } | null>(null); let contextMenu = $state<{ x: number; y: number; note: NoteEntry } | null>(null);
let sortMenu = $state<{ x: number; y: number } | null>(null); let sortMenu = $state<{ x: number; y: number } | null>(null);
let editingNote = $state<string | null>(null); let editingNote = $state<string | null>(null);
@@ -1111,7 +1112,7 @@
{#if getNotebookPath(note)} {#if getNotebookPath(note)}
<span class="note-notebook">{getNotebookPath(note)}</span> <span class="note-notebook">{getNotebookPath(note)}</span>
{/if} {/if}
<span class="note-date-compact" title={`Created ${formatDate(note.meta.created)}\nModified ${formatDate(note.meta.modified)}`}>{formatRelativeTime($sortMode === 'created' ? note.meta.created : note.meta.modified)}</span> {#if showDates}<span class="note-date-compact" title={`Created ${formatDate(note.meta.created)}\nModified ${formatDate(note.meta.modified)}`}>{formatRelativeTime($sortMode === 'created' ? note.meta.created : note.meta.modified)}</span>{/if}
</div> </div>
{:else} {:else}
<div class="note-title" title={getNotebookPath(note) ? `${getNotebookPath(note)}/${note.meta.title}` : note.meta.title}> <div class="note-title" title={getNotebookPath(note) ? `${getNotebookPath(note)}/${note.meta.title}` : note.meta.title}>
@@ -1131,9 +1132,9 @@
<div class="note-meta"> <div class="note-meta">
{#if getNotebookPath(note)} {#if getNotebookPath(note)}
<span class="note-notebook">{getNotebookPath(note)}</span> <span class="note-notebook">{getNotebookPath(note)}</span>
<span class="note-meta-sep">&middot;</span> {#if showDates}<span class="note-meta-sep">&middot;</span>{/if}
{/if} {/if}
<span class="note-date" title={`Created ${formatDate(note.meta.created)}\nModified ${formatDate(note.meta.modified)}`}>{formatRelativeTime($sortMode === 'created' ? note.meta.created : note.meta.modified)}</span> {#if showDates}<span class="note-date" title={`Created ${formatDate(note.meta.created)}\nModified ${formatDate(note.meta.modified)}`}>{formatRelativeTime($sortMode === 'created' ? note.meta.created : note.meta.modified)}</span>{/if}
{#if note.meta.tags.length > 0} {#if note.meta.tags.length > 0}
<span class="note-tags"> <span class="note-tags">
{#each note.meta.tags.slice(0, 3) as tag} {#each note.meta.tags.slice(0, 3) as tag}
+13 -1
View File
@@ -457,6 +457,7 @@
// General settings // General settings
let compactNotes = $state($appConfig?.compact_notes ?? false); let compactNotes = $state($appConfig?.compact_notes ?? false);
let showNoteDates = $state($appConfig?.show_note_dates ?? true);
let timeFormat = $state($appConfig?.time_format ?? 'relative'); let timeFormat = $state($appConfig?.time_format ?? 'relative');
let gpuAcceleration = $state($appConfig?.gpu_acceleration ?? true); let gpuAcceleration = $state($appConfig?.gpu_acceleration ?? true);
let autostart = $state($appConfig?.autostart ?? false); let autostart = $state($appConfig?.autostart ?? false);
@@ -512,6 +513,7 @@
function saveGeneralSettings() { function saveGeneralSettings() {
if ($appConfig) { if ($appConfig) {
$appConfig.compact_notes = compactNotes; $appConfig.compact_notes = compactNotes;
$appConfig.show_note_dates = showNoteDates;
$appConfig.time_format = timeFormat; $appConfig.time_format = timeFormat;
$appConfig.gpu_acceleration = gpuAcceleration; $appConfig.gpu_acceleration = gpuAcceleration;
$appConfig.autostart = autostart; $appConfig.autostart = autostart;
@@ -525,7 +527,7 @@
$appConfig.close_to_tray = closeToTray; $appConfig.close_to_tray = closeToTray;
$appConfig.enable_wiki_links = enableWikiLinks; $appConfig.enable_wiki_links = enableWikiLinks;
} }
setGeneralSettings(compactNotes, timeFormat, gpuAcceleration, autostart, pdfPreview, pdfHeight, titleMode, hideTitleInBody, showLineNumbers, defaultViewMode, showTrayIcon, closeToTray, enableWikiLinks) setGeneralSettings(compactNotes, timeFormat, gpuAcceleration, autostart, pdfPreview, pdfHeight, titleMode, hideTitleInBody, showLineNumbers, defaultViewMode, showTrayIcon, closeToTray, enableWikiLinks, showNoteDates)
.catch((e) => console.error('Failed to save general settings:', e)); .catch((e) => console.error('Failed to save general settings:', e));
} }
@@ -646,6 +648,7 @@
// Sync general settings // Sync general settings
if ($appConfig) { if ($appConfig) {
compactNotes = $appConfig.compact_notes ?? false; compactNotes = $appConfig.compact_notes ?? false;
showNoteDates = $appConfig.show_note_dates ?? true;
timeFormat = $appConfig.time_format ?? 'relative'; timeFormat = $appConfig.time_format ?? 'relative';
gpuAcceleration = $appConfig.gpu_acceleration ?? true; gpuAcceleration = $appConfig.gpu_acceleration ?? true;
autostart = $appConfig.autostart ?? false; autostart = $appConfig.autostart ?? false;
@@ -750,6 +753,15 @@
<span class="toggle-knob"></span> <span class="toggle-knob"></span>
</button> </button>
</label> </label>
<label class="setting-toggle">
<span class="setting-label">
<span class="setting-name">Show dates</span>
<span class="setting-desc">Show the date next to each note in the list</span>
</span>
<button class="toggle-switch" class:on={showNoteDates} onclick={() => { showNoteDates = !showNoteDates; saveGeneralSettings(); }}>
<span class="toggle-knob"></span>
</button>
</label>
</div> </div>
<div class="settings-section"> <div class="settings-section">
+1
View File
@@ -56,6 +56,7 @@ export interface AppConfig {
line_height: number | null; line_height: number | null;
ui_scale: number | null; ui_scale: number | null;
compact_notes: boolean; compact_notes: boolean;
show_note_dates: boolean;
time_format: string; time_format: string;
gpu_acceleration: boolean; gpu_acceleration: boolean;
autostart: boolean; autostart: boolean;