Skip to content

Commit

Permalink
[offline] On desktop /my/planned don’t cache reports automatically
Browse files Browse the repository at this point in the history
Desktop users are presumably less likely to find themselves offline,
so it doesn't make sense to cache all reports in the shortlist
automatically. This commit adds a link to the bottom of the report list
on the desktop version of the /my/planned page that allows users to kick
off the caching process manually.

Behaviour on mobile is unchanged.
  • Loading branch information
davea committed Oct 7, 2024
1 parent 8053db7 commit b2c713e
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .cypress/cypress/integration/borsetshire.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ it('logs in without fuss', function() {
cy.contains('Inspector').click();
cy.url().should('include', '/my/planned');
// Wait for offline stuff, which can take time
cy.contains('Save to this device for offline use').should('be.visible').click();
cy.get('.top_banner--offline', { timeout: 10000 }).contains('Reports saved offline', { timeout: 10000 });
cy.contains('Save to this device for offline use').should('not.be.visible');

cy.contains('Your account').click();
cy.contains('Sign out').click();
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
- Provide ResultSet fallback translation in lookup.
- Mark non-Open311 updates as processed by daemon. #4552
- Inspector/planned offline report caching now fetches URLs sequentially, not in parallel.
- Desktop browsers won't automatically cache reports offline when visiting /my/planned.
- Changes:
- Switch to OpenStreetMap for reverse geocoding. #4444
- Convert all uploaded images to JPEGs.
Expand Down
6 changes: 6 additions & 0 deletions templates/web/base/my/planned.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ <h1>[% loc('Your shortlist') %]</h1>
<div id="js-reports-list">
[% INCLUDE 'my/_problem-list.html' shortlist = 1 %]
</div>
<div class="shadow-wrap hidden-nojs">
<ul id="key-tools">
<li><a class="offline js-cache-reports" href="#">[% loc("Save to this device for offline use") %]</a></li>
</ul>
</div>

</section>

</div>
Expand Down
4 changes: 4 additions & 0 deletions web/cobrands/fixmystreet/images/cloud-download.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 12 additions & 2 deletions web/cobrands/fixmystreet/offline.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,19 @@ if ($('#offline_list').length) {
} else {
fixmystreet.offlineBanner.make(false);

// On /my/planned, when online, cache all shortlisted
// On /my/planned, when online, cache all shortlisted automatically on mobile.
// On desktop, show a button to cache them.
if (location.pathname === '/my/planned') {
fixmystreet.offline.updateCachedReports();
if ($("html").hasClass("mobile")) {
$(".js-cache-reports").closest(".shadow-wrap").hide();
fixmystreet.offline.updateCachedReports();
} else {
$(".js-cache-reports").on("click", function(e) {
e.preventDefault();
$(".js-cache-reports").closest(".shadow-wrap").hide();
fixmystreet.offline.updateCachedReports();
});
}
}

// Catch additions and removals from the shortlist
Expand Down
6 changes: 6 additions & 0 deletions web/cobrands/sass/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,12 @@ html.mobile.js-nav-open #js-menu-open-modal {
&.chevron:after {
background-position: flip(-16px 0, 0 0);
}

&.offline:after {
background-size: 16px 16px;
background-position: 0 0;
background-image: url("/cobrands/fixmystreet/images/cloud-download.svg");
}
}

.sub-area-item {
Expand Down

0 comments on commit b2c713e

Please sign in to comment.