diff --git a/Flow.Launcher.Plugin/Result.cs b/Flow.Launcher.Plugin/Result.cs index a34608454..1894e0eda 100644 --- a/Flow.Launcher.Plugin/Result.cs +++ b/Flow.Launcher.Plugin/Result.cs @@ -68,11 +68,20 @@ namespace Flow.Launcher.Plugin public string AutoCompleteText { get; set; } /// - /// The image to be displayed for the result. + /// Path or URI to the icon image for this result. + /// Updates appropriately when set. /// - /// Can be a local file path or a URL. /// - /// GlyphInfo is prioritized if not null + /// Preferred usage: provide a path relative to the plugin directory (for example: "Images\icon.png"). + /// Because is serialized, using relative paths keeps the icon reference portable + /// when Flow is moved. + /// + /// Accepted formats: + /// - Relative file paths (resolved against into ) + /// - Absolute file paths (left as-is) + /// - HTTP/HTTPS URLs (left as-is) + /// - Data URIs (left as-is) + /// public string IcoPath { get => _icoPath; @@ -98,7 +107,10 @@ namespace Flow.Launcher.Plugin } /// - /// TODO COMMENT + /// Absolute path or URI which is used to load and display the result icon for Flow. + /// This is populated by the setter. + /// If a relative path was provided to , this property will contain the resolved + /// absolute local path after combining with . /// public string IcoPathAbsolute => _icoPathAbsolute; diff --git a/Flow.Launcher/Storage/QueryHistory.cs b/Flow.Launcher/Storage/QueryHistory.cs index 56e032c51..d25c13ca0 100644 --- a/Flow.Launcher/Storage/QueryHistory.cs +++ b/Flow.Launcher/Storage/QueryHistory.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text.Json.Serialization; @@ -20,6 +20,11 @@ namespace Flow.Launcher.Storage private readonly int _maxHistory = 300; + /// + /// Migrate legacy history data (stored in ) into the new + /// format and append them to + /// . + /// public void PopulateHistoryFromLegacyHistory() { if (Items.Count == 0) return; @@ -78,6 +83,10 @@ namespace Flow.Launcher.Storage } } + /// + /// Attempts to find an existing in + /// that is considered equal to the supplied . + /// private bool TryGetLastOpenedHistoryResult(Result result, out LastOpenedHistoryResult historyItem) { historyItem = LastOpenedHistoryItems.FirstOrDefault(x => x.Equals(result)); @@ -85,12 +94,15 @@ namespace Flow.Launcher.Storage } /// - /// Refresh stored PluginDirectory (and optionally normalize relative ico paths) - /// using current plugin metadata. Call this after plugins are loaded/initialized. + /// Flow uses IcoPathAbsolute property to display result the icons. This refreshes the IcoPathAbsolute + /// property using current plugin metadata by updating the PluginDirectory property, which in turn also + /// updates IcoPath. This keeps the saved icon paths of results updated correctly if flow is moved around. /// + /// Call this after plugins are loaded/initialized. public void UpdateIcoPathAbsolute() { - if (LastOpenedHistoryItems.Count == 0) return; + if (LastOpenedHistoryItems.Count == 0) + return; foreach (var item in LastOpenedHistoryItems) { diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index f5183d698..68ddada00 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -1372,12 +1372,23 @@ namespace Flow.Launcher.ViewModel } /// - /// TODO COMMENT- Requires the plugins to have initialized first because - /// it needs the plugin directory paths for initialization + /// Refreshes the last-opened history storage by migrating legacy entries and + /// updating stored icon paths to their resolved (absolute) locations. /// + /// + /// Calls to refresh absolute icon + /// paths on the migrated/saved history entries by updating each item's + /// PluginDirectory (which in turn resolves IcoPathAbsolute). + /// + /// Important: + /// - Plugins must be initialized (their metadata and PluginDirectory set) + /// before calling this method; otherwise icon resolution cannot be performed. + /// internal void RefreshLastOpenedHistoryResults() { + // TODO: remove after release v2.3.0 _history.PopulateHistoryFromLegacyHistory(); + _history.UpdateIcoPathAbsolute(); }