Google Drive Javascript API: Detect drive changes - return changes only -


i try detect changes on users drive update contents in list when request changes receive entries on drive.

to explain why want this: handy feature when user has 2 tabs opened, 1 google drive environment , 1 application uses drive (doesn't need reload app see content changes made in drive environment).

i'm following guide listed here: https://developers.google.com/drive/v2/reference/changes/list

a strange thing need largestchangeid+1, how know value? not know largestchangeid , set null. no matter i'm doing value content.

i made following code:

o.getcloudfileupdates = function(fcallback, sfolderid ) {   var odefq = {q:'trashed=false '+(typeof sfolderid == 'string'?('and "'+sfolderid+'" in parents'):''), largestchangeid:null, orderby:'title', maxresults:1000},             fgetfiles = function(request, result)        {         request.execute(function(resp)          {             //$d(resp);              if( resp.items instanceof array )                {               result = result.concat(resp.items);               if( resp.nextpagetoken )                { // next page , 'break' function                   return fgetfiles(gapi.client.drive.changes.list($j.extend(odefq,{'pagetoken':resp.nextpagetoken})), result);                }              }              if( result.length )             {               result.sort(function(a,b)                {                 if (a.title < b.title)                  { return -1; }                 if (a.title > b.title)                  { return 1; }                 return 0;               });                fcallback(result);               return;             }             fcallback(false);         });       };    try {     fgetfiles(gapi.client.drive.changes.list(odefq), []);   } catch(e) { fcallback(false); return false; }   return true; }; 

how latest changes whithout knowing largestchangeid?

start 0 on first call. within response current largest change id, need store , use on next request. in code, materialise "resp.largestchangeid".


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -