-
-
Notifications
You must be signed in to change notification settings - Fork 154
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
Add prefix checking before displaying list of matched articles #593
Conversation
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.
The implementation looked like a good idea at first sight.
But, second thought, I think it won't be reliable (and may introduce bugs) because comparing the first dirEntry url with the search field is not safe.
The current search implementation uses several "variants" of the search field to do the binary search with (and also first trims it). See function findDirEntriesWithPrefix
of ZIMArchive. So we can not simply compare it. Doing a case insensitive comparison might cover most cases, but also could give false-positives.
Another problem is that the search algorithm might change in the future. For example to allow to search the string anywhere in the title, or even for full-text search. We won't be able to duplicate this logic here.
A proper fix for #184 (that could also cover #89 as a refactoring of #587) would be to pass a kind of state through all the callbacks, that could be compared with the expected state.
But it might be complicated to implement.
This state could be an object with 2 properties : the type of current action (searching, or going to an article), and an id for the current action (search prefix for a search, article url for an article). Or maybe this state might even be an integer, incremented on each user action. This needs to be thought about more deeply.
…st async action that could result in false display
Thanks for the hints in addressing this issue. I managed to use the The only problem I found while testing is after searching and clicking an article, the search result might come back too fast and block the action of going to the clicked article but I am assuming this rarely happens. |
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.
The way to implement that might be good, but it lacks testing and re-reading.
Please take more time to review/test your changes before asking for our reviews, else I'll give up.
In ServiceWorker mode, the main page does not show up, and any attempt to open an article gives a :
isDirEntryExpectedToBeDisplayed is not defined
There also are many typos in the comments.
More minor remarks :
- Regarding the wording, I think you should use the word "async" instead of "asyn". The function
isThisCallbackExpectedToBePerformed
would have a more meaningful name with something likeisTheLatestAction
- in the functions that get the new action as a parameter, I would have put it as the last parameter instead of the first. Because it's not the most important parameter, and might be optional : if no action is passed, we don't do any check (like before)
To help testing, you might introduce delays in all the async actions you try to cover, with something like setTimeout
. You could even commit it, to help our testing too. And you would remove these delays before the merging
@zengchu2 : do you intend to finalize this PR? |
No feedback from the developer. I think this PR will have to be closed or finished by someone else. |
Closing this PR. The branch should be kept because I think the implementation was on the right track anyway |
Attempt to address the issue described in issue #184 .
Add an early return if either the follow conditions holds: