From 944c44ffb8e6968fe6f855db7ce788c77c8738e4 Mon Sep 17 00:00:00 2001 From: tophf Date: Wed, 16 Feb 2022 22:33:55 +0300 Subject: [PATCH] use default sorter pref for resiliency --- manage/sorter.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/manage/sorter.js b/manage/sorter.js index 7380bfab..3a4b140a 100644 --- a/manage/sorter.js +++ b/manage/sorter.js @@ -60,13 +60,14 @@ const sorter = (() => { 'disabled,desc, title,desc', 'disabled,desc, usercss,asc, title,desc', ]; - const splitRegex = /\s*,\s*/; + const ID = 'manage.newUI.sort'; + const getPref = () => prefs.get(ID) || prefs.__defaults[ID]; let columns = 1; onDOMready().then(() => { - prefs.subscribe('manage.newUI.sort', sorter.update); + prefs.subscribe(ID, sorter.update); $('#sorter-help').onclick = showHelp; addOptions(); updateColumnCount(); @@ -112,13 +113,13 @@ const sorter = (() => { }); renderBin.appendChild(container); select.appendChild(renderBin); - select.value = prefs.get('manage.newUI.sort'); + select.value = getPref(); } return { sort({styles}) { - const sortBy = prefs.get('manage.newUI.sort').split(splitRegex); + const sortBy = getPref().split(splitRegex); const len = sortBy.length; return styles.sort((a, b) => { let types, direction;