Fix image queue creation
This commit is contained in:
@@ -12,14 +12,16 @@ import { Sources } from '@/features/source/services/Sources.ts';
|
|||||||
export class SourceAwareQueue {
|
export class SourceAwareQueue {
|
||||||
private static readonly DEFAULT_ID = '__global__';
|
private static readonly DEFAULT_ID = '__global__';
|
||||||
|
|
||||||
private readonly queueBySource = new Map<string, Queue>([
|
private readonly queueBySource: Map<string, Queue>;
|
||||||
[SourceAwareQueue.DEFAULT_ID, new Queue(this.concurrencyPerSource)],
|
|
||||||
]);
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly areConnectionsLimited: boolean,
|
private readonly areConnectionsLimited: boolean,
|
||||||
private readonly concurrencyPerSource = 5,
|
private readonly concurrencyPerSource = 5,
|
||||||
) {}
|
) {
|
||||||
|
this.queueBySource = new Map<string, Queue>([
|
||||||
|
[SourceAwareQueue.DEFAULT_ID, new Queue(this.concurrencyPerSource)],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
private getConcurrencyFor(sourceId: string | null): number {
|
private getConcurrencyFor(sourceId: string | null): number {
|
||||||
const isLocalSource = sourceId === Sources.LOCAL_SOURCE_ID;
|
const isLocalSource = sourceId === Sources.LOCAL_SOURCE_ID;
|
||||||
|
|||||||
@@ -467,7 +467,7 @@ export class RequestManager {
|
|||||||
const isHttps = typeof window !== 'undefined' && window.location.protocol === 'https:';
|
const isHttps = typeof window !== 'undefined' && window.location.protocol === 'https:';
|
||||||
const isHttp2 = isHttps && this.detectHttp2();
|
const isHttp2 = isHttps && this.detectHttp2();
|
||||||
|
|
||||||
this.imageQueue = new SourceAwareQueue(isHttp2, 5);
|
this.imageQueue = new SourceAwareQueue(!isHttp2, 5);
|
||||||
|
|
||||||
BaseClient.setTokenRefreshCompleteCallback(() => {
|
BaseClient.setTokenRefreshCompleteCallback(() => {
|
||||||
this.processQueues();
|
this.processQueues();
|
||||||
@@ -954,7 +954,6 @@ export class RequestManager {
|
|||||||
|
|
||||||
private getSourceIdFromUrl(url: string): string | null {
|
private getSourceIdFromUrl(url: string): string | null {
|
||||||
try {
|
try {
|
||||||
console.log('asdf', new URL(url).searchParams.get('sourceId'));
|
|
||||||
return new URL(url).searchParams.get('sourceId');
|
return new URL(url).searchParams.get('sourceId');
|
||||||
} catch {
|
} catch {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user