Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removing dynamic method calling to prevent minification error #3012

Merged
merged 1 commit into from Jan 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 18 additions & 3 deletions packages/workbox-background-sync/src/Queue.ts
Expand Up @@ -11,7 +11,7 @@ import {logger} from 'workbox-core/_private/logger.js';
import {assert} from 'workbox-core/_private/assert.js';
import {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.js';
import {QueueStore} from './lib/QueueStore.js';
import {UnidentifiedQueueStoreEntry} from './lib/QueueDb.js';
import {QueueStoreEntry, UnidentifiedQueueStoreEntry} from './lib/QueueDb.js';
import {StorableRequest} from './lib/StorableRequest.js';
import './_version.js';

Expand Down Expand Up @@ -276,7 +276,14 @@ class Queue {
entry.metadata = metadata;
}

await this._queueStore[`${operation}Entry`](entry);
switch (operation) {
case 'push':
await this._queueStore.pushEntry(entry);
break;
case 'unshift':
await this._queueStore.unshiftEntry(entry);
break;
}

if (process.env.NODE_ENV !== 'production') {
logger.log(
Expand Down Expand Up @@ -307,7 +314,15 @@ class Queue {
operation: 'pop' | 'shift',
): Promise<QueueEntry | undefined> {
const now = Date.now();
const entry = await this._queueStore[`${operation}Entry`]();
let entry: QueueStoreEntry | undefined;
switch (operation) {
case 'pop':
entry = await this._queueStore.popEntry();
break;
case 'shift':
entry = await this._queueStore.shiftEntry();
break;
}

if (entry) {
// Ignore requests older than maxRetentionTime. Call this function
Expand Down