Skip to content

Commit 9dd1ebf

Browse files
Mohit TejaniMohit Tejani
authored andcommitted
lib/dist updates
1 parent 2a94ff8 commit 9dd1ebf

File tree

4 files changed

+64
-6
lines changed

4 files changed

+64
-6
lines changed

dist/web/pubnub.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9566,6 +9566,11 @@
95669566
return subscriptionTimetokenFromReference(currentTimetoken, referenceTimetoken !== null && referenceTimetoken !== void 0 ? referenceTimetoken : '0');
95679567
}
95689568
subscribe({ channels, channelGroups, timetoken, withPresence, }) {
9569+
var _a;
9570+
// check if the channels and groups are already subscribed
9571+
const hasNewChannels = channels === null || channels === void 0 ? void 0 : channels.some((channel) => !this.channels.includes(channel));
9572+
const hasNewGroups = channelGroups === null || channelGroups === void 0 ? void 0 : channelGroups.some((group) => !this.groups.includes(group));
9573+
const hasNewSubscriptions = hasNewChannels || hasNewGroups;
95699574
this.channels = [...this.channels, ...(channels !== null && channels !== void 0 ? channels : [])];
95709575
this.groups = [...this.groups, ...(channelGroups !== null && channelGroups !== void 0 ? channelGroups : [])];
95719576
if (withPresence) {
@@ -9576,7 +9581,29 @@
95769581
this.engine.transition(restore(Array.from(new Set([...this.channels, ...(channels !== null && channels !== void 0 ? channels : [])])), Array.from(new Set([...this.groups, ...(channelGroups !== null && channelGroups !== void 0 ? channelGroups : [])])), timetoken));
95779582
}
95789583
else {
9579-
this.engine.transition(subscriptionChange(Array.from(new Set([...this.channels, ...(channels !== null && channels !== void 0 ? channels : [])])), Array.from(new Set([...this.groups, ...(channelGroups !== null && channelGroups !== void 0 ? channelGroups : [])]))));
9584+
if (hasNewSubscriptions) {
9585+
this.engine.transition(subscriptionChange(Array.from(new Set([...this.channels, ...(channels !== null && channels !== void 0 ? channels : [])])), Array.from(new Set([...this.groups, ...(channelGroups !== null && channelGroups !== void 0 ? channelGroups : [])]))));
9586+
}
9587+
else {
9588+
this.dependencies.config
9589+
.logger()
9590+
.debug('EventEngine', 'Skipping state transition - all channels/groups already subscribed. Emitting SubscriptionChanged event.');
9591+
// Get current timetoken from state context
9592+
const currentState = this.engine.currentState;
9593+
const currentContext = this.engine.currentContext;
9594+
let currentTimetoken = '0';
9595+
if ((currentState === null || currentState === void 0 ? void 0 : currentState.label) === ReceivingState.label && currentContext) {
9596+
const receivingContext = currentContext;
9597+
currentTimetoken = (_a = receivingContext.cursor) === null || _a === void 0 ? void 0 : _a.timetoken;
9598+
}
9599+
// Manually emit SubscriptionChanged status event
9600+
this.dependencies.emitStatus({
9601+
category: StatusCategory$1.PNSubscriptionChangedCategory,
9602+
affectedChannels: Array.from(new Set(this.channels.filter((c) => !c.endsWith('-pnpres')))),
9603+
affectedChannelGroups: Array.from(new Set(this.groups.filter((g) => !g.endsWith('-pnpres')))),
9604+
currentTimetoken,
9605+
});
9606+
}
95809607
}
95819608
if (this.dependencies.join) {
95829609
this.dependencies.join({

dist/web/pubnub.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/event-engine/index.js

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,17 @@ var __importStar = (this && this.__importStar) || (function () {
3737
return result;
3838
};
3939
})();
40+
var __importDefault = (this && this.__importDefault) || function (mod) {
41+
return (mod && mod.__esModule) ? mod : { "default": mod };
42+
};
4043
Object.defineProperty(exports, "__esModule", { value: true });
4144
exports.EventEngine = void 0;
4245
const receiving_1 = require("./states/receiving");
4346
const dispatcher_1 = require("./dispatcher");
4447
const utils_1 = require("../core/utils");
4548
const unsubscribed_1 = require("./states/unsubscribed");
4649
const core_1 = require("./core");
50+
const categories_1 = __importDefault(require("../core/constants/categories"));
4751
const utils = __importStar(require("../core/utils"));
4852
const events = __importStar(require("./events"));
4953
/**
@@ -88,6 +92,11 @@ class EventEngine {
8892
return (0, utils_1.subscriptionTimetokenFromReference)(currentTimetoken, referenceTimetoken !== null && referenceTimetoken !== void 0 ? referenceTimetoken : '0');
8993
}
9094
subscribe({ channels, channelGroups, timetoken, withPresence, }) {
95+
var _a;
96+
// check if the channels and groups are already subscribed
97+
const hasNewChannels = channels === null || channels === void 0 ? void 0 : channels.some((channel) => !this.channels.includes(channel));
98+
const hasNewGroups = channelGroups === null || channelGroups === void 0 ? void 0 : channelGroups.some((group) => !this.groups.includes(group));
99+
const hasNewSubscriptions = hasNewChannels || hasNewGroups;
91100
this.channels = [...this.channels, ...(channels !== null && channels !== void 0 ? channels : [])];
92101
this.groups = [...this.groups, ...(channelGroups !== null && channelGroups !== void 0 ? channelGroups : [])];
93102
if (withPresence) {
@@ -98,7 +107,29 @@ class EventEngine {
98107
this.engine.transition(events.restore(Array.from(new Set([...this.channels, ...(channels !== null && channels !== void 0 ? channels : [])])), Array.from(new Set([...this.groups, ...(channelGroups !== null && channelGroups !== void 0 ? channelGroups : [])])), timetoken));
99108
}
100109
else {
101-
this.engine.transition(events.subscriptionChange(Array.from(new Set([...this.channels, ...(channels !== null && channels !== void 0 ? channels : [])])), Array.from(new Set([...this.groups, ...(channelGroups !== null && channelGroups !== void 0 ? channelGroups : [])]))));
110+
if (hasNewSubscriptions) {
111+
this.engine.transition(events.subscriptionChange(Array.from(new Set([...this.channels, ...(channels !== null && channels !== void 0 ? channels : [])])), Array.from(new Set([...this.groups, ...(channelGroups !== null && channelGroups !== void 0 ? channelGroups : [])]))));
112+
}
113+
else {
114+
this.dependencies.config
115+
.logger()
116+
.debug('EventEngine', 'Skipping state transition - all channels/groups already subscribed. Emitting SubscriptionChanged event.');
117+
// Get current timetoken from state context
118+
const currentState = this.engine.currentState;
119+
const currentContext = this.engine.currentContext;
120+
let currentTimetoken = '0';
121+
if ((currentState === null || currentState === void 0 ? void 0 : currentState.label) === receiving_1.ReceivingState.label && currentContext) {
122+
const receivingContext = currentContext;
123+
currentTimetoken = (_a = receivingContext.cursor) === null || _a === void 0 ? void 0 : _a.timetoken;
124+
}
125+
// Manually emit SubscriptionChanged status event
126+
this.dependencies.emitStatus({
127+
category: categories_1.default.PNSubscriptionChangedCategory,
128+
affectedChannels: Array.from(new Set(this.channels.filter((c) => !c.endsWith('-pnpres')))),
129+
affectedChannelGroups: Array.from(new Set(this.groups.filter((g) => !g.endsWith('-pnpres')))),
130+
currentTimetoken,
131+
});
132+
}
102133
}
103134
if (this.dependencies.join) {
104135
this.dependencies.join({

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)