@@ -30,64 +30,28 @@ const commands: Command[] = [
3030function update ( ) : void {
3131 const snapshot = DB . getSnapshot ( ) ;
3232 subgroup . list = [ ] ;
33+
3334 if (
34- snapshot === undefined ||
35- snapshot . tags === undefined ||
36- snapshot . tags . length === 0
35+ snapshot !== undefined &&
36+ snapshot . tags !== undefined &&
37+ snapshot . tags . length > 0
3738 ) {
3839 subgroup . list . push ( {
39- id : "createTag" ,
40- display : "Create tag" ,
41- icon : "fa-plus" ,
42- shouldFocusTestUI : false ,
43- exec : ( { commandlineModal } ) : void => {
44- EditTagsPopup . show ( "add" , undefined , undefined , commandlineModal ) ;
45- } ,
46- } ) ;
47- return ;
48- }
49- subgroup . list . push ( {
50- id : "clearTags" ,
51- display : `Clear tags` ,
52- icon : "fa-times" ,
53- sticky : true ,
54- exec : async ( ) : Promise < void > => {
55- const snapshot = DB . getSnapshot ( ) ;
56- if ( ! snapshot ) return ;
57-
58- snapshot . tags = snapshot . tags ?. map ( ( tag ) => {
59- tag . active = false ;
60-
61- return tag ;
62- } ) ;
63-
64- DB . setSnapshot ( snapshot ) ;
65- if (
66- Config . paceCaret === "average" ||
67- Config . paceCaret === "tagPb" ||
68- Config . paceCaret === "daily"
69- ) {
70- await PaceCaret . init ( ) ;
71- }
72- void ModesNotice . update ( ) ;
73- TagController . saveActiveToLocalStorage ( ) ;
74- } ,
75- } ) ;
76-
77- for ( const tag of snapshot . tags ) {
78- subgroup . list . push ( {
79- id : "toggleTag" + tag . _id ,
80- display : tag . display ,
40+ id : "clearTags" ,
41+ display : `Clear tags` ,
42+ icon : "fa-times" ,
8143 sticky : true ,
82- active : ( ) => {
83- return (
84- DB . getSnapshot ( ) ?. tags ?. find ( ( t ) => t . _id === tag . _id ) ?. active ??
85- false
86- ) ;
87- } ,
8844 exec : async ( ) : Promise < void > => {
89- TagController . toggle ( tag . _id ) ;
45+ const snapshot = DB . getSnapshot ( ) ;
46+ if ( ! snapshot ) return ;
47+
48+ snapshot . tags = snapshot . tags ?. map ( ( tag ) => {
49+ tag . active = false ;
9050
51+ return tag ;
52+ } ) ;
53+
54+ DB . setSnapshot ( snapshot ) ;
9155 if (
9256 Config . paceCaret === "average" ||
9357 Config . paceCaret === "tagPb" ||
@@ -96,8 +60,35 @@ function update(): void {
9660 await PaceCaret . init ( ) ;
9761 }
9862 void ModesNotice . update ( ) ;
63+ TagController . saveActiveToLocalStorage ( ) ;
9964 } ,
10065 } ) ;
66+
67+ for ( const tag of snapshot . tags ) {
68+ subgroup . list . push ( {
69+ id : "toggleTag" + tag . _id ,
70+ display : tag . display ,
71+ sticky : true ,
72+ active : ( ) => {
73+ return (
74+ DB . getSnapshot ( ) ?. tags ?. find ( ( t ) => t . _id === tag . _id ) ?. active ??
75+ false
76+ ) ;
77+ } ,
78+ exec : async ( ) : Promise < void > => {
79+ TagController . toggle ( tag . _id ) ;
80+
81+ if (
82+ Config . paceCaret === "average" ||
83+ Config . paceCaret === "tagPb" ||
84+ Config . paceCaret === "daily"
85+ ) {
86+ await PaceCaret . init ( ) ;
87+ }
88+ void ModesNotice . update ( ) ;
89+ } ,
90+ } ) ;
91+ }
10192 }
10293 subgroup . list . push ( {
10394 id : "createTag" ,
0 commit comments