Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

Commit

Permalink
* remake releases in cinemahall on cache file
Browse files Browse the repository at this point in the history
  • Loading branch information
trueromanus committed Sep 24, 2020
1 parent 9db3ec3 commit f86974d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Anilibria/Pages/CinemaHall/CinemaHallViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
using Anilibria.Services;
using Anilibria.Storage;
using Anilibria.Storage.Entities;
using Newtonsoft.Json;
using Windows.Storage;

namespace Anilibria.Pages.CinemaHall {

Expand Down Expand Up @@ -129,7 +131,7 @@ public void NavigateFrom () {
/// Navigate to.
/// </summary>
/// <param name="parameter">Parameter.</param>
public void NavigateTo ( object parameter ) {
public async void NavigateTo ( object parameter ) {

var collection = m_DataContext.GetCollection<CinemaHallReleaseEntity> ();
m_ReleasesEntity = collection.FirstOrDefault ();
Expand All @@ -143,8 +145,12 @@ public void NavigateTo ( object parameter ) {

IsEmptyList = !m_ReleasesEntity.Releases.Any ();

var releasesCollection = m_DataContext.GetCollection<ReleaseEntity> ();
var releases = releasesCollection.All ();
var releasesFile = await ApplicationData.Current.LocalFolder.TryGetItemAsync ( "releases.cache" );
var releases = Enumerable.Empty<ReleaseEntity> ();
if ( releasesFile != null ) {
var relasesJson = await FileIO.ReadTextAsync ( (IStorageFile) releasesFile );
releases = relasesJson.Length > 0 ? JsonConvert.DeserializeObject<List<ReleaseEntity>> ( relasesJson ) : Enumerable.Empty<ReleaseEntity> ();
}

var releasesDictionary = releases.ToDictionary ( a => a.Id );

Expand Down

0 comments on commit f86974d

Please sign in to comment.