mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-22 09:46:30 -05:00
Fix history time should save in UNIX timestamp to avoid time offset issue
This commit is contained in:
parent
4188d8f942
commit
c06b2f4838
2 changed files with 8 additions and 7 deletions
|
@ -123,7 +123,7 @@ function updateHistory(userid, noteId, document) {
|
||||||
var noteInfo = models.Note.parseNoteInfo(document);
|
var noteInfo = models.Note.parseNoteInfo(document);
|
||||||
noteHistory.id = noteId;
|
noteHistory.id = noteId;
|
||||||
noteHistory.text = noteInfo.title;
|
noteHistory.text = noteInfo.title;
|
||||||
noteHistory.time = moment().format('MMMM Do YYYY, h:mm:ss a');
|
noteHistory.time = moment().valueOf();
|
||||||
noteHistory.tags = noteInfo.tags;
|
noteHistory.tags = noteInfo.tags;
|
||||||
caches[userid].isDirty = true;
|
caches[userid].isDirty = true;
|
||||||
});
|
});
|
||||||
|
|
|
@ -96,8 +96,8 @@ function clearDuplicatedHistory(notehistory) {
|
||||||
var id = notehistory[i].id.replace(/\=+$/, '');
|
var id = notehistory[i].id.replace(/\=+$/, '');
|
||||||
var newId = newnotehistory[j].id.replace(/\=+$/, '');
|
var newId = newnotehistory[j].id.replace(/\=+$/, '');
|
||||||
if (id == newId || notehistory[i].id == newnotehistory[j].id || !notehistory[i].id || !newnotehistory[j].id) {
|
if (id == newId || notehistory[i].id == newnotehistory[j].id || !notehistory[i].id || !newnotehistory[j].id) {
|
||||||
var time = moment(notehistory[i].time, 'MMMM Do YYYY, h:mm:ss a');
|
var time = (typeof notehistory[i].time === 'number' ? moment(notehistory[i].time) : moment(notehistory[i].time, 'MMMM Do YYYY, h:mm:ss a'));
|
||||||
var newTime = moment(newnotehistory[j].time, 'MMMM Do YYYY, h:mm:ss a');
|
var newTime = (typeof newnotehistory[i].time === 'number' ? moment(newnotehistory[i].time) : moment(newnotehistory[i].time, 'MMMM Do YYYY, h:mm:ss a'));
|
||||||
if(time >= newTime) {
|
if(time >= newTime) {
|
||||||
newnotehistory[j] = notehistory[i];
|
newnotehistory[j] = notehistory[i];
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ function renderHistory(view) {
|
||||||
return {
|
return {
|
||||||
id: id,
|
id: id,
|
||||||
text: title,
|
text: title,
|
||||||
time: moment().format('MMMM Do YYYY, h:mm:ss a'),
|
time: moment().valueOf(),
|
||||||
tags: tags
|
tags: tags
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -358,9 +358,10 @@ function parseToHistory(list, notehistory, callback) {
|
||||||
else if (notehistory && notehistory.length > 0) {
|
else if (notehistory && notehistory.length > 0) {
|
||||||
for (var i = 0; i < notehistory.length; i++) {
|
for (var i = 0; i < notehistory.length; i++) {
|
||||||
//parse time to timestamp and fromNow
|
//parse time to timestamp and fromNow
|
||||||
notehistory[i].timestamp = moment(notehistory[i].time, 'MMMM Do YYYY, h:mm:ss a').valueOf();
|
var timestamp = (typeof notehistory[i].time === 'number' ? moment(notehistory[i].time) : moment(notehistory[i].time, 'MMMM Do YYYY, h:mm:ss a'));
|
||||||
notehistory[i].fromNow = moment(notehistory[i].time, 'MMMM Do YYYY, h:mm:ss a').fromNow();
|
notehistory[i].timestamp = timestamp.valueOf();
|
||||||
notehistory[i].time = moment(notehistory[i].time, 'MMMM Do YYYY, h:mm:ss a').format('llll');
|
notehistory[i].fromNow = timestamp.fromNow();
|
||||||
|
notehistory[i].time = timestamp.format('llll');
|
||||||
if (notehistory[i].id && list.get('id', notehistory[i].id).length == 0)
|
if (notehistory[i].id && list.get('id', notehistory[i].id).length == 0)
|
||||||
list.add(notehistory[i]);
|
list.add(notehistory[i]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue