From 369fbfb611c6fee284d2d51736b5667d4e87453e Mon Sep 17 00:00:00 2001 From: Debora Crescenzo Date: Mon, 16 Feb 2026 16:10:59 +0000 Subject: [PATCH] MT#64432 Refactor updateSharedValue and getList * fix updateSharedValue to be less flacky: it was using the reference of row, mutated, to make the backend request. It now use a value stored in a variable. * amend getList to make sure we pass the default page (1) when looking for all rows with api v1. Change-Id: Ia8c4fcb1547c16a6a3e862f864fbc5aecda3e065 (cherry picked from commit 9db53bc3cec1177f0a1854402fa2c96742ca0fdc) (cherry picked from commit fd4e43ef8e7a934a3768bbac55b0a1157f2f0c6e) --- src/api/common.js | 1 + src/api/subscriber-phonebook.js | 10 +++++----- src/store/subscriber-phonebook.js | 5 +++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/api/common.js b/src/api/common.js index 96da240a..cee05f9c 100644 --- a/src/api/common.js +++ b/src/api/common.js @@ -94,6 +94,7 @@ export async function getList (options) { }, options) if (requestConfig.all === true) { requestConfig.params.rows = LIST_ALL_ROWS + requestConfig.params.page = LIST_DEFAULT_PAGE } if (requestConfig.resource !== undefined) { requestConfig.path = `api/${requestConfig.resource}/` diff --git a/src/api/subscriber-phonebook.js b/src/api/subscriber-phonebook.js index 79a50dae..5e725441 100644 --- a/src/api/subscriber-phonebook.js +++ b/src/api/subscriber-phonebook.js @@ -32,16 +32,16 @@ export async function getEntryById (subscriberId, id) { }) } -export async function getPhonebook (options) { +export async function getPhonebook (data) { return getList({ - path: `api/v2/subscribers/${options.subscriber_id}/phonebook`, - params: options + path: `api/v2/subscribers/${data.subscriber_id}/phonebook`, + params: data }) } -export function setSharedValue (subscriberId, phonebookId, value) { +export function setSharedValue (data, value) { return patchReplace({ - path: `api/v2/subscribers/${subscriberId}/phonebook/${phonebookId}`, + path: `api/v2/subscribers/${data.subscriber_id}/phonebook/${data.id}`, fieldPath: 'shared', value }) diff --git a/src/store/subscriber-phonebook.js b/src/store/subscriber-phonebook.js index 6e19cbe4..0c13d879 100644 --- a/src/store/subscriber-phonebook.js +++ b/src/store/subscriber-phonebook.js @@ -83,8 +83,9 @@ export default { await updateEntry(data) }, async updateSharedValue (context, row) { - context.commit('setSharedValue', { id: row.id, value: !row.shared }) - await setSharedValue(row.subscriber_id, row.id, row.shared) + const newValue = !row.shared + context.commit('setSharedValue', { id: row.id, value: newValue }) + await setSharedValue(row, newValue) } } }