There are two parts to this change:
1. The computation of peaks is moved from `MessageAudio` to the
`GlobalAudioContext` and thus we can limit the concurrency of the
computations (`p-queue`!) and de-duplicate the computations as well
2. While the peaks are computed the component has to display spinning
animation instead of empty waveform and unclickable UI.
`useMemo()` doesn't guarantee that the value won't be recomputed during
re-renders. Unfortunately, every time `AudioContext` is instantiated -
there is an audible click. This click happens during the change between
conversations and is very annoying.
Move both `AudioContext` instance to the
GlobalAudioContext's top-level declarations, and `Audio`/`WaveformCache`
to `useRef()`s.
Introduce new UI and behavior for playing audio attachments in
conversations. Previously, playback stopped unexpectedly during window
resizes and scrolling through the messages due to the row height
recomputation in `react-virtualized`.
With this commit we introduce `<GlobalAudioContext/>` instance that
wraps whole conversation and provides an `<audio/>` element that
doesn't get re-rendered (or destroyed) whenever `react-virtualized`
recomputes messages. The audio players (with a freshly designed UI) now
share this global `<audio/>` instance and manage access to it using
`audioPlayer.owner` state from the redux.
New UI computes on the fly, caches, and displays waveforms for each
audio attachment. Storybook had to be slightly modified to accomodate
testing of Android bubbles by introducing the new knob for
`authorColor`.