mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
37 lines
917 B
C#
37 lines
917 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace Flow.Launcher.Storage
|
|
{
|
|
public class History
|
|
{
|
|
[JsonInclude]
|
|
public List<HistoryItem> Items { get; private set; } = new List<HistoryItem>();
|
|
|
|
private int _maxHistory = 300;
|
|
|
|
public void Add(string query)
|
|
{
|
|
if (string.IsNullOrEmpty(query)) return;
|
|
if (Items.Count > _maxHistory)
|
|
{
|
|
Items.RemoveAt(0);
|
|
}
|
|
|
|
if (Items.Count > 0 && Items.Last().Query == query)
|
|
{
|
|
Items.Last().ExecutedDateTime = DateTime.Now;
|
|
}
|
|
else
|
|
{
|
|
Items.Add(new HistoryItem
|
|
{
|
|
Query = query,
|
|
ExecutedDateTime = DateTime.Now
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|