-
-
Notifications
You must be signed in to change notification settings - Fork 534
Last opened history mode show result icon instead #4057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jjw24
wants to merge
50
commits into
dev
Choose a base branch
from
last_history_show_result_icon
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+342
−134
Open
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
7883e7a
add result IcoPath & Glyph + handling show badge switching
jjw24 10d3ba2
update history result icon display logic & remove badge icon logic
jjw24 26ad473
change getting last history item to get the same result if exists
jjw24 92551c5
show distinct records when history style is last opened
jjw24 25aa5bf
show history result sorted descending by execution time
jjw24 0f26945
remove duplicate history item sort call
jjw24 7958b17
wip show result icon
jjw24 d78d313
update to use IcoAbsoluteLocalPath
jjw24 de0d022
rename last opened class; use inheritance; initialise at startup
jjw24 6b6a9a9
simplify GetHistoryItems
jjw24 8d7fa1d
revert QueryHistoryItems property
jjw24 810725c
add explicit JsonInclude for PluginID internal set
jjw24 2e8bb35
Merge branch 'dev' into last_history_show_result_icon
jjw24 20854ba
formatting
jjw24 7c670de
fix history result highlight and scroll when history mode activated
jjw24 f9df44a
rename to IcoPathAbsolute
jjw24 6d6003f
switch to using TrimmedQuery
jjw24 9c2f239
add method comments for LastOpenedHistoryResult
jjw24 024eeaf
changed LastOpenHistoryResult's Copy to DeepCopy to clarify intent
jjw24 101e5e6
fix Glyph optional null when copying
jjw24 4174b5e
fix title when query history style used
jjw24 94ebbab
update legacy item to show Query style title
jjw24 25037e3
update IcoPath if existing is different to the selected
jjw24 55673cd
add method comments
jjw24 ea7a2d2
mark PopulateHistoryFromLegacyHistory obsolete
jjw24 19fa107
minor fixes and adjustments for code quality
jjw24 216b6f5
Code cleanup
Jack251970 5f99235
Code cleanup
Jack251970 177e607
Add code comments
Jack251970 11645fd
ensure history results ordered by ExecutedDateTime
jjw24 58d910d
fix deep copy Glyph on LastOpenHistoryResult
jjw24 f22b644
Fix issue when querying history items in home page
Jack251970 e6a91a9
Ensure history items have valid icons in QueryHistory
Jack251970 cf4268d
Fix preview panel blank issue
Jack251970 5b2fb1f
Revert "Ensure history items have valid icons in QueryHistory"
Jack251970 e403c41
Change copied icon logic as origin
Jack251970 c610100
Use QueryManager function
Jack251970 e404d02
Update the result when executing history item
Jack251970 26e4529
Update the result when executing history item
Jack251970 583bf74
Update code comments
Jack251970 938a87c
Fix preview panel blank issue
Jack251970 9d9ab1f
Do not allow context menu for history items
Jack251970 3745c44
Revert `Update the result when executing history item`
Jack251970 e970bb4
fix icon & glyph display based on selected history style results
jjw24 9036002
update glyph when history result exists
jjw24 5c241d7
fix to respect max history result shown setting
jjw24 4ddb164
adjusted context menu call to exit early when history result selected
jjw24 657e6ae
add null-safe comparison for glyph
jjw24 bf44637
revert context menu early exit when history result
jjw24 8e127d0
Code cleanup
Jack251970 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| using System; | ||
| using Flow.Launcher.Infrastructure; | ||
| using Flow.Launcher.Plugin; | ||
|
|
||
| namespace Flow.Launcher.Storage; | ||
|
|
||
| /// <summary> | ||
| /// A serializable result used to record the last opened history for reopening results. | ||
| /// Inherits common result fields from <see cref="Result"/> and adds the original query and execution time. | ||
| /// </summary> | ||
| public class LastOpenedHistoryResult : Result | ||
| { | ||
| /// <summary> | ||
| /// The query string from Query.TrimmedQuery property, it is stored as a string instead of the entire Query class <see cref="Result"/>. | ||
| /// This is used so results can be reopened or re-run using the serialized query string. | ||
| /// </summary> | ||
| public string Query { get; set; } = string.Empty; | ||
|
|
||
| /// <summary> | ||
| /// The local date and time when this result was executed/opened. | ||
| /// </summary> | ||
| public DateTime ExecutedDateTime { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of <see cref="LastOpenedHistoryResult"/>. | ||
| /// </summary> | ||
| public LastOpenedHistoryResult() | ||
| { | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Creates a <see cref="LastOpenedHistoryResult"/> from an existing <see cref="Result"/>. | ||
| /// Copies required fields and sets up default reopening actions. | ||
| /// </summary> | ||
| /// <param name="result">The original result to create history from.</param> | ||
| public LastOpenedHistoryResult(Result result) | ||
| { | ||
| Title = result.Title; | ||
| SubTitle = result.SubTitle; | ||
| PluginID = result.PluginID; | ||
| Query = result.OriginQuery.TrimmedQuery; | ||
| OriginQuery = result.OriginQuery; | ||
| RecordKey = result.RecordKey; | ||
| IcoPath = result.IcoPath; | ||
| PluginDirectory = result.PluginDirectory; | ||
| Glyph = result.Glyph; | ||
| ExecutedDateTime = DateTime.Now; | ||
| // Used for Query History style reopening | ||
| Action = _ => | ||
| { | ||
| App.API.BackToQueryResults(); | ||
| App.API.ChangeQuery(result.OriginQuery.TrimmedQuery); | ||
| return false; | ||
| }; | ||
| // Used for Last Opened History style reopening, currently need to be assigned at MainViewModel.cs | ||
| AsyncAction = null; | ||
| } | ||
jjw24 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /// <summary> | ||
| /// Selectively creates a deep copy of the required properties for <see cref="LastOpenedHistoryResult"/> | ||
| /// based on the style of history- Last Opened or Query. | ||
| /// This copy should be independent of original and full isolated. | ||
| /// </summary> | ||
| /// <returns>A new <see cref="LastOpenedHistoryResult"/> containing the same required data.</returns> | ||
| public LastOpenedHistoryResult DeepCopyForHistoryStyle(bool isHistoryStyleLastOpened) | ||
| { | ||
| // queryValue and glyphValue are captured to ensure they are correctly referenced in the Action delegate. | ||
| var queryValue = Query; | ||
| var glyphValue = Glyph; | ||
|
|
||
| var title = string.Empty; | ||
| var showBadge = false; | ||
| var badgeIcoPath = string.Empty; | ||
| var icoPath = string.Empty; | ||
| var glyph = null as GlyphInfo; | ||
|
|
||
| if (isHistoryStyleLastOpened) | ||
| { | ||
| title = Title; | ||
| icoPath = IcoPath; | ||
| glyph = glyphValue != null | ||
| ? new GlyphInfo(glyphValue.FontFamily, glyphValue.Glyph) | ||
| : null; | ||
| showBadge = true; | ||
| badgeIcoPath = Constant.HistoryIcon; | ||
| } | ||
| else | ||
| { | ||
| title = Localize.executeQuery(Query); | ||
| icoPath = Constant.HistoryIcon; | ||
| glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uE81C"); | ||
| showBadge = false; | ||
| } | ||
|
|
||
| return new LastOpenedHistoryResult | ||
| { | ||
| Title = title, | ||
| // Subtitle has datetime which can cause duplicates when saving. | ||
| SubTitle = Localize.lastExecuteTime(ExecutedDateTime), | ||
| // Empty PluginID so the source of last opened history results won't be updated, this copy is meant to be temporary. | ||
| PluginID = string.Empty, | ||
| Query = Query, | ||
| OriginQuery = new Query { TrimmedQuery = Query }, | ||
| RecordKey = RecordKey, | ||
| IcoPath = icoPath, | ||
| ShowBadge = showBadge, | ||
| BadgeIcoPath = badgeIcoPath, | ||
| PluginDirectory = PluginDirectory, | ||
| // Used for Query History style reopening | ||
| Action = _ => | ||
| { | ||
| App.API.BackToQueryResults(); | ||
| App.API.ChangeQuery(queryValue); | ||
| return false; | ||
| }, | ||
| // Used for Last Opened History style reopening, currently need to be assigned at MainViewModel.cs | ||
| AsyncAction = null, | ||
| Glyph = glyph, | ||
| ExecutedDateTime = ExecutedDateTime | ||
| // Note: Other properties are left as default — copy if needed. | ||
| }; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Determines whether the specified <see cref="Result"/> is equivalent to this history result. | ||
| /// Comparison uses <see cref="Result.RecordKey"/> when available; otherwise falls back to title/subtitle/plugin id and query. | ||
| /// </summary> | ||
| /// <param name="r">The result to compare to.</param> | ||
| /// <returns><c>true</c> if the results are considered equal; otherwise <c>false</c>.</returns> | ||
| public bool Equals(Result r) | ||
| { | ||
| if (string.IsNullOrEmpty(RecordKey) || string.IsNullOrEmpty(r.RecordKey)) | ||
| { | ||
| return Title == r.Title | ||
| && SubTitle == r.SubTitle | ||
| && PluginID == r.PluginID | ||
| && Query == r.OriginQuery.TrimmedQuery; | ||
| } | ||
| else | ||
| { | ||
| return RecordKey == r.RecordKey | ||
| && PluginID == r.PluginID | ||
| && Query == r.OriginQuery.TrimmedQuery; | ||
| } | ||
| } | ||
jjw24 marked this conversation as resolved.
Show resolved
Hide resolved
jjw24 marked this conversation as resolved.
Show resolved
Hide resolved
Jack251970 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.