diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index 15ed3f7de..c8a2df23c 100644 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -781,7 +781,7 @@ "moloch-period-voting": "Voting now.", "moloch-period-grace": "Grace period.", "moloch-period-abort": "Aborted.:", - "moloch-period-complete": "Aborted.", + "moloch-period-complete": "Completed.", "moloch-period-passed": "Passed.", "moloch-period-rejected": "Rejected.", "moloch-period-aborted": "Aborted.", diff --git a/imports/api/server/methods.js b/imports/api/server/methods.js index 22e6f8b26..af44339fd 100644 --- a/imports/api/server/methods.js +++ b/imports/api/server/methods.js @@ -333,9 +333,9 @@ Meteor.methods({ */ sync(lastTimestamp) { check(lastTimestamp, Date); - const feed = Contracts.find({ $or: [{ period: 'VOTING' }, { period: 'GRACE' }, { period: 'QUEUE' }, { period: 'PROCESS' }] }).fetch(); + const feed = Contracts.find({ $or: [{ period: 'COMPLETE' }, { period: 'VOTING' }, { period: 'GRACE' }, { period: 'QUEUE' }, { period: 'PROCESS' }] }).fetch(); - log(`{ method: 'sync', feed.length: '${feed.length}' }`); + log(`{ method: 'sync', feed.length: '${feed.length}', lastTimestamp: '${lastTimestamp}' }`); let newPeriod; let queueEnd; @@ -343,7 +343,8 @@ Meteor.methods({ newPeriod = feed[i].period; switch (feed[i].period) { case 'PROCESS': - if (lastTimestamp > feed[i].closing.graceCalendar && feed[i].processed) { + case 'COMPLETE': + if (lastTimestamp >= feed[i].closing.graceCalendar && feed[i].processed) { if (!feed[i].aborted) { newPeriod = 'COMPLETE'; } @@ -360,14 +361,14 @@ Meteor.methods({ } break; case 'VOTING': - if (lastTimestamp > feed[i].closing.calendar) { + if (lastTimestamp > feed[i].closing.calendar && !feed[i].processed) { newPeriod = 'GRACE'; } break; case 'QUEUE': default: queueEnd = parseInt(feed[i].timestamp.getTime() + feed[i].closing.periodDuration, 10); - if (lastTimestamp > queueEnd) { + if (lastTimestamp > queueEnd && !feed[i].processed) { newPeriod = 'VOTING'; } break; diff --git a/imports/startup/both/modules/metamask.js b/imports/startup/both/modules/metamask.js index 0b5f8959a..afa868bff 100644 --- a/imports/startup/both/modules/metamask.js +++ b/imports/startup/both/modules/metamask.js @@ -587,22 +587,16 @@ const _getLastTimestamp = async () => { if (!Session.get('blockTimes')) { await sync(); } - return await _getBlockHeight().then(async (resolved) => { - return await web3.eth.getBlock(resolved).then((res) => { - const timestamp = res.timestamp * 1000; - Session.set('lastTimestamp', timestamp); - Meteor.call('sync', new Date(timestamp), (error) => { - if (error) { - console.log(error); - } - }); - const blockTimes = Session.get('blockTimes'); - if (blockTimes && blockTimes.length > 0) { - return _.pluck(_.where(blockTimes, { collectiveId: defaults.ROOT }), 'timestamp'); + const blockTimes = Session.get('blockTimes'); + if (blockTimes && blockTimes.length > 0) { + const timestamp = _.pluck(_.where(blockTimes, { collectiveId: defaults.ROOT }), 'timestamp'); + Meteor.call('sync', new Date(timestamp[0]), (error) => { + if (error) { + console.log(error); } - return undefined; }); - }); + return timestamp; + } } return undefined; }; diff --git a/imports/startup/both/routes.js b/imports/startup/both/routes.js index 55a8fa5c4..1dc9b6991 100644 --- a/imports/startup/both/routes.js +++ b/imports/startup/both/routes.js @@ -131,7 +131,6 @@ Router.route('/', { loadingTemplate: 'load', onBeforeAction() { _reset(); - sync(); this.next(); }, data() { @@ -166,7 +165,6 @@ Router.route('/address/:username', { onBeforeAction() { Session.set('sidebarMenuSelectedId', 999); _reset(); - sync(); this.next(); }, data() { @@ -222,7 +220,6 @@ Router.route('/tx/:keyword', { onBeforeAction() { Session.set('sidebarMenuSelectedId', 999); _reset(); - sync(); this.next(); }, data() { diff --git a/imports/ui/templates/layout/sync.js b/imports/ui/templates/layout/sync.js index b7b10869e..3fd48942d 100644 --- a/imports/ui/templates/layout/sync.js +++ b/imports/ui/templates/layout/sync.js @@ -4,6 +4,7 @@ import { Meteor } from 'meteor/meteor'; import { Session } from 'meteor/session'; const _sync = async () => { + console.log('syncing....'); return await new Promise((resolve, reject) => { Meteor.call('getBlock', [], (error, result) => { if (error) { reject(error); } diff --git a/imports/ui/templates/widgets/feed/feedItem.js b/imports/ui/templates/widgets/feed/feedItem.js index 7b5da4ee2..fe82ed0dc 100644 --- a/imports/ui/templates/widgets/feed/feedItem.js +++ b/imports/ui/templates/widgets/feed/feedItem.js @@ -65,7 +65,7 @@ const _getProposalDescription = (title, onlyTitle) => { const json = JSON.parse(xmlDescription.json); if (json && json.description !== undefined) { const description = wrapURLs(json.description, true); - const html = `