@@ -13,12 +13,15 @@ namespace Flow.Launcher.Helper
13
13
internal static class QuickLookHelper
14
14
{
15
15
private const int TIMEOUT = 500 ;
16
+ private static DateTime lastNotificationTime = DateTime . MinValue ;
17
+
16
18
private static readonly string pipeName = $ "QuickLook.App.Pipe.{ WindowsIdentity . GetCurrent ( ) . User ? . Value } ";
17
19
private static readonly string pipeMessageSwitch = "QuickLook.App.PipeMessages.Switch" ;
18
20
private static readonly string pipeMessageToggle = "QuickLook.App.PipeMessages.Toggle" ;
19
21
private static readonly string pipeMessageClose = "QuickLook.App.PipeMessages.Close" ;
20
22
private static readonly string pipeMessageInvoke = "QuickLook.App.PipeMessages.Invoke" ;
21
-
23
+
24
+
22
25
/// <summary>
23
26
/// Toggle QuickLook
24
27
/// </summary>
@@ -64,14 +67,15 @@ public static async Task<bool> OpenQuickLookAsync(string path)
64
67
/// Switch QuickLook to preview another file if it's on
65
68
/// </summary>
66
69
/// <param name="path">File path to preview</param>
70
+ /// <param name="sendFailToast">Send notification if fail</param>
67
71
/// <returns></returns>
68
- public static async Task < bool > SwitchQuickLookAsync ( string path )
72
+ public static async Task < bool > SwitchQuickLookAsync ( string path , bool sendFailToast = false )
69
73
{
70
74
if ( string . IsNullOrEmpty ( path ) )
71
75
return false ;
72
76
73
77
bool success = await SendQuickLookPipeMsgAsync ( pipeMessageSwitch , path ) ;
74
- if ( ! success )
78
+ if ( sendFailToast && ! success )
75
79
{
76
80
ShowQuickLookUnavailableToast ( ) ;
77
81
}
@@ -141,8 +145,12 @@ static async Task<int> QuickLookServerAvailable()
141
145
142
146
private static void ShowQuickLookUnavailableToast ( )
143
147
{
144
- Notification . Show ( InternationalizationManager . Instance . GetTranslation ( "QuickLookFail" ) ,
148
+ if ( lastNotificationTime . AddSeconds ( 10 ) < DateTime . Now )
149
+ {
150
+ Notification . Show ( InternationalizationManager . Instance . GetTranslation ( "QuickLookFail" ) ,
145
151
InternationalizationManager . Instance . GetTranslation ( "QuickLookFailTips" ) ) ;
152
+ lastNotificationTime = DateTime . Now ;
153
+ }
146
154
}
147
155
}
148
156
}
0 commit comments