Skip to content

Commit 4a7d90e

Browse files
authored
Fix JSON loading when it's empty (#1224)
1 parent c02a74d commit 4a7d90e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Files/View Models/SettingsViewModel.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ private async void PopulatePinnedSidebarItems()
115115
try
116116
{
117117
App.SidebarPinned = JsonConvert.DeserializeObject<SidebarPinnedModel>(await FileIO.ReadTextAsync(pinnedItemsFile));
118+
if (App.SidebarPinned == null)
119+
{
120+
App.SidebarPinned = new SidebarPinnedModel();
121+
throw new Exception(SidebarPinnedModel.JsonFileName + " is empty, regenerating...");
122+
}
118123
}
119124
catch (Exception)
120125
{
@@ -237,6 +242,11 @@ private async void LoadTerminalApps()
237242
try
238243
{
239244
TerminalsModel = JsonConvert.DeserializeObject<TerminalFileModel>(content);
245+
if (TerminalsModel == null)
246+
{
247+
TerminalsModel = new TerminalFileModel();
248+
throw new JsonSerializationException("terminal.json is empty, regenerating...");
249+
}
240250
}
241251
catch (JsonSerializationException)
242252
{

0 commit comments

Comments
 (0)