Skip to content

Commit

Permalink
CCA: ESLint: Fix floating promise warning in views/camera/timertick.ts
Browse files Browse the repository at this point in the history
`cca.py lint --eslintrc .eslintrc_floating_promise.js` error count goes
down from 106 to 103.

Bug: b:172336355
Test: cca.py lint --eslintrc .eslintrc_floating_promise.js
Change-Id: I3ab6b0d2f42ca4218fb42c9687ff007990ebec47
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4314700
Commit-Queue: Pi-Hsun Shih <pihsun@chromium.org>
Reviewed-by: Shik Chen <shik@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1115606}
  • Loading branch information
peter50216 authored and Chromium LUCI CQ committed Mar 10, 2023
1 parent 85d310d commit 3861571
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 2 additions & 4 deletions ash/webui/camera_app_ui/resources/js/animation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@ function getAnimations(el: HTMLElement): Animation[] {
* Cancels the running animation on the element, if any.
*
* @param el Target element to cancel animation.
* @return Promise resolved when the animation is cancelled.
*/
export async function cancel(el: HTMLElement): Promise<void> {
export function cancel(el: HTMLElement): void {
for (const a of getAnimations(el)) {
a.cancel();
}
await getQueueFor(el).flush();
}

/**
Expand All @@ -50,7 +48,7 @@ export async function cancel(el: HTMLElement): Promise<void> {
*/
export async function play(
el: HTMLElement, changeElement?: () => void): Promise<void> {
await cancel(el);
cancel(el);
const queue = getQueueFor(el);
async function job() {
void el.offsetWidth; // Force repaint before applying the animation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ export function start(): Promise<void> {
} else {
const sound = sounds.get(tickCounter);
if (sound !== undefined) {
play(dom.get(sound, HTMLAudioElement));
// Not waiting for audio to finish playing.
void play(dom.get(sound, HTMLAudioElement));
}
tickMsg.textContent = tickCounter + '';
animate.play(tickMsg);
// Not waiting for animation to finish playing.
void animate.play(tickMsg);
tickTimeout = setTimeout(onTimerTick, 1000);
tickCounter--;
}
Expand Down

0 comments on commit 3861571

Please sign in to comment.