Voice notes drafts

This commit is contained in:
Alvaro 2023-03-02 13:55:40 -07:00 committed by GitHub
parent 356fb301e1
commit 99015d7b96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 2113 additions and 909 deletions

View file

@ -81,7 +81,8 @@ async function doComputePeaks(
url: string,
barCount: number
): Promise<ComputePeaksResult> {
const existing = waveformCache.get(url);
const cacheKey = `${url}:${barCount}`;
const existing = waveformCache.get(cacheKey);
if (existing) {
log.info('GlobalAudioContext: waveform cache hit', url);
return Promise.resolve(existing);
@ -101,7 +102,7 @@ async function doComputePeaks(
`GlobalAudioContext: audio ${url} duration ${duration}s is too long`
);
const emptyResult = { peaks, duration };
waveformCache.set(url, emptyResult);
waveformCache.set(cacheKey, emptyResult);
return emptyResult;
}
@ -143,7 +144,7 @@ async function doComputePeaks(
}
const result = { peaks, duration };
waveformCache.set(url, result);
waveformCache.set(cacheKey, result);
return result;
}