/// <summary> /// </summary> /// <param name="parameter">FortData containing the Pokestop that we're visiting</param> /// <param name="mode"></param> /// <param name="suspensionState"></param> /// <returns></returns> public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> suspensionState) { if (suspensionState.Any()) { // Recovering the state CurrentPokestopInfo = new FortDetailsResponse(); CurrentSearchResponse = new FortSearchResponse(); SelectedModifierItem = new ItemData(); CurrentAddModifierResponse = new AddFortModifierResponse(); CurrentPokestop = JsonConvert.DeserializeObject <FortDataWrapper>((string)suspensionState[nameof(CurrentPokestop)]); CurrentPokestopInfo.MergeFrom(ByteString.FromBase64((string)suspensionState[nameof(CurrentPokestop)]).CreateCodedInput()); CurrentSearchResponse.MergeFrom(ByteString.FromBase64((string)suspensionState[nameof(CurrentSearchResponse)]).CreateCodedInput()); SelectedModifierItem.MergeFrom(ByteString.FromBase64((string)suspensionState[nameof(SelectedModifierItem)]).CreateCodedInput()); CurrentAddModifierResponse.MergeFrom(ByteString.FromBase64((string)suspensionState[nameof(CurrentAddModifierResponse)]).CreateCodedInput()); RaisePropertyChanged(() => CurrentPokestopInfo); RaisePropertyChanged(() => CurrentSearchResponse); RaisePropertyChanged(() => SelectedModifierItem); RaisePropertyChanged(() => CurrentAddModifierResponse); } else { // Navigating from game page, so we need to actually load the Pokestop Busy.SetBusy(true, "Loading Pokestop"); CurrentPokestop = (FortDataWrapper)NavigationHelper.NavigationState[nameof(CurrentPokestop)]; NavigationHelper.NavigationState.Remove(nameof(CurrentPokestop)); Logger.Info($"Searching {CurrentPokestop.Id}"); CurrentPokestopInfo = await GameClient.GetFort(CurrentPokestop.Id, CurrentPokestop.Latitude, CurrentPokestop.Longitude); Busy.SetBusy(false); // If timeout is expired we can go to to pokestop page if (CurrentPokestop.CooldownCompleteTimestampMs >= DateTime.UtcNow.ToUnixTime()) { // Timeout is not expired yet, player can't get items from the fort SearchInCooldown?.Invoke(null, null); } } }
/// <summary> /// Provides a safe way to invoke the <see cref="AddFortModifierReceived" /> event. /// </summary> /// <param name="value"></param> public void RaiseAddFortModifierReceived(AddFortModifierResponse value) => AddFortModifierReceived?.Invoke(this, value);