From 2b4b256d4eb79b82e356f2e3f6ee514456302f6c Mon Sep 17 00:00:00 2001 From: Jon Robson Date: Mon, 12 Feb 2024 08:52:46 -0800 Subject: [PATCH] Callback should only be run after completion of API save request Bug: T357212 Change-Id: Icee40b8f9b642e516583998f98cf0072a9e37dee --- .../skins.vector.clientPreferences/clientPreferences.js | 5 +++-- resources/skins.vector.clientPreferences/package.json | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/resources/skins.vector.clientPreferences/clientPreferences.js b/resources/skins.vector.clientPreferences/clientPreferences.js index 92dfe4e55..0fdfc07c4 100644 --- a/resources/skins.vector.clientPreferences/clientPreferences.js +++ b/resources/skins.vector.clientPreferences/clientPreferences.js @@ -56,8 +56,9 @@ function toggleDocClassAndSave( featureName, value, config ) { // Ideally this should be taken care of via a single core helper function. mw.util.debounce( function () { api = api || new mw.Api(); - api.saveOption( pref.preferenceKey, value ); - callback(); + api.saveOption( pref.preferenceKey, value ).then( () => { + callback(); + } ); }, 100 )(); // END FIXME. } else { diff --git a/resources/skins.vector.clientPreferences/package.json b/resources/skins.vector.clientPreferences/package.json index 123098d61..ac6efa4b2 100644 --- a/resources/skins.vector.clientPreferences/package.json +++ b/resources/skins.vector.clientPreferences/package.json @@ -1,6 +1,6 @@ { "name": "@wikimedia/mediawiki.skins.clientpreferences", - "version": "1.1.0", + "version": "1.1.1", "private": false, "main": "clientPreferences.js", "author": "Wikimedia Foundation",