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

[No QA] Add support for Pusher responses #9219

Merged
merged 12 commits into from
Jun 2, 2022
Merged

[No QA] Add support for Pusher responses #9219

merged 12 commits into from
Jun 2, 2022

Conversation

Gonals
Copy link
Contributor

@Gonals Gonals commented May 30, 2022

Details

We haven't migrated any commands yet, so we need to add some changes in Web to test this.

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/211236

Tests

  1. In web-E, you'll need to add an Onyx response to a command to test this. I simply added this line here, so it would be triggered when a new comment is added on the chat:
$onyxUpdate[] = ['onyxMethod' => 'Report_AddCommentSet', 'key' =>'Nepal', 'value' => 'Test'];
  1. You can just log the JSON to the console here to make sure it is received.
  2. After that, open a chat in NewDot and send a message. In a second or two you should see the response showing up in the console.
  3. Tail the logs.
  4. Remove or change one of the keys in onyxUpdate and send a message to the chat. The response that shows up in the console should now be an empty array, and a warning indicating that the response was not correctly formatted should show in the logs.

@Gonals Gonals requested review from marcaaron and a team as code owners May 30, 2022 13:53
@Gonals Gonals self-assigned this May 30, 2022
@melvin-bot melvin-bot bot requested review from tylerkaraszewski and removed request for a team May 30, 2022 13:53
@Gonals Gonals changed the title [No QA] Add support for Pusher responses [HOLD][No QA] Add support for Pusher responses May 30, 2022
@Gonals Gonals removed the request for review from tylerkaraszewski May 30, 2022 14:07
marcaaron
marcaaron previously approved these changes May 30, 2022
function getCurrentRequest() {
if (currentRequest === null) {
return Promise.resolve();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB, could also initialize/reset with a Promise.resolve() but this works.

@@ -11,4 +11,6 @@ export default {
PREFERRED_LOCALE: 'preferredLocale',
EXPENSIFY_CARD_UPDATE: 'expensifyCardUpdate',
SCREEN_SHARE_REQUEST: 'screenshareRequest',
ONYX_API_UPDATE: 'onyxApiUpdate',
ONYX_API_UPDATE_CHUNK: 'chunked-onyxApiUpdate',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After these changes we won't need the prepend chunked to channel names.

cc @danieldoglas to confirm

Copy link
Contributor Author

@Gonals Gonals Jun 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nice! That one seems fully approved, so it should be merging today, right @alex-mechler? I can update this then :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just self merged it, since all reviewers had approved!

That said, we still need the chunked- channel to be listened to for now, since Web-E will still be sending them until we make the changes to stop sending them. That is HELD on the linked PR getting deployed to production.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can move ahead with this PR as-is and remove that afterwards?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, that sounds fine. I have to remove the other chunked- channels later from this repo anyways.

src/libs/Pusher/pusher.js Outdated Show resolved Hide resolved
}

function onPusherResubscribeToPrivateUserChannel() {
NetworkConnection.triggerReconnectionCallbacks('Pusher re-subscribed to private user channel');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opinion (non-blocking): It stuck out to me that the Pusher library is now triggering and aware of the reconnection callbacks. Feels like it now has extra responsibility it should not have. I would maybe put this into something like a PusherUtils or just have it in User eventually (after the usages in Report.js are cleaned up). But not sure we need to do this now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm. User seems like a weird place to me, but creating PusherUtils may be a good idea. Do we expect to create more stuff that would go in there?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we expect to create more stuff that would go in there?

Unsure, but I suspect that this subscription will eventually be moved into something like a "User Logged In" or "App Initialized" action since it will happen every time the app starts up.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like putting it into PusherUtils 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved!

yuwenmemon
yuwenmemon previously approved these changes Jun 1, 2022
src/libs/Pusher/pusher.js Outdated Show resolved Hide resolved
}

function onPusherResubscribeToPrivateUserChannel() {
NetworkConnection.triggerReconnectionCallbacks('Pusher re-subscribed to private user channel');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like putting it into PusherUtils 👍

@Gonals Gonals changed the title [HOLD][No QA] Add support for Pusher responses [No QA] Add support for Pusher responses Jun 2, 2022
@Gonals Gonals dismissed stale reviews from yuwenmemon and marcaaron via 29ad302 June 2, 2022 08:50
@Gonals
Copy link
Contributor Author

Gonals commented Jun 2, 2022

OFF HOLD and comments addressed!

@yuwenmemon
Copy link
Contributor

@marcaaron all yours

@marcaaron marcaaron merged commit afa9087 into main Jun 2, 2022
@marcaaron marcaaron deleted the alberto-onyxUpdate branch June 2, 2022 17:59
@marcaaron
Copy link
Contributor

🚀

@OSBotify
Copy link
Contributor

OSBotify commented Jun 2, 2022

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

OSBotify commented Jun 6, 2022

🚀 Deployed to staging by @marcaaron in version: 1.1.72-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

OSBotify commented Jun 8, 2022

🚀 Deployed to production by @yuwenmemon in version: 1.1.73-2 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Log.hmmm('[Report] Failed to subscribe to Pusher channel', false, {error, pusherChannelName, eventName});
}

Pusher.subscribe(pusherChannelName, eventName, onEventPush, onPusherResubscribeToPrivateUserChannel)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here there was not the isChunked but in the reportUtils it is back.

@@ -302,6 +304,18 @@ function subscribeToUserEvents() {

const pusherChannelName = `private-encrypted-user-accountID-${currentUserAccountID}${CONFIG.PUSHER.SUFFIX}`;

// Receive any relevant Onyx updates from the server
PusherUtils.subscribeToPrivateUserChannelEvent(Pusher.TYPE.ONYX_API_UPDATE, currentUserAccountID, (pushJSON) => {
SequentialQueue.getCurrentRequest().then(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey everyone 👋🏼 I know it's been a little while, but can someone explain why we needed to add SequentialQueue.getCurrentRequest() here? It's not clear to me what it's doing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I understand why this was added now, I tried to summarize it as concisely as possible here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was always a longer goal of mine to add a NETWORK.md and that explanation would be perfect for it (or added as a comment here).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants