Commit e9884112 authored by Thomas Nigro's avatar Thomas Nigro

Clear the LogFile when updating the app

parent a4a13c35
......@@ -9,6 +9,7 @@ namespace VLC_WINRT_APP.Helpers
{
public static StorageFile LogFile;
public static bool usedForRead = false;
private static bool signalUpdate = false;
static LogHelper()
{
Initialize();
......@@ -17,6 +18,11 @@ namespace VLC_WINRT_APP.Helpers
static async Task Initialize()
{
LogFile = await ApplicationData.Current.LocalFolder.CreateFileAsync("LogFile.txt", CreationCollisionOption.OpenIfExists);
if (signalUpdate)
{
FileIO.WriteTextAsync(LogFile, "App updated on " + DateTime.Now.ToString());
signalUpdate = false;
}
Log("------------------------------------------");
Log("------------------------------------------");
Log("------------------------------------------");
......@@ -32,5 +38,10 @@ namespace VLC_WINRT_APP.Helpers
{
if (LogFile != null && !usedForRead) FileIO.AppendTextAsync(LogFile, value);
}
public static void SignalUpdate()
{
signalUpdate = true;
}
}
}
......@@ -46,20 +46,25 @@ namespace VLC_WINRT_APP.Views.MainPages
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (NeedsToDrop())
if (e.NavigationMode == NavigationMode.New)
{
MusicLibraryVM.TrackCollectionRepository.Drop();
MusicLibraryVM.TracklistItemRepository.Drop();
MusicLibraryVM._albumDataRepository.Drop();
MusicLibraryVM._artistDataRepository.Drop();
MusicLibraryVM._trackDataRepository.Drop();
Locator.VideoLibraryVM.VideoRepository.Drop();
MusicLibraryVM.TrackCollectionRepository.Initialize();
MusicLibraryVM.TracklistItemRepository.Initialize();
MusicLibraryVM._albumDataRepository.Initialize();
MusicLibraryVM._artistDataRepository.Initialize();
MusicLibraryVM._trackDataRepository.Initialize();
Locator.VideoLibraryVM.VideoRepository.Initialize();
if (NeedsToDrop())
{
MusicLibraryVM.TrackCollectionRepository.Drop();
MusicLibraryVM.TracklistItemRepository.Drop();
MusicLibraryVM._albumDataRepository.Drop();
MusicLibraryVM._artistDataRepository.Drop();
MusicLibraryVM._trackDataRepository.Drop();
Locator.VideoLibraryVM.VideoRepository.Drop();
MusicLibraryVM.TrackCollectionRepository.Initialize();
MusicLibraryVM.TracklistItemRepository.Initialize();
MusicLibraryVM._albumDataRepository.Initialize();
MusicLibraryVM._artistDataRepository.Initialize();
MusicLibraryVM._trackDataRepository.Initialize();
Locator.VideoLibraryVM.VideoRepository.Initialize();
LogHelper.SignalUpdate();
}
}
HardwareButtons.BackPressed += HardwareButtonsOnBackPressed;
AppBarHelper.UpdateAppBar(typeof(MainPageHome), MainPivot.SelectedIndex);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment