Fix "Next" button ordering
This commit is contained in:
parent
820e905743
commit
64aea6e62d
@ -107,13 +107,10 @@ export function FocusView(vm, params) {
|
||||
}
|
||||
doc(await ImageType.find(_id));
|
||||
|
||||
Promise.all([
|
||||
ImageType.find({ _id: { $lt: _id } }, { limit: 2, sort: [{ _id: 'desc' }] }),
|
||||
ImageType.find({ _id: { $gt: _id } }, { limit: 2 })
|
||||
]).then(([prev, next]) => {
|
||||
nextLink(next.length ? router.href('focus', { id: next[0]._id }) : null);
|
||||
prevLink(prev.length ? router.href('focus', { id: prev[0]._id }) : null);
|
||||
});
|
||||
const n = await ImageType.next(_id);
|
||||
nextLink(n.length ? router.href('focus', { id: n[0].id }) : null);
|
||||
const p = await ImageType.next(_id, true);
|
||||
prevLink(p.length ? router.href('focus', { id: p[0].id }) : null);
|
||||
})
|
||||
],
|
||||
true
|
||||
|
||||
@ -148,6 +148,17 @@ export function PouchORM(PouchDB) {
|
||||
}
|
||||
}
|
||||
|
||||
async function next(key, previous = false, limit = 1, inclusive = false) {
|
||||
const res = await _db.allDocs({
|
||||
startkey: key,
|
||||
descending: previous,
|
||||
sort: ['id'],
|
||||
skip: inclusive ? 0 : 1,
|
||||
limit
|
||||
});
|
||||
return res.rows;
|
||||
}
|
||||
|
||||
Object.defineProperties(cls.prototype, {
|
||||
_name: { value: name },
|
||||
_prefix: { value: prefix },
|
||||
@ -159,6 +170,7 @@ export function PouchORM(PouchDB) {
|
||||
Object.defineProperties(cls, {
|
||||
getOrCreate: { value: getOrCreate },
|
||||
find: { value: find },
|
||||
next: { value: next },
|
||||
delete: { value: _delete },
|
||||
subscribe: { value: watch },
|
||||
db: { value: _db },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user