@@ -23,15 +23,16 @@ import * as CustomBackgroundFilter from "../elements/custom-background-filter";
2323import {
2424 ConfigValue ,
2525 CustomBackgroundSchema ,
26+ CustomLayoutFluid ,
2627 FunboxName ,
2728} from "@monkeytype/contracts/schemas/configs" ;
2829import { getAllFunboxes , checkCompatibility } from "@monkeytype/funbox" ;
2930import { getActiveFunboxNames } from "../test/funbox/list" ;
3031import { SnapshotPreset } from "../constants/default-snapshot" ;
3132import { LayoutsList } from "../constants/layouts" ;
3233import { DataArrayPartial , Optgroup } from "slim-select/store" ;
33- import { areUnsortedArraysEqual } from "../utils/arrays" ;
3434import { tryCatch } from "@monkeytype/util/trycatch" ;
35+ import { areSortedArraysEqual , areUnsortedArraysEqual } from "../utils/arrays" ;
3536
3637type SettingsGroups < T extends ConfigValue > = Record < string , SettingsGroup < T > > ;
3738
@@ -690,8 +691,13 @@ async function fillSettingsPage(): Promise<void> {
690691 settings : { keepOrder : true } ,
691692 events : {
692693 afterChange : ( newVal ) : void => {
693- const customLayoutfluid = newVal . map ( ( it ) => it . value ) . join ( "#" ) ;
694- if ( customLayoutfluid !== Config . customLayoutfluid ) {
694+ const customLayoutfluid = newVal . map (
695+ ( it ) => it . value
696+ ) as CustomLayoutFluid ;
697+ //checking equal with order, because customLayoutfluid is ordered
698+ if (
699+ ! areSortedArraysEqual ( customLayoutfluid , Config . customLayoutfluid )
700+ ) {
695701 void UpdateConfig . setCustomLayoutfluid ( customLayoutfluid ) ;
696702 }
697703 } ,
@@ -706,6 +712,7 @@ async function fillSettingsPage(): Promise<void> {
706712 events : {
707713 afterChange : ( newVal ) : void => {
708714 const customPolyglot = newVal . map ( ( it ) => it . value ) ;
715+ //checking equal without order, because customPolyglot is not ordered
709716 if ( ! areUnsortedArraysEqual ( customPolyglot , Config . customPolyglot ) ) {
710717 void UpdateConfig . setCustomPolyglot ( customPolyglot ) ;
711718 }
@@ -914,14 +921,23 @@ export async function update(groupUpdate = true): Promise<void> {
914921
915922 if (
916923 customLayoutFluidSelect !== undefined &&
917- customLayoutFluidSelect . getSelected ( ) . join ( "#" ) !== Config . customLayoutfluid
924+ //checking equal with order, because customLayoutFluid is ordered
925+ ! areSortedArraysEqual (
926+ customLayoutFluidSelect . getSelected ( ) ,
927+ Config . customLayoutfluid
928+ )
918929 ) {
930+ //replace the data because the data is ordered. do not use setSelected
919931 customLayoutFluidSelect . setData ( getLayoutfluidDropdownData ( ) ) ;
920932 }
921933
922934 if (
923935 customPolyglotSelect !== undefined &&
924- customPolyglotSelect . getSelected ( ) !== Config . customPolyglot
936+ //checking equal without order, because customPolyglot is not ordered
937+ ! areUnsortedArraysEqual (
938+ customPolyglotSelect . getSelected ( ) ,
939+ Config . customPolyglot
940+ )
925941 ) {
926942 customPolyglotSelect . setSelected ( Config . customPolyglot ) ;
927943 }
@@ -1391,7 +1407,7 @@ function getLanguageDropdownData(
13911407}
13921408
13931409function getLayoutfluidDropdownData ( ) : DataArrayPartial {
1394- const customLayoutfluidActive = Config . customLayoutfluid . split ( "#" ) ;
1410+ const customLayoutfluidActive = Config . customLayoutfluid ;
13951411 return [
13961412 ...customLayoutfluidActive ,
13971413 ...LayoutsList . filter ( ( it ) => ! customLayoutfluidActive . includes ( it ) ) ,
0 commit comments