mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Add minimum gap time between fail toasts
This commit is contained in:
parent
c705b01326
commit
7033bce433
1 changed files with 12 additions and 4 deletions
|
|
@ -13,12 +13,15 @@ namespace Flow.Launcher.Helper
|
||||||
internal static class QuickLookHelper
|
internal static class QuickLookHelper
|
||||||
{
|
{
|
||||||
private const int TIMEOUT = 500;
|
private const int TIMEOUT = 500;
|
||||||
|
private static DateTime lastNotificationTime = DateTime.MinValue;
|
||||||
|
|
||||||
private static readonly string pipeName = $"QuickLook.App.Pipe.{WindowsIdentity.GetCurrent().User?.Value}";
|
private static readonly string pipeName = $"QuickLook.App.Pipe.{WindowsIdentity.GetCurrent().User?.Value}";
|
||||||
private static readonly string pipeMessageSwitch = "QuickLook.App.PipeMessages.Switch";
|
private static readonly string pipeMessageSwitch = "QuickLook.App.PipeMessages.Switch";
|
||||||
private static readonly string pipeMessageToggle = "QuickLook.App.PipeMessages.Toggle";
|
private static readonly string pipeMessageToggle = "QuickLook.App.PipeMessages.Toggle";
|
||||||
private static readonly string pipeMessageClose = "QuickLook.App.PipeMessages.Close";
|
private static readonly string pipeMessageClose = "QuickLook.App.PipeMessages.Close";
|
||||||
private static readonly string pipeMessageInvoke = "QuickLook.App.PipeMessages.Invoke";
|
private static readonly string pipeMessageInvoke = "QuickLook.App.PipeMessages.Invoke";
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Toggle QuickLook
|
/// Toggle QuickLook
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -64,14 +67,15 @@ namespace Flow.Launcher.Helper
|
||||||
/// Switch QuickLook to preview another file if it's on
|
/// Switch QuickLook to preview another file if it's on
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path">File path to preview</param>
|
/// <param name="path">File path to preview</param>
|
||||||
|
/// <param name="sendFailToast">Send notification if fail</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static async Task<bool> SwitchQuickLookAsync(string path)
|
public static async Task<bool> SwitchQuickLookAsync(string path, bool sendFailToast = false)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(path))
|
if (string.IsNullOrEmpty(path))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool success = await SendQuickLookPipeMsgAsync(pipeMessageSwitch, path);
|
bool success = await SendQuickLookPipeMsgAsync(pipeMessageSwitch, path);
|
||||||
if (!success)
|
if (sendFailToast && !success)
|
||||||
{
|
{
|
||||||
ShowQuickLookUnavailableToast();
|
ShowQuickLookUnavailableToast();
|
||||||
}
|
}
|
||||||
|
|
@ -141,8 +145,12 @@ namespace Flow.Launcher.Helper
|
||||||
|
|
||||||
private static void ShowQuickLookUnavailableToast()
|
private static void ShowQuickLookUnavailableToast()
|
||||||
{
|
{
|
||||||
Notification.Show(InternationalizationManager.Instance.GetTranslation("QuickLookFail"),
|
if (lastNotificationTime.AddSeconds(10) < DateTime.Now)
|
||||||
|
{
|
||||||
|
Notification.Show(InternationalizationManager.Instance.GetTranslation("QuickLookFail"),
|
||||||
InternationalizationManager.Instance.GetTranslation("QuickLookFailTips"));
|
InternationalizationManager.Instance.GetTranslation("QuickLookFailTips"));
|
||||||
|
lastNotificationTime = DateTime.Now;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue