add method comments

This commit is contained in:
Jeremy 2026-01-04 21:16:13 +11:00
parent 25037e3f5f
commit 55673cdb4b
3 changed files with 45 additions and 10 deletions

View file

@ -68,11 +68,20 @@ namespace Flow.Launcher.Plugin
public string AutoCompleteText { get; set; } public string AutoCompleteText { get; set; }
/// <summary> /// <summary>
/// The image to be displayed for the result. /// Path or URI to the icon image for this result.
/// Updates <IcoPathAbsolute/> appropriately when set.
/// </summary> /// </summary>
/// <value>Can be a local file path or a URL.</value>
/// <remarks> /// <remarks>
/// GlyphInfo is prioritized if not null</remarks> /// Preferred usage: provide a path relative to the plugin directory (for example: "Images\icon.png").
/// Because <see cref="IcoPath"/> is serialized, using relative paths keeps the icon reference portable
/// when Flow is moved.
///
/// Accepted formats:
/// - Relative file paths (resolved against <see cref="PluginDirectory"/> into <see cref="IcoPathAbsolute"/>)
/// - Absolute file paths (left as-is)
/// - HTTP/HTTPS URLs (left as-is)
/// - Data URIs (left as-is)
/// </remarks>
public string IcoPath public string IcoPath
{ {
get => _icoPath; get => _icoPath;
@ -98,7 +107,10 @@ namespace Flow.Launcher.Plugin
} }
/// <summary> /// <summary>
/// TODO COMMENT /// Absolute path or URI which is used to load and display the result icon for Flow.
/// This is populated by the <see cref="IcoPath"/> setter.
/// If a relative path was provided to <see cref="IcoPath"/>, this property will contain the resolved
/// absolute local path after combining with <see cref="PluginDirectory"/>.
/// </summary> /// </summary>
public string IcoPathAbsolute => _icoPathAbsolute; public string IcoPathAbsolute => _icoPathAbsolute;

View file

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
@ -20,6 +20,11 @@ namespace Flow.Launcher.Storage
private readonly int _maxHistory = 300; private readonly int _maxHistory = 300;
/// <summary>
/// Migrate legacy history data (stored in <see cref="Items"/>) into the new
/// <see cref="LastOpenedHistoryResult"/> format and append them to
/// <see cref="LastOpenedHistoryItems"/>.
/// </summary>
public void PopulateHistoryFromLegacyHistory() public void PopulateHistoryFromLegacyHistory()
{ {
if (Items.Count == 0) return; if (Items.Count == 0) return;
@ -78,6 +83,10 @@ namespace Flow.Launcher.Storage
} }
} }
/// <summary>
/// Attempts to find an existing <see cref="LastOpenedHistoryResult"/> in <see cref="LastOpenedHistoryItems"/>
/// that is considered equal to the supplied <paramref name="result"/>.
/// </summary>
private bool TryGetLastOpenedHistoryResult(Result result, out LastOpenedHistoryResult historyItem) private bool TryGetLastOpenedHistoryResult(Result result, out LastOpenedHistoryResult historyItem)
{ {
historyItem = LastOpenedHistoryItems.FirstOrDefault(x => x.Equals(result)); historyItem = LastOpenedHistoryItems.FirstOrDefault(x => x.Equals(result));
@ -85,12 +94,15 @@ namespace Flow.Launcher.Storage
} }
/// <summary> /// <summary>
/// Refresh stored PluginDirectory (and optionally normalize relative ico paths) /// Flow uses IcoPathAbsolute property to display result the icons. This refreshes the IcoPathAbsolute
/// using current plugin metadata. Call this after plugins are loaded/initialized. /// 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.
/// </summary> /// </summary>
/// <remarks> Call this after plugins are loaded/initialized.</remarks>
public void UpdateIcoPathAbsolute() public void UpdateIcoPathAbsolute()
{ {
if (LastOpenedHistoryItems.Count == 0) return; if (LastOpenedHistoryItems.Count == 0)
return;
foreach (var item in LastOpenedHistoryItems) foreach (var item in LastOpenedHistoryItems)
{ {

View file

@ -1372,12 +1372,23 @@ namespace Flow.Launcher.ViewModel
} }
/// <summary> /// <summary>
/// TODO COMMENT- Requires the plugins to have initialized first because /// Refreshes the last-opened history storage by migrating legacy entries and
/// it needs the plugin directory paths for initialization /// updating stored icon paths to their resolved (absolute) locations.
/// </summary> /// </summary>
/// <remarks>
/// Calls <see cref="History.UpdateIcoPathAbsolute"/> to refresh absolute icon
/// paths on the migrated/saved history entries by updating each item's
/// <c>PluginDirectory</c> (which in turn resolves <c>IcoPathAbsolute</c>).
///
/// Important:
/// - Plugins must be initialized (their metadata and <c>PluginDirectory</c> set)
/// before calling this method; otherwise icon resolution cannot be performed.
/// </remarks>
internal void RefreshLastOpenedHistoryResults() internal void RefreshLastOpenedHistoryResults()
{ {
// TODO: remove after release v2.3.0
_history.PopulateHistoryFromLegacyHistory(); _history.PopulateHistoryFromLegacyHistory();
_history.UpdateIcoPathAbsolute(); _history.UpdateIcoPathAbsolute();
} }