From 5f79c74866d9c9acd6b9cbeefafed58172428e56 Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Tue, 12 Dec 2023 13:53:46 +0530 Subject: [PATCH] fix: LIMIT must not be negative issue of tokens api --- packages/nc-gui/components/account/Token.vue | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/nc-gui/components/account/Token.vue b/packages/nc-gui/components/account/Token.vue index 6928a30e70..1290ec4730 100644 --- a/packages/nc-gui/components/account/Token.vue +++ b/packages/nc-gui/components/account/Token.vue @@ -77,6 +77,10 @@ const loadTokens = async (page = currentPage.value, limit = currentLimit.value) pagination.pageSize = 10 tokens.value = response.list as IApiTokenInfo[] + + if (!allTokens.value.length) { + await loadAllTokens(pagination.total) + } } catch (e: any) { message.error(await extractSdkResponseErrorMsg(e)) } @@ -85,11 +89,11 @@ const loadTokens = async (page = currentPage.value, limit = currentLimit.value) loadTokens() // To set default next token name we should need to fetch all token first -const loadAllTokens = async () => { +const loadAllTokens = async (limit = pagination.total) => { try { const response: any = await api.orgTokens.list({ query: { - limit: -1, + limit: limit, }, } as RequestParams) if (!response) return @@ -101,8 +105,6 @@ const loadAllTokens = async () => { } } -loadAllTokens() - // This will updated allTokens local value instead of fetching all tokens on each operation (add|delete) const updateAllTokens = (type: 'delete' | 'add', token: IApiTokenInfo) => { switch (type) { @@ -130,7 +132,7 @@ const deleteToken = async (token: string): Promise => { await loadTokens() updateAllTokens('delete', { - token: token, + token, } as IApiTokenInfo) if (!tokens.value.length && currentPage.value !== 1) {