fix the pagination error display

This commit is contained in:
Son 2021-11-19 18:30:36 +01:00
parent d2ed9337f1
commit b2c31ef658
2 changed files with 16 additions and 2 deletions

View File

@ -145,6 +145,8 @@ def get_alias_infos_with_pagination_v3(
alias_filter=None,
mailbox_id=None,
directory_id=None,
page_limit=PAGE_LIMIT,
page_size=PAGE_LIMIT,
) -> [AliasInfo]:
q = construct_alias_query(user)
@ -199,7 +201,7 @@ def get_alias_infos_with_pagination_v3(
q = q.order_by(Alias.pinned.desc())
q = q.order_by(latest_activity.desc())
q = list(q.limit(PAGE_LIMIT).offset(page_id * PAGE_LIMIT))
q = list(q.limit(page_limit).offset(page_id * page_size))
ret = []
for alias, contact, email_log, custom_domain, nb_reply, nb_blocked, nb_forward in q:

View File

@ -163,7 +163,19 @@ def index():
alias_infos = get_alias_infos_with_pagination_v3(
current_user, page, query, sort, alias_filter, mailbox_id, directory_id
)
last_page = len(alias_infos) < PAGE_LIMIT
# to know whether there's alias on the next page
next_page_alias = get_alias_infos_with_pagination_v3(
current_user,
page + 1, # next page
query,
sort,
alias_filter,
mailbox_id,
directory_id,
page_limit=1, # only load 1 alias
)
last_page = len(next_page_alias) == 0
# add highlighted alias in case it's not included
if highlight_alias_id and highlight_alias_id not in [