-
-
Notifications
You must be signed in to change notification settings - Fork 486
New API Instance (ReQuery) #2581
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
Conversation
This comment has been minimized.
This comment has been minimized.
jjw24
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Really well described PR, thank you for making the change requirement clear and easy to understand.
|
Let's hold off merging till 1.18.0 release is scheduled. |
|
|
|
🤩 |
|
Hey there, I'd like to introduce an idea I've tested. However, I can't judge whether it enhances the user experience. I just want to share it. Problem: By default, ReQuery sets the selected result to the first index all the time. Task.Run(async () =>
{
await this._notionDataParser.CallApiForSearch();
Context.API.ReQuery();
});Result Fix: I introduced a new boolean, Task.Run(async () =>
{
await this._notionDataParser.CallApiForSearch();
Context.API.ReQuery(reselect: false);
});Result I cannot determine whether adding this option is better or not. It might not be more beneficial for large queries, like fetching 200 results, where users might not be noticed that the query has been reloaded. Alternatively, adding this option and allowing plugin developers to choose it could be an improvement. Feel free to share your thoughts on this feature. Note: The method override keeps Link to branch let me know if you interested to push changes. |
|
interesting. I think this is easier to use compared to the UpdateResults event? |
|
It's still using UpdateResults but passing a new parameter to it to prevent selecting the first index. I didn't attempt to come up with something new to reduce test time and potential issues that may arise. |
Prevent reselect first result if needed
|
Hey @jjw24 , Please see above comment. |
This comment has been minimized.
This comment has been minimized.
|
I don't like the idea of storing a variable for whether reselect. Probably it should be a parameter? |
|
I am unsure if achieving smooth functionality is possible in this case, mainly due to the involvement of the RegisterViewUpdate method, which is invoking the UpdateResultView instance. This specific method is called by the Class structor and occurs subsequent to a query change and I encountered difficulty in passing a new parameter to it |
Oh probably add another property to |
|
How you'd suggest passing reselect param from ReQuery method() to RegisterViewUpdate() because calling RegisterViewUpdate() with new param causing a bug that flow not select first result by default any more after method is invoked, that's why i prefer storing a variable for whether reselect, it didn't raise any issues with me till now. public void ReQuery(bool reselect)
{
if (SelectedIsFromQueryResults())
{
QueryResults(isReQuery: true);
RegisterViewUpdate(reselect);
}
} |
No that's not what I mean. I mean add a parameter to the It doesn't make sense to re-register everytime query. |
|
Thanks, @taooceros, for your suggestion. I couldn't figure out a way to pass the parameter from |
|
Sure let me show you what I mean. |
|
@AminSallah sorry for the delay. Take a look? |
This comment has been minimized.
This comment has been minimized.
|
Yeah, now I understand, but do you prefer to add a parameter to the entire collection, needing only one to determine whether to select the first or not, rather than declaring it as a top class parameter? Also, I encountered a bug that I tried to fix, but couldn't figure out why it occurred. I double checked that the whole collection has the same |
|
I guess it's the problem we try to avoid by selecting the first result. Plugins result may appear at different time and some early result may get selected, and later move to some odd position. |
|
The parameter is not added to the entire collection of results, but only the result batch, which is slightly better. In fact, I think it is needed, because the results of different plugins can arrive at different times. They may not be processed at once? I am doubting that the original implementation will only disable reSelect at the first results update but not in the later ones. Though I am not sure whether this is desirable or not.... This kind of reasoning can be the reason of the issue you mentioned. |
|
Class parameter introduce mutable state across various method, which might eventually make it very very hard to debug (what if we trigger a normal query right after some plugin trigger requery?). Flow already have a massive mutable states that makes it very hard to modify, so I would advocate that we should make things more pure. Note: The local function (in the query result) still capture some state but that seems to be a little bit unavoidable unless we would like to pass the channel reader to the query function (which might be a good choice though). |
|
@AminSallah I found the issue...I made two parameter with the same when refactoring, which somehow create weird behavior. |
This comment has been minimized.
This comment has been minimized.
I noticed this just now. Currently, it's working very well. Much thanks to you @taooceros, for your assistance. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
You are very welcome. |
|
@AminSallah could you please resolve conflict. I see this PR should be ready to go right, any additional from you @taooceros ? |
|
Yeah it's good for me |
@check-spelling-bot Report🔴 Please reviewSee the 📂 files view, the 📜action log, or 📝 job summary for details.Unrecognized words (23)To accept these unrecognized words as correct, you could run the following commands... in a clone of the git@github.com:AminSallah/Flow.Launcher.git repository curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/prerelease/apply.pl' |
perl - 'https://github.com/Flow-Launcher/Flow.Launcher/actions/runs/8462244429/attempts/1'
Errors (2)See the 📂 files view, the 📜action log, or 📝 job summary for details.
See ❌ Event descriptions for more information. If the flagged items are 🤯 false positivesIf items relate to a ...
|



Changes:
ReQueryin PublicAPIInstance.cs.ReQueryin IPublicAPI.cs.public.Benefits:
This update allows plugin developers to reload queries to refresh data, addressing the following use cases:
ReQueryto update the query.Testing the ReQuery Instance
I have tested the
ReQueryinstance in one of my plugins to requery every second.Result:

Why not use
ChangeQuery(Query.RawQuery, true):The use of this method failed for me; it is too sticky. I cannot remove the action keyword or continue typing in the query. When triggering the flow, it changes the query on its own.
Result:
