Core refactoring (app doesn't work)
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Windows.Storage;
|
||||
|
||||
namespace FoxTube.Services
|
||||
{
|
||||
public static class History
|
||||
{
|
||||
static readonly ApplicationDataContainer storage = ApplicationData.Current.RoamingSettings;
|
||||
|
||||
public static string[] SearchHistory
|
||||
{
|
||||
get => JsonConvert.DeserializeObject<string[]>(storage.Values["SearchHistory"] as string) ?? new string[0];
|
||||
private set => JsonConvert.SerializeObject(value);
|
||||
}
|
||||
|
||||
public static void AddSearchHistoryEntry(string term)
|
||||
{
|
||||
List<string> history = SearchHistory.ToList();
|
||||
history.Insert(0, term);
|
||||
|
||||
if (history.Count > 5)
|
||||
history.RemoveRange(5, history.Count - 5);
|
||||
|
||||
SearchHistory = history.ToArray();
|
||||
}
|
||||
|
||||
public static void ClearSearchHistory() =>
|
||||
SearchHistory = new string[0];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user