Skip to content

Commit

Permalink
take-1 fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mohitpubnub committed Jan 8, 2024
1 parent f7b92ad commit 528ca45
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/core/endpoints/subscriptionUtils/receiveMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const endpoint = {
}
outParams.tt = params.timetoken;
outParams.tr = params.region;
outParams.ee='';
outParams.ee = '';
return outParams;
},

Expand Down
6 changes: 3 additions & 3 deletions src/event-engine/core/retryPolicy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export class RetryPolicy {
maximumRetry: configuration.maximumRetry,

shouldRetry(error: any, attempt: number) {

Check warning on line 24 in src/event-engine/core/retryPolicy.ts

View workflow job for this annotation

GitHub Actions / Integration and Unit tests (12, ci:node)

Unexpected any. Specify a different type

Check warning on line 24 in src/event-engine/core/retryPolicy.ts

View workflow job for this annotation

GitHub Actions / Integration and Unit tests (14, ci:node)

Unexpected any. Specify a different type

Check warning on line 24 in src/event-engine/core/retryPolicy.ts

View workflow job for this annotation

GitHub Actions / Integration and Unit tests (16, ci:node)

Unexpected any. Specify a different type

Check warning on line 24 in src/event-engine/core/retryPolicy.ts

View workflow job for this annotation

GitHub Actions / Integration and Unit tests (16, ci:web)

Unexpected any. Specify a different type
if (error?.status?.statusCode === 403) {
return false;
}
if (error?.status?.statusCode === 403) {
return false;
}
return this.maximumRetry > attempt;
},

Expand Down
60 changes: 29 additions & 31 deletions src/event-engine/dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,39 +130,37 @@ export class EventEngineDispatcher extends Dispatcher<effects.Effects, Dependenc

this.on(
effects.handshakeReconnect.type,
asyncHandler(
async (payload, abortSignal, { handshake, delay, presenceState, config }) => {
if (config.retryConfiguration && config.retryConfiguration.shouldRetry(payload.reason, payload.attempts)) {
abortSignal.throwIfAborted();

await delay(config.retryConfiguration.getDelay(payload.attempts));

abortSignal.throwIfAborted();

try {
const result = await handshake({
abortSignal: abortSignal,
channels: payload.channels,
channelGroups: payload.groups,
filterExpression: config.filterExpression,
state: presenceState,
});

return engine.transition(events.handshakingReconnectingSuccess(result));
} catch (error) {
if (error instanceof Error && error.message === 'Aborted') {
return;
}

if (error instanceof PubNubError) {
return engine.transition(events.handshakingReconnectingFailure(error));
}
asyncHandler(async (payload, abortSignal, { handshake, delay, presenceState, config }) => {
if (config.retryConfiguration && config.retryConfiguration.shouldRetry(payload.reason, payload.attempts)) {
abortSignal.throwIfAborted();

await delay(config.retryConfiguration.getDelay(payload.attempts));

abortSignal.throwIfAborted();

try {
const result = await handshake({
abortSignal: abortSignal,
channels: payload.channels,
channelGroups: payload.groups,
filterExpression: config.filterExpression,
state: presenceState,
});

return engine.transition(events.handshakingReconnectingSuccess(result));
} catch (error) {
if (error instanceof Error && error.message === 'Aborted') {
return;
}

if (error instanceof PubNubError) {
return engine.transition(events.handshakingReconnectingFailure(error));
}
} else {
return engine.transition(events.handshakingReconnectingGiveup());
}
},
),
} else {
return engine.transition(events.handshakingReconnectingGiveup());
}
}),
);
}
}
2 changes: 1 addition & 1 deletion src/event-engine/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const reconnectingSuccess = createEvent('RECEIVE_RECONNECT_SUCCESS', (cur
export const reconnectingFailure = createEvent('RECEIVE_RECONNECT_FAILURE', (error: PubNubError) => error);
export const reconnectingGiveup = createEvent('RECEIVING_RECONNECTING_GIVEUP', () => ({}));
export const reconnectingRetry = createEvent('RECONNECT', () => ({}));
export const unsubscribeAll = createEvent('UNSUBSCRIBE_ALL', () => {});
export const unsubscribeAll = createEvent('UNSUBSCRIBE_ALL', () => ({}));

export type Events = MapOf<
| typeof subscriptionChange
Expand Down
4 changes: 2 additions & 2 deletions src/event-engine/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ export class EventEngine {
}

unsubscribe({ channels, groups }: { channels?: string[]; groups?: string[] }) {
let channlesWithPres: any = channels?.slice(0);
const channlesWithPres: any = channels?.slice(0);
channels?.map((c) => channlesWithPres.push(`${c}-pnpres`));
this.channels = this.channels.filter((channel) => !channlesWithPres?.includes(channel));

let groupsWithPres: any = groups?.slice(0);
const groupsWithPres: any = groups?.slice(0);
groups?.map((g) => groupsWithPres.push(`${g}-pnpres`));
this.groups = this.groups.filter((group) => !groupsWithPres?.includes(group));

Expand Down
2 changes: 1 addition & 1 deletion src/event-engine/presence/states/heartbeat_failed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ HeartbeatFailedState.on(disconnect.type, (context, _) =>
),
);

HeartbeatFailedState.on(leftAll.type, (context,_) =>
HeartbeatFailedState.on(leftAll.type, (context, _) =>
HeartbeatInactiveState.with(undefined, [leave(context.channels, context.groups)]),
);

0 comments on commit 528ca45

Please sign in to comment.