| Name | Message | Date |
|---|---|---|
| 📄 AppSettings.cs | 4 days ago | |
| 📄 NoteCacheJsonContext.cs | 4 days ago | |
| 📄 NoteCacheStore.cs | 4 days ago |
📄
src/Storage/NoteCacheStore.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System.Text.Json; using NotesApp.Models; namespace NotesApp.Storage; public static class NoteCacheStore { private const string FileName = "notes_cache.json"; private static string FilePath => Path.Combine(Application.Context.FilesDir!.AbsolutePath, FileName); public static List<NoteCacheEntry> Load() { try { if (!File.Exists(FilePath)) return []; using var stream = File.OpenRead(FilePath); return JsonSerializer.Deserialize( stream, NoteCacheJsonContext.Default.ListNoteCacheEntry ) ?? []; } catch { // Corrupt or unreadable cache; treat as empty and let the next refresh rebuild it. return []; } } public static void Save(List<NoteCacheEntry> entries) { using var stream = File.Create(FilePath); JsonSerializer.Serialize(stream, entries, NoteCacheJsonContext.Default.ListNoteCacheEntry); } }