( mode: M, mode2: Mode2<M>, punctuation: boolean, numbers: boolean, language: Language, difficulty: Difficulty, lazyMode: boolean, wpm: number, acc: number, raw: number, consistency: number, )
| 187 | } |
| 188 | |
| 189 | function saveLocalPB<M extends Mode>( |
| 190 | mode: M, |
| 191 | mode2: Mode2<M>, |
| 192 | punctuation: boolean, |
| 193 | numbers: boolean, |
| 194 | language: Language, |
| 195 | difficulty: Difficulty, |
| 196 | lazyMode: boolean, |
| 197 | wpm: number, |
| 198 | acc: number, |
| 199 | raw: number, |
| 200 | consistency: number, |
| 201 | ): void { |
| 202 | if (mode === "quote") return; |
| 203 | if (!dbSnapshot) return; |
| 204 | function cont(): void { |
| 205 | if (!dbSnapshot) return; |
| 206 | let found = false; |
| 207 | |
| 208 | dbSnapshot.personalBests ??= { |
| 209 | time: {}, |
| 210 | words: {}, |
| 211 | quote: {}, |
| 212 | zen: {}, |
| 213 | custom: {}, |
| 214 | }; |
| 215 | |
| 216 | dbSnapshot.personalBests[mode] ??= { |
| 217 | [mode2]: [], |
| 218 | }; |
| 219 | |
| 220 | dbSnapshot.personalBests[mode][mode2] ??= |
| 221 | [] as unknown as PersonalBests[M][Mode2<M>]; |
| 222 | |
| 223 | ( |
| 224 | dbSnapshot.personalBests[mode][mode2] as unknown as PersonalBest[] |
| 225 | ).forEach((pb) => { |
| 226 | if ( |
| 227 | (pb.punctuation ?? false) === punctuation && |
| 228 | (pb.numbers ?? false) === numbers && |
| 229 | pb.difficulty === difficulty && |
| 230 | pb.language === language && |
| 231 | (pb.lazyMode ?? false) === lazyMode |
| 232 | ) { |
| 233 | found = true; |
| 234 | pb.wpm = wpm; |
| 235 | pb.acc = acc; |
| 236 | pb.raw = raw; |
| 237 | pb.timestamp = Date.now(); |
| 238 | pb.consistency = consistency; |
| 239 | pb.lazyMode = lazyMode; |
| 240 | } |
| 241 | }); |
| 242 | if (!found) { |
| 243 | //nothing found |
| 244 | (dbSnapshot.personalBests[mode][mode2] as unknown as PersonalBest[]).push( |
| 245 | { |
| 246 | language, |
no test coverage detected