mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-12 16:52:50 +00:00
Merge pull request #8727 from k-yle/local-storage-full
show an error if local storage is full
This commit is contained in:
@@ -589,6 +589,7 @@ en:
|
||||
offline: The OpenStreetMap API is offline. Your edits are safe locally. Please come back later.
|
||||
readonly: The OpenStreetMap API is currently read-only. You can continue editing, but must wait to save your changes.
|
||||
rateLimit: The OpenStreetMap API is limiting anonymous connections. You can fix this by logging in.
|
||||
local_storage_full: You have made too many edits to back up. Consider saving your changes now.
|
||||
retry: Retry
|
||||
commit:
|
||||
title: Upload to OpenStreetMap
|
||||
|
||||
2
dist/locales/en.min.json
vendored
2
dist/locales/en.min.json
vendored
File diff suppressed because one or more lines are too long
@@ -15,7 +15,7 @@ import {
|
||||
|
||||
|
||||
export function coreHistory(context) {
|
||||
var dispatch = d3_dispatch('reset', 'change', 'merge', 'restore', 'undone', 'redone');
|
||||
var dispatch = d3_dispatch('reset', 'change', 'merge', 'restore', 'undone', 'redone', 'storage_error');
|
||||
var lock = utilSessionMutex('lock');
|
||||
|
||||
// restorable if iD not open in another window/tab and a saved history exists in localStorage
|
||||
@@ -659,8 +659,9 @@ export function coreHistory(context) {
|
||||
if (lock.locked() &&
|
||||
// don't overwrite existing, unresolved changes
|
||||
!_hasUnresolvedRestorableChanges) {
|
||||
const success = prefs(getKey('saved_history'), history.toJSON() || null);
|
||||
|
||||
prefs(getKey('saved_history'), history.toJSON() || null);
|
||||
if (!success) dispatch.call('storage_error');
|
||||
}
|
||||
return history;
|
||||
},
|
||||
|
||||
@@ -16,18 +16,25 @@ _storage = _storage || (() => {
|
||||
// corePreferences is an interface for persisting basic key-value strings
|
||||
// within and between iD sessions on the same site.
|
||||
//
|
||||
/**
|
||||
* @param {string} k
|
||||
* @param {string?} v
|
||||
* @returns {boolean} true if the action succeeded
|
||||
*/
|
||||
function corePreferences(k, v) {
|
||||
|
||||
try {
|
||||
if (arguments.length === 1) return _storage.getItem(k);
|
||||
else if (v === null) _storage.removeItem(k);
|
||||
else _storage.setItem(k, v);
|
||||
return true;
|
||||
} catch (e) {
|
||||
/* eslint-disable no-console */
|
||||
if (typeof console !== 'undefined') {
|
||||
console.error('localStorage quota exceeded');
|
||||
}
|
||||
/* eslint-enable no-console */
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -69,6 +69,11 @@ export function uiStatus(context) {
|
||||
|
||||
osm.on('apiStatusChange.uiStatus', update);
|
||||
|
||||
context.history().on('storage_error', () => {
|
||||
selection.html(t.html('osm_api_status.message.local_storage_full'));
|
||||
selection.attr('class', 'api-status error');
|
||||
});
|
||||
|
||||
// reload the status periodically regardless of other factors
|
||||
window.setInterval(function() {
|
||||
osm.reloadApiStatus();
|
||||
|
||||
Reference in New Issue
Block a user