File size: 814 Bytes
5893f8f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | import { Template } from 'meteor/templating'
import { Translations } from '/imports/api/indexDB'
import { FlowRouter } from 'meteor/ostrio:flow-router-extra'
import './translations.html'
const nextTranslation = (id) => {
let sample = _.sample(Translations.find({
_id: {
$ne: id
},
status: 'new',
'votes.userId': {
$ne: Meteor.userId()
}
}).fetch())
setTimeout(() => {
if (!sample) {
FlowRouter.go('/moderator/translations')
} else {
FlowRouter.go(`/moderator/translations/${sample._id}`)
}
}, 300)
}
export { nextTranslation }
Template.modTranslations.onCreated(function() {
this.autorun(() => {
SubsCache.subscribe('translations')
})
})
Template.modTranslations.helpers({
nextTranslation: () => nextTranslation()
}) |