mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-23 11:56:00 +01:00
remove finally() since it is not supported in older browsers
This commit is contained in:
parent
cc27f98aae
commit
965e35604c
@ -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);
|
||||
|
@ -32,7 +32,7 @@ export function throttle(limit: number, throttleKey: (args: any[]) => string) {
|
||||
|
||||
return new Promise<T>((resolve, reject) => {
|
||||
const exec = () => {
|
||||
originalMethod.apply(this, args).finally(() => {
|
||||
const onFinally = () => {
|
||||
queue.splice(queue.indexOf(exec), 1);
|
||||
if (queue.length >= limit) {
|
||||
queue[limit - 1]();
|
||||
@ -42,6 +42,13 @@ export function throttle(limit: number, throttleKey: (args: any[]) => string) {
|
||||
allThrottles.delete(this);
|
||||
}
|
||||
}
|
||||
};
|
||||
originalMethod.apply(this, args).then((val: any) => {
|
||||
onFinally();
|
||||
return val;
|
||||
}).catch((err: any) => {
|
||||
onFinally();
|
||||
throw err;
|
||||
}).then(resolve, reject);
|
||||
};
|
||||
queue.push(exec);
|
||||
|
Loading…
Reference in New Issue
Block a user