GOOGLE-155 Enable searching of collapsed GDrive folders
|Participant||Role||Time Spent||Comments||Latest Comment|
|Reviewer - 100% reviewed||5m||2||hostName is not used anywhere other than line 540. Maybe ...|
|Reviewer - Complete||10m|
|Reviewer - 100% reviewed||3m|
|Reviewer - 0% reviewed|
|Reviewer - Complete||41m||3||Comment here would be great|
|Reviewer - Complete||16m||2||Great to check using JSLink.|
|Reviewer - Complete||6m|
With the implementation of the new GDrive UI with jsTree, folder data is only loaded from Google Drive when requested by the user when they expand folders. Therefore, GDrive doesn't know about the contents of the folders and cannot perform an accurate search.
To remedy this, we make use of a jsTree API feature which allows us to specify an Ajax function (although it doesn't need to be Ajax) that will determine what folder data needs to be loaded before a search is run.
This has an added benefit that the current page view caches the folder data, making subsequent folder expansions and searches quicker.
Added pre-search Ajax function to assemble a list of tree nodes that should be loaded (because they contain search results) before the search code is run.
Added code to only perform search if search text has changed, because some browser events (switching tabs, windows, or even between applications) was causing the search to be run again.
When a new search begins, clear the old search.
Keep a list of outstanding search Ajax requests so that they can be aborted just before a new search starts.
Disabled the jsTree web worker feature, which was interfering with our Ajax calls.
Changes unrelated to this issue:
Changed console.log() calls to console.warn() so that browsers that have a warning indicator will show it.
Fixed the order of arguments received from $.ajax() calls by error callback functions.
getDriveFile(): Surprisingly, this method has been using the error callback's arguments in the wrong order for a long time. I've fixed this and also changed the code to use the "promise" model in an attempt to improve error handling. It didn't help, but it didn't hurt. The promise model is recommended for new jQuery code, so I'll keep this code.
_getGoogleDriveUrl(): Simplified and clarified by using meaningful, descriptive variable names.
Also, JSLint recommended changes and simplified some other code.
Branches in review
Issues Raised From Comments