2026-11-25 13:44:02 +01:00
|
|
|
|
#nullable enable
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Text.Json;
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
using System.Threading;
|
2026-11-25 13:44:02 +01:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using ReminderOrganizer.Models;
|
|
|
|
|
|
|
|
|
|
|
|
namespace ReminderOrganizer.Services
|
|
|
|
|
|
{
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Stores tasks in %APPDATA%\ReminderOrganizer\tasks.json.
|
|
|
|
|
|
/// Writes are serialized and atomic (temp file + replace), a corrupt file is
|
|
|
|
|
|
/// backed up instead of being overwritten.
|
|
|
|
|
|
/// </summary>
|
2026-11-25 13:44:02 +01:00
|
|
|
|
public class DataService : IDataService
|
|
|
|
|
|
{
|
|
|
|
|
|
private static readonly JsonSerializerOptions _jsonOptions = new()
|
|
|
|
|
|
{
|
|
|
|
|
|
WriteIndented = true,
|
|
|
|
|
|
PropertyNameCaseInsensitive = true
|
|
|
|
|
|
};
|
|
|
|
|
|
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
private readonly SemaphoreSlim _writeLock = new(1, 1);
|
|
|
|
|
|
|
Snooze notifications, morning summary, ICS import, data folder sync
- Windows toast notifications with snooze (10 min / 1 h / tomorrow) and
done buttons; balloon fallback; works when Windows starts the app
- Recurring entries snooze via SnoozedUntil without moving their date;
lead reminders keep the real date
- Morning summary once a day from a chosen hour (pure DailySummary)
- iCalendar import incl. Google birthday calendar, folded lines, UTC,
alarms, own export round trip, duplicates skipped by UID, undo
- Data folder selectable (location.json pointer), file watcher reloads
changes from another PC (own writes ignored)
- Themed date picker calendar, WPF tray menu, arrow/Home/End/Space keys
- 90 tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 20:37:20 +01:00
|
|
|
|
public string DataFilePath { get; private set; }
|
|
|
|
|
|
public string DataDirectory => Path.GetDirectoryName(DataFilePath)!;
|
2026-11-25 13:44:02 +01:00
|
|
|
|
|
Snooze notifications, morning summary, ICS import, data folder sync
- Windows toast notifications with snooze (10 min / 1 h / tomorrow) and
done buttons; balloon fallback; works when Windows starts the app
- Recurring entries snooze via SnoozedUntil without moving their date;
lead reminders keep the real date
- Morning summary once a day from a chosen hour (pure DailySummary)
- iCalendar import incl. Google birthday calendar, folded lines, UTC,
alarms, own export round trip, duplicates skipped by UID, undo
- Data folder selectable (location.json pointer), file watcher reloads
changes from another PC (own writes ignored)
- Themed date picker calendar, WPF tray menu, arrow/Home/End/Space keys
- 90 tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 20:37:20 +01:00
|
|
|
|
/// <summary>Time stamp of our own last write – a different one means another PC (sync) changed the file.</summary>
|
|
|
|
|
|
public DateTime LastWriteUtc { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// App folder (pointer file, error log): %APPDATA%\ReminderOrganizer – or REMINDER_ORGANIZER_DATA (tests/screenshots).
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static string AppDirectory =>
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
Environment.GetEnvironmentVariable("REMINDER_ORGANIZER_DATA") is { Length: > 0 } custom
|
|
|
|
|
|
? custom
|
|
|
|
|
|
: Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ReminderOrganizer");
|
|
|
|
|
|
|
Snooze notifications, morning summary, ICS import, data folder sync
- Windows toast notifications with snooze (10 min / 1 h / tomorrow) and
done buttons; balloon fallback; works when Windows starts the app
- Recurring entries snooze via SnoozedUntil without moving their date;
lead reminders keep the real date
- Morning summary once a day from a chosen hour (pure DailySummary)
- iCalendar import incl. Google birthday calendar, folded lines, UTC,
alarms, own export round trip, duplicates skipped by UID, undo
- Data folder selectable (location.json pointer), file watcher reloads
changes from another PC (own writes ignored)
- Themed date picker calendar, WPF tray menu, arrow/Home/End/Space keys
- 90 tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 20:37:20 +01:00
|
|
|
|
/// <summary>Where tasks.json lives: the folder chosen in Settings (e.g. OneDrive), otherwise the app folder.</summary>
|
|
|
|
|
|
public static string DefaultDataDirectory => ReadPointer(AppDirectory) ?? AppDirectory;
|
|
|
|
|
|
|
|
|
|
|
|
private const string PointerFile = "location.json";
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Chosen data folder from location.json, or null (none / folder gone).</summary>
|
|
|
|
|
|
public static string? ReadPointer(string appDirectory)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
var file = Path.Combine(appDirectory, PointerFile);
|
|
|
|
|
|
if (!File.Exists(file)) return null;
|
|
|
|
|
|
using var doc = JsonDocument.Parse(File.ReadAllText(file));
|
|
|
|
|
|
var folder = doc.RootElement.TryGetProperty("DataFolder", out var p) ? p.GetString() : null;
|
|
|
|
|
|
return !string.IsNullOrWhiteSpace(folder) && Directory.Exists(folder) ? folder : null;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Stores the data folder; null or the app folder itself removes the pointer.</summary>
|
|
|
|
|
|
public static void WritePointer(string appDirectory, string? folder)
|
|
|
|
|
|
{
|
|
|
|
|
|
Directory.CreateDirectory(appDirectory);
|
|
|
|
|
|
var file = Path.Combine(appDirectory, PointerFile);
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(folder) ||
|
|
|
|
|
|
string.Equals(Path.GetFullPath(folder).TrimEnd('\\'), Path.GetFullPath(appDirectory).TrimEnd('\\'), StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (File.Exists(file)) File.Delete(file);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
File.WriteAllText(file, JsonSerializer.Serialize(new { DataFolder = folder }, _jsonOptions));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
public DataService() : this(DefaultDataDirectory) { }
|
|
|
|
|
|
|
|
|
|
|
|
public DataService(string dataDirectory)
|
|
|
|
|
|
{
|
|
|
|
|
|
Directory.CreateDirectory(dataDirectory);
|
|
|
|
|
|
DataFilePath = Path.Combine(dataDirectory, "tasks.json");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
Snooze notifications, morning summary, ICS import, data folder sync
- Windows toast notifications with snooze (10 min / 1 h / tomorrow) and
done buttons; balloon fallback; works when Windows starts the app
- Recurring entries snooze via SnoozedUntil without moving their date;
lead reminders keep the real date
- Morning summary once a day from a chosen hour (pure DailySummary)
- iCalendar import incl. Google birthday calendar, folded lines, UTC,
alarms, own export round trip, duplicates skipped by UID, undo
- Data folder selectable (location.json pointer), file watcher reloads
changes from another PC (own writes ignored)
- Themed date picker calendar, WPF tray menu, arrow/Home/End/Space keys
- 90 tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 20:37:20 +01:00
|
|
|
|
/// <summary>Use another folder from now on (after moving or adopting its tasks.json).</summary>
|
|
|
|
|
|
public void SwitchTo(string dataDirectory)
|
|
|
|
|
|
{
|
|
|
|
|
|
StopWatching();
|
|
|
|
|
|
Directory.CreateDirectory(dataDirectory);
|
|
|
|
|
|
DataFilePath = Path.Combine(dataDirectory, "tasks.json");
|
|
|
|
|
|
LastWriteUtc = File.Exists(DataFilePath) ? File.GetLastWriteTimeUtc(DataFilePath) : default;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ---------- sync: notice changes made by another PC ----------
|
|
|
|
|
|
|
|
|
|
|
|
private FileSystemWatcher? _watcher;
|
|
|
|
|
|
private Timer? _debounce;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Calls <paramref name="onExternalChange"/> (thread pool) when tasks.json changes and it wasn't us.</summary>
|
|
|
|
|
|
public void StartWatching(Action onExternalChange)
|
|
|
|
|
|
{
|
|
|
|
|
|
StopWatching();
|
|
|
|
|
|
if (File.Exists(DataFilePath)) LastWriteUtc = File.GetLastWriteTimeUtc(DataFilePath);
|
|
|
|
|
|
_debounce = new Timer(_ =>
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
if (IsExternalChange()) onExternalChange();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { /* file busy – next event */ }
|
|
|
|
|
|
});
|
|
|
|
|
|
_watcher = new FileSystemWatcher(DataDirectory, "tasks.json")
|
|
|
|
|
|
{
|
|
|
|
|
|
NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.Size,
|
|
|
|
|
|
EnableRaisingEvents = true
|
|
|
|
|
|
};
|
|
|
|
|
|
FileSystemEventHandler h = (_, _) => _debounce?.Change(1000, Timeout.Infinite); // sync tools write in bursts
|
|
|
|
|
|
_watcher.Changed += h;
|
|
|
|
|
|
_watcher.Created += h;
|
|
|
|
|
|
_watcher.Renamed += (_, _) => _debounce?.Change(1000, Timeout.Infinite);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void StopWatching()
|
|
|
|
|
|
{
|
|
|
|
|
|
_watcher?.Dispose();
|
|
|
|
|
|
_watcher = null;
|
|
|
|
|
|
_debounce?.Dispose();
|
|
|
|
|
|
_debounce = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>True if the file on disk is newer than our own last write.</summary>
|
|
|
|
|
|
public bool IsExternalChange()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!File.Exists(DataFilePath)) return false;
|
|
|
|
|
|
var stamp = File.GetLastWriteTimeUtc(DataFilePath);
|
|
|
|
|
|
if (Math.Abs((stamp - LastWriteUtc).TotalMilliseconds) < 50) return false;
|
|
|
|
|
|
LastWriteUtc = stamp;
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
/// <summary>Copies tasks.json from an old location (next to the exe) if no data exists yet.</summary>
|
|
|
|
|
|
public void MigrateFrom(string? legacyDirectory)
|
2026-11-25 13:44:02 +01:00
|
|
|
|
{
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
if (string.IsNullOrEmpty(legacyDirectory) || File.Exists(DataFilePath)) return;
|
|
|
|
|
|
var legacy = Path.Combine(legacyDirectory, "tasks.json");
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
if (File.Exists(legacy) && !string.Equals(Path.GetFullPath(legacy), Path.GetFullPath(DataFilePath), StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
|
File.Copy(legacy, DataFilePath);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Diagnostics.Debug.WriteLine($"[DataService] Migration failed: {ex.Message}");
|
|
|
|
|
|
}
|
2026-11-25 13:44:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<AppData> LoadAsync()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!File.Exists(DataFilePath))
|
|
|
|
|
|
return new AppData();
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
var json = await File.ReadAllTextAsync(DataFilePath);
|
|
|
|
|
|
var data = JsonSerializer.Deserialize<AppData>(json, _jsonOptions);
|
|
|
|
|
|
return data ?? new AppData();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Diagnostics.Debug.WriteLine($"[DataService] Load failed: {ex.Message}");
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
BackupCorruptFile();
|
2026-11-25 13:44:02 +01:00
|
|
|
|
return new AppData();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
private void BackupCorruptFile()
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
var backup = DataFilePath + $".corrupt-{DateTime.Now:yyyyMMdd-HHmmss}";
|
|
|
|
|
|
File.Copy(DataFilePath, backup, overwrite: true);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-11-25 14:52:25 +01:00
|
|
|
|
public void Save(AppData data)
|
|
|
|
|
|
{
|
|
|
|
|
|
_writeLock.Wait();
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
var tmp = DataFilePath + ".tmp";
|
|
|
|
|
|
File.WriteAllText(tmp, JsonSerializer.Serialize(data, _jsonOptions));
|
|
|
|
|
|
Commit(tmp);
|
|
|
|
|
|
}
|
|
|
|
|
|
finally
|
|
|
|
|
|
{
|
|
|
|
|
|
_writeLock.Release();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Commit(string tmp)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (File.Exists(DataFilePath))
|
|
|
|
|
|
File.Replace(tmp, DataFilePath, DataFilePath + ".bak");
|
|
|
|
|
|
else
|
|
|
|
|
|
File.Move(tmp, DataFilePath);
|
Snooze notifications, morning summary, ICS import, data folder sync
- Windows toast notifications with snooze (10 min / 1 h / tomorrow) and
done buttons; balloon fallback; works when Windows starts the app
- Recurring entries snooze via SnoozedUntil without moving their date;
lead reminders keep the real date
- Morning summary once a day from a chosen hour (pure DailySummary)
- iCalendar import incl. Google birthday calendar, folded lines, UTC,
alarms, own export round trip, duplicates skipped by UID, undo
- Data folder selectable (location.json pointer), file watcher reloads
changes from another PC (own writes ignored)
- Themed date picker calendar, WPF tray menu, arrow/Home/End/Space keys
- 90 tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 20:37:20 +01:00
|
|
|
|
LastWriteUtc = File.GetLastWriteTimeUtc(DataFilePath); // our own write is not a "sync change"
|
2026-11-25 14:52:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-11-25 13:44:02 +01:00
|
|
|
|
public async Task SaveAsync(AppData data)
|
|
|
|
|
|
{
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
await _writeLock.WaitAsync();
|
2026-11-25 13:44:02 +01:00
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
var json = JsonSerializer.Serialize(data, _jsonOptions);
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
var tmp = DataFilePath + ".tmp";
|
|
|
|
|
|
await File.WriteAllTextAsync(tmp, json);
|
2026-11-25 14:52:25 +01:00
|
|
|
|
Commit(tmp);
|
2026-11-25 13:44:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Diagnostics.Debug.WriteLine($"[DataService] Save failed: {ex.Message}");
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
finally
|
|
|
|
|
|
{
|
|
|
|
|
|
_writeLock.Release();
|
|
|
|
|
|
}
|
2026-11-25 13:44:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|