Expire saved changeset comment older than 2 days

(closes #3947)
This commit is contained in:
Bryan Housel
2017-04-21 23:01:32 -04:00
parent 92d6d51724
commit a5554cf3b0
2 changed files with 19 additions and 4 deletions

View File

@@ -75,8 +75,13 @@ export function behaviorHash(context) {
if (window.location.hash) {
var q = utilStringQs(window.location.hash.substring(1));
if (q.id) context.zoomToEntity(q.id.split(',')[0], !q.map);
if (q.comment) context.storage('comment', q.comment);
if (q.id) {
context.zoomToEntity(q.id.split(',')[0], !q.map);
}
if (q.comment) {
context.storage('comment', q.comment);
context.storage('commentDate', Date.now());
}
hashchange();
if (q.map) hash.hadHash = true;
}

View File

@@ -41,7 +41,16 @@ export function uiCommit(context) {
var changes = context.history().changes(),
summary = context.history().difference().summary(),
rawTagEditor = uiRawTagEditor(context).on('change', changeTags);
rawTagEditor = uiRawTagEditor(context).on('change', changeTags),
comment = context.storage('comment') || '',
commentDate = +context.storage('commentDate') || 0,
currDate = Date.now(),
cutoff = 2 * 86400 * 1000; // 2 days
// expire the stored comment if it is too old - #3947
if (commentDate > currDate || currDate - commentDate > cutoff) {
comment = '';
}
selection
.append('div')
@@ -67,11 +76,12 @@ export function uiCommit(context) {
.attr('class', 'commit-form-comment')
.attr('placeholder', t('commit.description_placeholder'))
.attr('maxlength', 255)
.property('value', context.storage('comment') || '')
.property('value', comment)
.on('input.save', change(true))
.on('change.save', change())
.on('blur.save', function() {
context.storage('comment', this.value);
context.storage('commentDate', Date.now());
});