Uploaded image for project: 'Moodle app'
  1. Moodle app
  2. MOBILE-1592

Check if a WS call is running and return the ongoing promise if it is

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Run the following code in console and check that both "Success" are written to console. Go to Network tab and check that only 1 request was done.

      var $mmSite = angular.element(document.querySelector('[ng-app]')).injector().get('$mmSite'),
          data = {userid: $mmSite.getUserId()},
          preSets = {getFromCache: false};
       
      $mmSite.read('core_enrol_get_users_courses', data, preSets).then(function(courses) {
          console.log('Success', courses.length);
      });
      $mmSite.read('core_enrol_get_users_courses', data, preSets).then(function(courses) {
          console.log('Success', courses.length);
      });
      

      Execute it again to see the request is done again.

      Run the following code in console and check that two heads are retrieved only once with different result:

      var $mmWS = angular.element(document.querySelector('[ng-app]')).injector().get('$mmWS');
      $mmWS.getRemoteFileSize('http://i.telegraph.co.uk/multimedia/archive/03589/Wellcome_Image_Awa_3589699k.jpg').then(function(data) {
          console.log('FileSize ' + data);
      });
      $mmWS.getRemoteFileMimeType('http://i.telegraph.co.uk/multimedia/archive/03589/Wellcome_Image_Awa_3589699k.jpg').then(function(data) {
          console.log('MimeType ' + data);
      });
      

      Show
      Run the following code in console and check that both "Success" are written to console. Go to Network tab and check that only 1 request was done. var $mmSite = angular.element(document.querySelector('[ng-app]')).injector().get('$mmSite'), data = {userid: $mmSite.getUserId()}, preSets = {getFromCache: false};   $mmSite.read('core_enrol_get_users_courses', data, preSets).then(function(courses) { console.log('Success', courses.length); }); $mmSite.read('core_enrol_get_users_courses', data, preSets).then(function(courses) { console.log('Success', courses.length); }); Execute it again to see the request is done again. Run the following code in console and check that two heads are retrieved only once with different result: var $mmWS = angular.element(document.querySelector('[ng-app]')).injector().get('$mmWS'); $mmWS.getRemoteFileSize('http://i.telegraph.co.uk/multimedia/archive/03589/Wellcome_Image_Awa_3589699k.jpg').then(function(data) { console.log('FileSize ' + data); }); $mmWS.getRemoteFileMimeType('http://i.telegraph.co.uk/multimedia/archive/03589/Wellcome_Image_Awa_3589699k.jpg').then(function(data) { console.log('MimeType ' + data); });
    • Difficulty:
      Moderate
    • Affected Branches:
      MOODLE_31_STABLE
    • Fixed Branches:
      MOODLE_31_STABLE
    • Issue size:
      Medium

      Description

      If the a WS call with same arguments is called twice the mmWS library will check it twice.

      We should implement a ongoing promises list and return it instead of launch it again.

        Attachments

          Activity

            People

            • Assignee:
              pferre22 Pau Ferrer
              Reporter:
              pferre22 Pau Ferrer
              Peer reviewer:
              Dani Palou
              Integrator:
              Juan Leyva
              Tester:
              Juan Leyva
              Participants:
              Component watchers:
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                27/Jul/16

                Time Tracking

                Estimated:
                Original Estimate - 3 days, 1 hour, 30 minutes
                3d 1h 30m
                Remaining:
                0m
                Logged:
                Time Not Required
                Not Specified