Fix Google Data isAuthorized check - fixes #3054 (#3612)

- adjust for new undefined return value of new cookies package
- add some error handling in case we think we're logged in, but really aren't
This commit is contained in:
Tom Morris 2021-02-11 13:50:10 -05:00 committed by GitHub
parent ff0b81e0f0
commit 8b459d69e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 17 deletions

View File

@ -35,7 +35,7 @@ var GdataExtension = {};
GdataExtension.isAuthorized = function() { GdataExtension.isAuthorized = function() {
// TODO: Unreliable - just means that we were authorized at one point // TODO: Unreliable - just means that we were authorized at one point
return Cookies.get('oauth2_token') !== null; return Cookies.get('oauth2_token') != null;
}; };
GdataExtension.showAuthorizationDialog = function(onAuthorized, onNotAuthorized) { GdataExtension.showAuthorizationDialog = function(onAuthorized, onNotAuthorized) {

View File

@ -128,10 +128,6 @@ Refine.GDataSourceUI.prototype._listDocuments = function() {
Refine.GDataSourceUI.prototype._renderDocuments = function(o) { Refine.GDataSourceUI.prototype._renderDocuments = function(o) {
var self = this; var self = this;
if (!o.documents) {
return;
}
this._elmts.listingContainer.empty(); this._elmts.listingContainer.empty();
var table = $( var table = $(
@ -186,17 +182,23 @@ Refine.GDataSourceUI.prototype._renderDocuments = function(o) {
.appendTo(td); .appendTo(td);
}; };
var docs = o.documents; if (o.status === 'error') {
$.each(docs, function() { // We're probably not logged in, even though we thought we were. Show signin page
this.updatedDate = (this.updated) ? new Date(this.updated) : null; this._body.find('.gdata-page').hide();
this.updatedDateTime = (this.updatedDate) ? this.updatedDate.getTime() : 0; this._elmts.signinPage.show();
}); } else {
docs.sort(function(a, b) { return b.updatedDateTime - a.updatedDateTime; }); var docs = o.documents;
$.each(docs, function() {
for (var i = 0; i < docs.length; i++) { this.updatedDate = (this.updated) ? new Date(this.updated) : null;
renderDocument(docs[i]); this.updatedDateTime = (this.updatedDate) ? this.updatedDate.getTime() : 0;
});
docs.sort(function(a, b) { return b.updatedDateTime - a.updatedDateTime; });
for (var i = 0; i < docs.length; i++) {
renderDocument(docs[i]);
}
this._body.find('.gdata-page').hide();
this._elmts.listingPage.show();
} }
this._body.find('.gdata-page').hide();
this._elmts.listingPage.show();
}; };