v1.18.x
Julian Lam 5 years ago
parent cdf81159df
commit b3115ea813

@ -44,7 +44,7 @@ define('forum/topic/diffs', ['forum/topic/images', 'benchpress', 'translator'],
selectEl.on('change', function () { selectEl.on('change', function () {
Diffs.load(pid, this.value, postContainer); Diffs.load(pid, this.value, postContainer);
revertEl.prop('disabled', data.timestamps.indexOf(this.value) === -1); revertEl.prop('disabled', data.timestamps.indexOf(this.value) === 0);
}); });
revertEl.on('click', function () { revertEl.on('click', function () {

@ -24,7 +24,7 @@ module.exports = function (Posts) {
Diffs.get = async function (pid, since) { Diffs.get = async function (pid, since) {
const timestamps = await Diffs.list(pid); const timestamps = await Diffs.list(pid);
// Pass those made after `since`, and create keys // Pass those made after `since`, and create keys
const keys = timestamps.filter(t => (parseInt(t, 10) || 0) >= since) const keys = timestamps.filter(t => (parseInt(t, 10) || 0) > since)
.map(t => 'diff:' + pid + '.' + t); .map(t => 'diff:' + pid + '.' + t);
return await db.getObjects(keys); return await db.getObjects(keys);
}; };

@ -10,7 +10,8 @@ module.exports = function (SocketPosts) {
const timestamps = await posts.diffs.list(data.pid); const timestamps = await posts.diffs.list(data.pid);
const cid = await posts.getCidByPid(data.pid); const cid = await posts.getCidByPid(data.pid);
const canEdit = await privileges.categories.can('edit', cid, socket.uid); const canEdit = await privileges.categories.can('edit', cid, socket.uid);
timestamps.unshift(Date.now()); const postTime = await posts.getPostField(data.pid, 'timestamp');
timestamps.push(postTime);
return { return {
timestamps: timestamps, timestamps: timestamps,
editable: canEdit, editable: canEdit,

Loading…
Cancel
Save