Exemple #1
0
 /// <summary>
 /// Downloads all recommendations
 /// </summary>
 private void ForceDownloadRecs()
 {
     if (SerializationHelper.EmptyRecommendations())
     {
         RecList.Clear();
         UpdateRecs(this, null);
     }
 }
Exemple #2
0
        /// <summary>
        /// Tries connecting to Tinder servers and getting recommendations
        /// </summary>
        /// <returns></returns>
        public async Task <bool> GetRecs()
        {
            try
            {
                var recs = await TinderHelper.GetRecommendations();

                if (recs.Recommendations != null)
                {
                    // Out of recs
                    if (recs.Recommendations.Any(x => x.Id.Contains("tinder_rate_limited")))
                    {
                        RecList.Clear();
                        SerializationHelper.EmptyRecommendations();
                        return(false);
                    }
                    // If it's the first time getting recs
                    if (RecList == null)
                    {
                        RecList = new ObservableCollection <RecModel>(recs.Recommendations);
                    }
                    // Only useful if we force to download new recs in which case old
                    // recs would be no use anyway
                    RecList.Clear();
                    foreach (var item in recs.Recommendations)
                    {
                        RecList.Add(item);
                    }

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (TinderRequestException e)
            {
                MessageBox.Show(e.Message);
                return(false);
            }
        }