Skip to content

Commit

Permalink
Stream fixes (#1417)
Browse files Browse the repository at this point in the history
* Release 1.7.0 (#1411)

* fix: fixed font sizes and dark theme (#1376)

* fix: fixed font sizes and dark theme

* fix: fixed line height

* Add erc1155 to token gating group conditions (#1382)

* feat: add erc1155 to token gating group conditions

* fix: add tokenId to fetchContractInfo function

* lock file updated

---------

Co-authored-by: rohitmalhotra1420 <[email protected]>

* Replaced useResolveWeb3Name hook with resolveWeb3Name helper function (#1390)

* fix: added common resolveweb3 for domain name

* fix: fixed review comments

* Notification Ui change (#1396)

* feat: new notification ui

* fix: fixed review comments

* lock file changed

* fix: fixed color and cta hover

* fix: fixed the review comments

* fix: fixed link icon

---------

Co-authored-by: rohitmalhotra1420 <[email protected]>

* Push Chat Reply Feature (#1399)

* Functioning reply in ChatPreviewList, ChatList and Input

* Reply cancel and replying to in UIWeb:MessageInput

* Reply Feature with styles

* fix: modified some parts in helper func

* fix: added the replied to text and also fixed the emoji picker position

added the replied to text in the chat bubble and fixed the emoji picker position also fixed the
breaking of the chat due to the messagetype issue

* fix: fixed the UI for the reply feature

changed the replying to to reply and also fixed the image positioning

* fix: fixed the issues

moved the funcs to helpers and also removed the commented code

* fix: fixed image in notification

* fix: added the commented code that was removed

---------

Co-authored-by: abhishek-01k <[email protected]>
Co-authored-by: Monalisha Mishra <[email protected]>

* uiweb lock file updated

* Add support for new chains in the chat criteria modal (#1404)

* fix: add cyber, linea and base

* fix: update cyber

* Added new infura key (#1408)

* fix: fixed infura key

* fix: fixed build issue

* fix: changed infura key

* fix: fixed review comments

* fix: fixed review comment

* lock files  fixed

---------

Co-authored-by: Monalisha Mishra <[email protected]>
Co-authored-by: Kalash Shah <[email protected]>
Co-authored-by: Harsh | Push <[email protected]>
Co-authored-by: abhishek-01k <[email protected]>
Co-authored-by: Monalisha Mishra <[email protected]>
Co-authored-by: Kolade <[email protected]>

* Release 1.7.1 (#1412)

* fix: fixed font sizes and dark theme (#1376)

* fix: fixed font sizes and dark theme

* fix: fixed line height

* Add erc1155 to token gating group conditions (#1382)

* feat: add erc1155 to token gating group conditions

* fix: add tokenId to fetchContractInfo function

* lock file updated

---------

Co-authored-by: rohitmalhotra1420 <[email protected]>

* Replaced useResolveWeb3Name hook with resolveWeb3Name helper function (#1390)

* fix: added common resolveweb3 for domain name

* fix: fixed review comments

* Notification Ui change (#1396)

* feat: new notification ui

* fix: fixed review comments

* lock file changed

* fix: fixed color and cta hover

* fix: fixed the review comments

* fix: fixed link icon

---------

Co-authored-by: rohitmalhotra1420 <[email protected]>

* Push Chat Reply Feature (#1399)

* Functioning reply in ChatPreviewList, ChatList and Input

* Reply cancel and replying to in UIWeb:MessageInput

* Reply Feature with styles

* fix: modified some parts in helper func

* fix: added the replied to text and also fixed the emoji picker position

added the replied to text in the chat bubble and fixed the emoji picker position also fixed the
breaking of the chat due to the messagetype issue

* fix: fixed the UI for the reply feature

changed the replying to to reply and also fixed the image positioning

* fix: fixed the issues

moved the funcs to helpers and also removed the commented code

* fix: fixed image in notification

* fix: added the commented code that was removed

---------

Co-authored-by: abhishek-01k <[email protected]>
Co-authored-by: Monalisha Mishra <[email protected]>

* uiweb lock file updated

* Add support for new chains in the chat criteria modal (#1404)

* fix: add cyber, linea and base

* fix: update cyber

* fix: fixed the theme for chat reply feature

fixed the UI of the chat reply

* Added new infura key (#1408)

* fix: fixed infura key

* fix: fixed build issue

* fix: changed infura key

* fix: fixed review comments

* fix: fixed review comment

* lock files  fixed

* fix: fixed the twitter preview Size issue

* fix: modified the address for the reply preview

* Release 1.7.0 (#1411) (#1413)

* fix: fixed font sizes and dark theme (#1376)

* fix: fixed font sizes and dark theme

* fix: fixed line height

* Add erc1155 to token gating group conditions (#1382)

* feat: add erc1155 to token gating group conditions

* fix: add tokenId to fetchContractInfo function

* lock file updated

---------



* Replaced useResolveWeb3Name hook with resolveWeb3Name helper function (#1390)

* fix: added common resolveweb3 for domain name

* fix: fixed review comments

* Notification Ui change (#1396)

* feat: new notification ui

* fix: fixed review comments

* lock file changed

* fix: fixed color and cta hover

* fix: fixed the review comments

* fix: fixed link icon

---------



* Push Chat Reply Feature (#1399)

* Functioning reply in ChatPreviewList, ChatList and Input

* Reply cancel and replying to in UIWeb:MessageInput

* Reply Feature with styles

* fix: modified some parts in helper func

* fix: added the replied to text and also fixed the emoji picker position

added the replied to text in the chat bubble and fixed the emoji picker position also fixed the
breaking of the chat due to the messagetype issue

* fix: fixed the UI for the reply feature

changed the replying to to reply and also fixed the image positioning

* fix: fixed the issues

moved the funcs to helpers and also removed the commented code

* fix: fixed image in notification

* fix: added the commented code that was removed

---------




* uiweb lock file updated

* Add support for new chains in the chat criteria modal (#1404)

* fix: add cyber, linea and base

* fix: update cyber

* Added new infura key (#1408)

* fix: fixed infura key

* fix: fixed build issue

* fix: changed infura key

* fix: fixed review comments

* fix: fixed review comment

* lock files  fixed

---------

Co-authored-by: Rohit Malhotra <[email protected]>
Co-authored-by: Kalash Shah <[email protected]>
Co-authored-by: Harsh | Push <[email protected]>
Co-authored-by: abhishek-01k <[email protected]>
Co-authored-by: Kolade <[email protected]>

* Revert "Release 1.7.0 (#1411) (#1413)" (#1414)

This reverts commit f96f451.

---------

Co-authored-by: Kalash Shah <[email protected]>
Co-authored-by: rohitmalhotra1420 <[email protected]>
Co-authored-by: Harsh | Push <[email protected]>
Co-authored-by: abhishek-01k <[email protected]>
Co-authored-by: Kolade <[email protected]>
Co-authored-by: Abhishek <[email protected]>

* fix: stream handling multiplier listeners

* fix: build issue

* fix: added logs

* fix: added type

* fix: stream fix

* fix: logs removal

* Update package.json

* Update UserProfile.tsx

* Update ChatDataProvider.tsx

* Update ChatDataProvider.tsx

* fix: fix log

---------

Co-authored-by: Rohit Malhotra <[email protected]>
Co-authored-by: Monalisha Mishra <[email protected]>
Co-authored-by: Kalash Shah <[email protected]>
Co-authored-by: Harsh | Push <[email protected]>
Co-authored-by: abhishek-01k <[email protected]>
Co-authored-by: Monalisha Mishra <[email protected]>
Co-authored-by: Kolade <[email protected]>
Co-authored-by: Abhishek <[email protected]>
  • Loading branch information
9 people authored Nov 6, 2024
1 parent 000294f commit c89d7ee
Show file tree
Hide file tree
Showing 5 changed files with 23,216 additions and 32,915 deletions.
77 changes: 65 additions & 12 deletions packages/restapi/src/lib/pushstream/PushStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,12 @@ export class PushStream extends EventEmitter {
listen: STREAM[],
newOptions: PushStreamInitializeProps
): Promise<void> {
this.uid = uuidv4();
this.listen = listen;
this.options = { ...this.options, ...newOptions };
await this.disconnect();
await this.connect();
await this.connect(true);
}

public async connect(): Promise<void> {
public async connect(reinit = false): Promise<void> {
return new Promise<void>((resolve, reject) => {
(async () => {
const shouldInitializeChatSocket =
Expand All @@ -140,10 +138,25 @@ export class PushStream extends EventEmitter {
this.listen.includes(STREAM.NOTIF_OPS) ||
this.listen.includes(STREAM.VIDEO);

let isChatSocketConnected = false;
let isNotifSocketConnected = false;
console.log('RestAPI::PushStream::connect - Initialization flags:', {
shouldInitializeChatSocket,
shouldInitializeNotifSocket,
});

let isChatSocketConnected = reinit ? this.chatSocketConnected : false;
let isNotifSocketConnected = reinit ? this.notifSocketConnected : false;
// Function to check and emit the STREAM.CONNECT event
const checkAndEmitConnectEvent = () => {
console.log(
'RestAPI::PushStream::connect - Checking conditions for STREAM.CONNECT event.',
{
shouldInitializeChatSocket,
isChatSocketConnected,
shouldInitializeNotifSocket,
isNotifSocketConnected,
}
);

if (
((shouldInitializeChatSocket && isChatSocketConnected) ||
!shouldInitializeChatSocket) &&
Expand All @@ -155,6 +168,8 @@ export class PushStream extends EventEmitter {
'RestAPI::PushStream::connect - Emitted STREAM.CONNECT'
);
resolve();
} else {
console.log('RestAPI::PushStream:: not emitting');
}
};

Expand All @@ -171,7 +186,20 @@ export class PushStream extends EventEmitter {
if (socketType === 'chat') {
isChatSocketConnected = false;
this.chatSocketConnected = false;

console.log(
'RestAPI::PushStream::handleSocketDisconnection - Chat socket disconnected. Decrementing chatSocketCount.',
'Previous chatSocketCount:',
this.chatSocketCount
);

this.chatSocketCount--;

console.log(
'RestAPI::PushStream::handleSocketDisconnection - New chatSocketCount:',
this.chatSocketCount
);

if (isNotifSocketConnected) {
if (
this.pushNotificationSocket &&
Expand All @@ -183,7 +211,6 @@ export class PushStream extends EventEmitter {
this.pushNotificationSocket.disconnect();
}
} else {
// Emit STREAM.DISCONNECT only if the notification socket was already disconnected
this.emit(STREAM.DISCONNECT);
console.log(
'RestAPI::PushStream::handleSocketDisconnection - Emitted STREAM.DISCONNECT for chat.'
Expand All @@ -192,7 +219,20 @@ export class PushStream extends EventEmitter {
} else if (socketType === 'notif') {
isNotifSocketConnected = false;
this.notifSocketConnected = false;

console.log(
'RestAPI::PushStream::handleSocketDisconnection - Notification socket disconnected. Decrementing notifSocketCount.',
'Previous notifSocketCount:',
this.notifSocketCount
);

this.notifSocketCount--;

console.log(
'RestAPI::PushStream::handleSocketDisconnection - New notifSocketCount:',
this.notifSocketCount
);

if (isChatSocketConnected) {
if (this.pushChatSocket && this.pushChatSocket.connected) {
console.log(
Expand All @@ -201,7 +241,6 @@ export class PushStream extends EventEmitter {
this.pushChatSocket.disconnect();
}
} else {
// Emit STREAM.DISCONNECT only if the chat socket was already disconnected
this.emit(STREAM.DISCONNECT);
console.log(
'RestAPI::PushStream::handleSocketDisconnection - Emitted STREAM.DISCONNECT for notification.'
Expand Down Expand Up @@ -277,7 +316,6 @@ export class PushStream extends EventEmitter {
console.log(
'RestAPI::PushStream::NotifSocket::Reconnect - Attempting to reconnect push notification socket...'
);
this.notifSocketCount++;
this.pushNotificationSocket.connect(); // Assuming connect() is the method to re-establish connection
} else {
// If pushNotificationSocket is already connected
Expand All @@ -295,20 +333,27 @@ export class PushStream extends EventEmitter {
};

if (this.pushChatSocket) {
checkAndEmitConnectEvent();
this.pushChatSocket.off(EVENTS.CONNECT);
this.pushChatSocket.on(EVENTS.CONNECT, async () => {
isChatSocketConnected = true;
this.chatSocketCount++;
this.chatSocketConnected = true;
checkAndEmitConnectEvent();
console.log(
`RestAPI::PushStream::EVENTS.CONNECT::Chat Socket Connected (ID: ${this.pushChatSocket.id})`
`RestAPI::PushStream::EVENTS.CONNECT:: Chat Socket Connected (ID: ${this.pushChatSocket.id})`
);
});

this.pushChatSocket.off(EVENTS.DISCONNECT);
this.pushChatSocket.on(EVENTS.DISCONNECT, async () => {
console.log(
'RestAPI::PushStream::ChatSocket::Disconnect - Chat socket disconnected.'
);
await handleSocketDisconnection('chat');
});

this.pushChatSocket.off(EVENTS.CHAT_GROUPS);
this.pushChatSocket.on(EVENTS.CHAT_GROUPS, (data: any) => {
try {
const modifiedData = DataModifier.handleChatGroupEvent(
Expand Down Expand Up @@ -347,6 +392,7 @@ export class PushStream extends EventEmitter {
}
});

this.pushChatSocket.off(EVENTS.CHAT_RECEIVED_MESSAGE);
this.pushChatSocket.on(
EVENTS.CHAT_RECEIVED_MESSAGE,
async (data: any) => {
Expand Down Expand Up @@ -386,6 +432,7 @@ export class PushStream extends EventEmitter {
}
);

this.pushChatSocket.off('SPACES');
this.pushChatSocket.on('SPACES', (data: any) => {
try {
const modifiedData = DataModifier.handleSpaceEvent(
Expand Down Expand Up @@ -426,6 +473,7 @@ export class PushStream extends EventEmitter {
}
});

this.pushChatSocket.off('SPACES_MESSAGES');
this.pushChatSocket.on('SPACES_MESSAGES', (data: any) => {
try {
const modifiedData = DataModifier.handleSpaceEvent(
Expand Down Expand Up @@ -455,6 +503,8 @@ export class PushStream extends EventEmitter {
}

if (this.pushNotificationSocket) {
checkAndEmitConnectEvent();
this.pushNotificationSocket.off(EVENTS.CONNECT);
this.pushNotificationSocket.on(EVENTS.CONNECT, async () => {
console.log(
`RestAPI::PushStream::NotifSocket::Connect - Notification Socket Connected (ID: ${this.pushNotificationSocket.id})`
Expand All @@ -465,13 +515,15 @@ export class PushStream extends EventEmitter {
checkAndEmitConnectEvent();
});

this.pushNotificationSocket.off(EVENTS.DISCONNECT);
this.pushNotificationSocket.on(EVENTS.DISCONNECT, async () => {
console.log(
'RestAPI::PushStream::NotifSocket::Disconnect - Notification socket disconnected.'
);
await handleSocketDisconnection('notif');
});

this.pushNotificationSocket.off(EVENTS.USER_FEEDS);
this.pushNotificationSocket.on(EVENTS.USER_FEEDS, (data: any) => {
try {
if (
Expand Down Expand Up @@ -514,6 +566,7 @@ export class PushStream extends EventEmitter {
}
});

this.pushNotificationSocket.off(EVENTS.USER_SPAM_FEEDS);
this.pushNotificationSocket.on(
EVENTS.USER_SPAM_FEEDS,
(data: any) => {
Expand Down Expand Up @@ -578,10 +631,10 @@ export class PushStream extends EventEmitter {
}
}

public info() {
public info(): { options: PushStreamInitializeProps; listen: STREAM[] } {
return {
options: this.options,
listen: this.listen,
listen: this.listen as STREAM[],
};
}

Expand Down
Loading

0 comments on commit c89d7ee

Please sign in to comment.