fix next/prev selection on same datetime events
This commit is contained in:
@@ -145,21 +145,35 @@ const eventController = {
|
|||||||
const next = await Event.findOne({
|
const next = await Event.findOne({
|
||||||
attributes: ['id', 'slug'],
|
attributes: ['id', 'slug'],
|
||||||
where: {
|
where: {
|
||||||
|
id: { [Op.not]: event.id },
|
||||||
is_visible: true,
|
is_visible: true,
|
||||||
recurrent: null,
|
recurrent: null,
|
||||||
start_datetime: { [Op.gt]: event.start_datetime }
|
[Op.or]: [
|
||||||
|
{ start_datetime: { [Op.gt]: event.start_datetime } },
|
||||||
|
{
|
||||||
|
start_datetime: event.start_datetime,
|
||||||
|
id: { [Op.gt]: event.id }
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
order: [['start_datetime', 'ASC']]
|
order: [['start_datetime', 'ASC'], ['id', 'ASC']]
|
||||||
})
|
})
|
||||||
|
|
||||||
const prev = await Event.findOne({
|
const prev = await Event.findOne({
|
||||||
attributes: ['id', 'slug'],
|
attributes: ['id', 'slug'],
|
||||||
where: {
|
where: {
|
||||||
is_visible: true,
|
is_visible: true,
|
||||||
|
id: { [Op.not]: event.id },
|
||||||
recurrent: null,
|
recurrent: null,
|
||||||
start_datetime: { [Op.lt]: event.start_datetime }
|
[Op.or]: [
|
||||||
|
{ start_datetime: { [Op.lt]: event.start_datetime } },
|
||||||
|
{
|
||||||
|
start_datetime: event.start_datetime,
|
||||||
|
id: { [Op.lt]: event.id }
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
order: [['start_datetime', 'DESC']]
|
order: [['start_datetime', 'DESC'], ['id', 'DESC']]
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO: also check if event is mine
|
// TODO: also check if event is mine
|
||||||
|
|||||||
Reference in New Issue
Block a user