initialize to 0 and optimize for it
This commit is contained in:
parent
611a5fb093
commit
64c16d88e7
2 changed files with 8 additions and 1 deletions
|
|
@ -1513,7 +1513,7 @@ const initWall = async () => {
|
||||||
user
|
user
|
||||||
.get(Key.WALL)
|
.get(Key.WALL)
|
||||||
.get(Key.NUM_OF_PAGES)
|
.get(Key.NUM_OF_PAGES)
|
||||||
.put(1, ack => {
|
.put(0, ack => {
|
||||||
if (ack.err) {
|
if (ack.err) {
|
||||||
rej(new Error(ack.err))
|
rej(new Error(ack.err))
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,13 @@ const getWallPage = async (page, publicKey) => {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (totalPages === 0) {
|
||||||
|
return {
|
||||||
|
count: 0,
|
||||||
|
posts: {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const actualPageIdx = page < 0 ? totalPages + page : page - 1
|
const actualPageIdx = page < 0 ? totalPages + page : page - 1
|
||||||
|
|
||||||
if (actualPageIdx > totalPages - 1) {
|
if (actualPageIdx > totalPages - 1) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue