I understand my contributions may be rejected for any reason
I understand my contributions are for the benefit of Derpibooru and/or the Philomena software
I understand my contributions are licensed under the GNU AGPLv3
[x] I understand all of the above
This PR mostly attempts to split the code to reduce cognitive complexity.
All the logic related to displaying & interacting with autocomplete popup was extracted into SuggestionsPopup class.
Now only one actual popup element is getting rendered and re-used for multiple inputs, instead of constantly removing and rendering a new ones every time.
Function of requesting the server-side suggestions was extracted into fetchSuggestions function.
Caching now happens insight the function, only one request will be sent per term.
Fixed the term not getting "normalized" before sending it to server-side auto-completion endpoint. Now the term is getting lower-cased and all white-spaces are trimmed out.
Replaced the Object used for caching with Map. This was done to fix errors when attempting to search terms matching with default Object methods, such as: toString, constructor, __defineGetter__, __lookupGetter__, etc.
Before you begin
I understand my contributions may be rejected for any reason
I understand my contributions are for the benefit of Derpibooru and/or the Philomena software
I understand my contributions are licensed under the GNU AGPLv3
[x] I understand all of the above
This PR mostly attempts to split the code to reduce cognitive complexity.
SuggestionsPopup
class.fetchSuggestions
function.Object
used for caching withMap
. This was done to fix errors when attempting to search terms matching with defaultObject
methods, such as:toString
,constructor
,__defineGetter__
,__lookupGetter__
, etc.