Archived
1
0

Crashing when there is no notifications.json file fixed

This commit is contained in:
Michael Gordeev
2018-12-12 21:49:54 +03:00
parent 0e6f847e02
commit b415dbd00a
-3
View File
@@ -121,15 +121,12 @@ namespace FoxTube
} }
public async void Initialize() public async void Initialize()
{
if (await ApplicationData.Current.RoamingFolder.GetFileAsync("notifications.json") != null)
{ {
bool[] notificationsSettings = new bool[] { (bool)settings.Values["newVideoNotification"], (bool)settings.Values["devNews"] }; bool[] notificationsSettings = new bool[] { (bool)settings.Values["newVideoNotification"], (bool)settings.Values["devNews"] };
await FileIO.WriteTextAsync( await FileIO.WriteTextAsync(
await ApplicationData.Current.RoamingFolder.CreateFileAsync("notifications.json", CreationCollisionOption.ReplaceExisting), await ApplicationData.Current.RoamingFolder.CreateFileAsync("notifications.json", CreationCollisionOption.ReplaceExisting),
JsonConvert.SerializeObject(notificationsSettings)); JsonConvert.SerializeObject(notificationsSettings));
} }
}
protected override void OnNavigatedTo(NavigationEventArgs e) protected override void OnNavigatedTo(NavigationEventArgs e)
{ {