1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-29 14:43:31 +00:00

remove finally() since it is not supported in older browsers

This commit is contained in:
Kyle Spearrin
2019-03-05 17:12:51 -05:00
parent cc27f98aae
commit 965e35604c
2 changed files with 16 additions and 2 deletions

View File

@@ -32,11 +32,18 @@ export function sequentialize(cacheKey: (args: any[]) => string) {
return response;
}
response = originalMethod.apply(this, args).finally(() => {
const onFinally = () => {
cache.delete(argsCacheKey);
if (cache.size === 0) {
caches.delete(this);
}
};
response = originalMethod.apply(this, args).then((val: any) => {
onFinally();
return val;
}).catch((err: any) => {
onFinally();
throw err;
});
cache.set(argsCacheKey, response);