Only set diffmode-historical user option when it has changed

Bug: T290703
Change-Id: I289e0c20db9235a432f7f49a425328ab617d57f3
This commit is contained in:
Ed Sanders 2021-12-19 23:21:50 +00:00 committed by Esanders
parent 717b5cf534
commit b57fe3e8ba

View file

@ -45,9 +45,11 @@
mode = item.getData();
var isVisual = mode === 'visual';
mw.user.options.set( 'visualeditor-diffmode-historical', mode );
// Same as ve.init.target.getLocalApi()
new mw.Api().saveOption( 'visualeditor-diffmode-historical', mode );
if ( mode !== mw.user.options.get( 'visualeditor-diffmode-historical' ) ) {
mw.user.options.set( 'visualeditor-diffmode-historical', mode );
// Same as ve.init.target.getLocalApi()
new mw.Api().saveOption( 'visualeditor-diffmode-historical', mode );
}
$visualDiffContainer.toggleClass( 'oo-ui-element-hidden', !isVisual );
$wikitextDiffBody.toggleClass( 'oo-ui-element-hidden', isVisual );
$revSlider.toggleClass( 've-init-mw-diffPage-revSlider-visual', isVisual );