Skip to content

GData initialization - Cannot read property 'sort' of undefined #6

@tfmorris

Description

@tfmorris

It looks like the Google Data importer is attempting to initialize its list of documents at startup even if it isn't visible or being used.

index-bundle.js:37619 Uncaught TypeError: Cannot read property 'sort' of undefined
    at Refine.GDataSourceUI._renderDocuments (index-bundle.js:37619)
    at Object.success (index-bundle.js:37550)
    at fire (index-bundle.js:3234)
    at Object.fireWith [as resolveWith] (index-bundle.js:3364)
    at done (index-bundle.js:9842)
    at XMLHttpRequest.callback (index-bundle.js:10313)

The offending code is

  var docs = o.documents;
  ...
  docs.sort(function(a, b) { return b.updatedDateTime -  a.updatedDateTime; });

Where the contents of o are an error message saying "Not authorized".

It's wasteful to do this initialization at every startup when it's rarely going to be needed. It should be deferred until the importer tab is selected.

It looks like part of the problem is that this test isn't failing:

  if (GdataExtension.isAuthorized()) {
    this._listDocuments();
  }

but it probably shouldn't even be executing that.

Originally posted by @tfmorris in OpenRefine/OpenRefine#3054 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions