Activities links generate 2 http requests; bug with assignment

Issue #108 new
David B created an issue

Hi,
With navJS enabled, the links in the tiles generate 2 http requests.
It 's a problem especially with work's (assignment) activity because sometimes the intial flag "latest" is wrong due of this double call.
The function get_user_submission can be called twice (https://github.com/moodle/moodle/blob/MOODLE_39_STABLE/mod/assign/locallib.php)

A click on a link :

[19/May/2022:17:55:54 +0200] "GET /mod/assign/view.php?id=1297 HTTP/1.1" 200

[19/May/2022:17:55:54 +0200] "GET /mod/assign/view.php?id=1297 HTTP/1.1" 200

…………………….

[19/May/2022:18:15:10 +0200] "GET /mod/folder/view.php?id=1296 HTTP/1.1" 200 12247

[19/May/2022:18:15:10 +0200] "GET /mod/folder/view.php?id=1296 HTTP/1.1" 200 12247

In the template : https://bitbucket.org/dw8/moodle-format_tiles/src/master/templates/course_module.mustache :

<a href="{{url}}"{{#clickable}} {{#clickable}}{{#isEmbeddedResource}} data-action="launch-tiles-resource-modal"{{/isEmbeddedResource}}{{#isEmbeddedModule}}
   data-action="launch-tiles-module-modal"{{/isEmbeddedModule}}{{/clickable}}{{#onclick}} onclick="{{onclick}}"{{/onclick}}{{/clickable}}
   data-title="{{{modtitle}}}" class="instancename {{{extraclasses}}}" data-action="launch-tiles-{{launchtype}}">
   <img src="{{iconurl}}" class="iconlarge activityicon" alt="{{{modtitle}}}"
      role="presentation">
   <span class="activitytitle">{{{modtitle}}}</span>
</a>

data-action="launch-tiles-{{launchtype}} is the problem with the line 4 of the extract from this JS : https://bitbucket.org/dw8/moodle-format_tiles/src/master/amd/src/course.js

pageContent.on(Event.CLICK, Selector.LAUNCH_STANDARD, function(e) {
    var clickedLk = $(e.currentTarget);
    if (clickedLk.attr("href") !== undefined) {
          window.location = clickedLk.attr("href");
    } else if (clickedLk.find('a').attr("href") !== undefined) {
        window.location = clickedLk.find('a').attr("href");
    }
});

I think, “data-action=”launch-tiles-{{launchtype}}”” is not useful here. Deleting this attribut, solves the problem and only one http request is called.