@@ -707,7 +707,7 @@ async function updateTags(dontSave: boolean): Promise<void> {
707707
708708 let annotationSide : LabelPosition = "start" ;
709709 let labelAdjust = 15 ;
710- activeTags . forEach ( async ( tag ) => {
710+ for ( const tag of activeTags ) {
711711 const tpb = await DB . getLocalTagPB (
712712 tag . _id ,
713713 Config . mode ,
@@ -791,7 +791,7 @@ async function updateTags(dontSave: boolean): Promise<void> {
791791 }
792792 }
793793 }
794- } ) ;
794+ }
795795}
796796
797797function updateTestType ( randomQuote : Quote | null ) : void {
@@ -1010,8 +1010,8 @@ export async function update(
10101010 await updateCrown ( dontSave ) ;
10111011 await updateGraph ( ) ;
10121012 await updateGraphPBLine ( ) ;
1013- updateResultChartDataVisibility ( ) ;
10141013 await updateTags ( dontSave ) ;
1014+ updateResultChartDataVisibility ( ) ;
10151015 updateOther ( difficultyFailed , failReason , afkDetected , isRepeated , tooShort ) ;
10161016
10171017 ( ( ChartController . result . options as PluginChartOptions < "line" | "scatter" > )
@@ -1118,13 +1118,15 @@ const resultChartDataVisibility = new LocalStorageWithSchema({
11181118 burst : z . boolean ( ) ,
11191119 errors : z . boolean ( ) ,
11201120 pbLine : z . boolean ( ) ,
1121+ tagPbLine : z . boolean ( ) ,
11211122 } )
11221123 . strict ( ) ,
11231124 fallback : {
11241125 raw : true ,
11251126 burst : true ,
11261127 errors : true ,
11271128 pbLine : true ,
1129+ tagPbLine : true ,
11281130 } ,
11291131} ) ;
11301132
@@ -1135,25 +1137,44 @@ function updateResultChartDataVisibility(update = false): void {
11351137 ChartController . result . getDataset ( "error" ) . hidden = ! vis . errors ;
11361138
11371139 for ( const annotation of resultAnnotation ) {
1138- if ( annotation . id !== "lpb" ) continue ;
1139- annotation . display = vis . pbLine ;
1140+ if ( annotation . id === "lpb" ) {
1141+ annotation . display = vis . pbLine ;
1142+ } else if ( annotation . id === "tpb" ) {
1143+ annotation . display = vis . tagPbLine ;
1144+ }
11401145 }
11411146
11421147 if ( update ) ChartController . result . update ( ) ;
11431148
11441149 const buttons = $ ( ".pageTest #result .chart .chartLegend button" ) ;
11451150
1151+ // Check if there are any tag PB annotations
1152+ const hasTagPbAnnotations = resultAnnotation . some (
1153+ ( annotation ) => annotation . id === "tpb"
1154+ ) ;
1155+
11461156 for ( const button of buttons ) {
11471157 const id = $ ( button ) . data ( "id" ) as string ;
11481158
1149- if ( id !== "raw" && id !== "burst" && id !== "errors" && id !== "pbLine" ) {
1159+ if (
1160+ id !== "raw" &&
1161+ id !== "burst" &&
1162+ id !== "errors" &&
1163+ id !== "pbLine" &&
1164+ id !== "tagPbLine"
1165+ ) {
11501166 return ;
11511167 }
11521168
11531169 $ ( button ) . toggleClass ( "active" , vis [ id ] ) ;
11541170
11551171 if ( id === "pbLine" ) {
11561172 $ ( button ) . toggleClass ( "hidden" , ! isAuthenticated ( ) ) ;
1173+ } else if ( id === "tagPbLine" ) {
1174+ $ ( button ) . toggleClass (
1175+ "hidden" ,
1176+ ! isAuthenticated ( ) || ! hasTagPbAnnotations
1177+ ) ;
11571178 }
11581179 }
11591180}
@@ -1216,10 +1237,15 @@ $(".pageTest #result .chart .chartLegend button").on("click", (event) => {
12161237 const $target = $ ( event . target ) ;
12171238 const id = $target . data ( "id" ) as string ;
12181239
1219- if ( id !== "raw" && id !== "burst" && id !== "errors" && id !== "pbLine" ) {
1240+ if (
1241+ id !== "raw" &&
1242+ id !== "burst" &&
1243+ id !== "errors" &&
1244+ id !== "pbLine" &&
1245+ id !== "tagPbLine"
1246+ ) {
12201247 return ;
12211248 }
1222-
12231249 const vis = resultChartDataVisibility . get ( ) ;
12241250 vis [ id ] = ! vis [ id ] ;
12251251 resultChartDataVisibility . set ( vis ) ;
@@ -1238,7 +1264,7 @@ $(".pageTest #favoriteQuoteButton").on("click", async () => {
12381264 if ( ! dbSnapshot ) return ;
12391265
12401266 if ( $button . hasClass ( "fas" ) ) {
1241- // Remove from favorites
1267+ // Remove from
12421268 Loader . show ( ) ;
12431269 const response = await Ape . users . removeQuoteFromFavorites ( {
12441270 body : {
0 commit comments