[PTRun]Add history plugin (#19569)

* Progress!

* Progress...

* POC level.

* Added ability to delete from history using IPublicAPI

* Some sorting, works in some cases.

* Rename "Run History" back to just "History".

* Updated item from review.

* Slight change to PowerLauncher ref, set Copy Local = False

* Fixed missing history items if added to history without search term.

* Added placeholder unit test project

* Updates for new History plugin.

* Update Product.wxs, removed useless Unit Test project

* Removed actual files for "Microsoft.PowerToys.Run.Plugin.History.UnitTests"

* Added history.md, updated ESRPSigning_core.json

* Changes for review

* Removed now global CodeAnalysis/stylecop
This commit is contained in:
Jeff Lord
2022-08-23 16:27:45 -04:00
committed by GitHub
parent 8cea22aaf1
commit 4c796c0b53
21 changed files with 940 additions and 64 deletions

View File

@@ -1,58 +0,0 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Wox.Plugin;
namespace PowerLauncher.Storage
{
public class UserSelectedRecord
{
public class UserSelectedRecordItem
{
public int SelectedCount { get; set; }
public DateTime LastSelected { get; set; }
}
[JsonInclude]
public Dictionary<string, UserSelectedRecordItem> Records { get; private set; } = new Dictionary<string, UserSelectedRecordItem>();
public void Add(Result result)
{
if (result == null)
{
throw new ArgumentNullException(nameof(result));
}
var key = result.ToString();
if (Records.TryGetValue(key, out var value))
{
Records[key].SelectedCount = Records[key].SelectedCount + 1;
Records[key].LastSelected = DateTime.UtcNow;
}
else
{
Records.Add(key, new UserSelectedRecordItem { SelectedCount = 1, LastSelected = DateTime.UtcNow });
}
}
public UserSelectedRecordItem GetSelectedData(Result result)
{
if (result == null)
{
throw new ArgumentNullException(nameof(result));
}
if (result != null && Records.TryGetValue(result.ToString(), out var value))
{
return value;
}
return new UserSelectedRecordItem { SelectedCount = 0, LastSelected = DateTime.MinValue };
}
}
}