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

Fix a few more regressions from #4235. #4266

Merged
merged 2 commits into from
Sep 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/start/AuthScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,7 @@ class AuthScreen extends PureComponent<Props> {
id_token: credential.identityToken,
});

// TODO: Use a `URL` computation, for #4146.
openLink(`${this.props.realm.toString()}/complete/apple/?${params}`);
openLink(new URL(`/complete/apple/?${params}`, this.props.realm).toString());

// Currently, the rest is handled with the `zulip://` redirect,
// same as in the web flow.
Expand Down
9 changes: 8 additions & 1 deletion src/webview/js/generatedEs3.js
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,14 @@ var compiledWebviewJs = (function (exports) {
var handleMessageEvent = function handleMessageEvent(e) {
scrollEventsDisabled = true;
var decodedData = decodeURIComponent(escape(window.atob(e.data)));
var updateEvents = JSON.parse(decodedData);
var rawUpdateEvents = JSON.parse(decodedData);
var updateEvents = rawUpdateEvents.map(function (updateEvent) {
return _objectSpread2(_objectSpread2({}, updateEvent), updateEvent.auth ? {
auth: _objectSpread2(_objectSpread2({}, updateEvent.auth), {}, {
realm: new URL(updateEvent.auth.realm)
})
} : {});
});
updateEvents.forEach(function (uevent) {
eventLogger.maybeCaptureInboundEvent(uevent);
eventUpdateHandlers[uevent.type](uevent);
Expand Down
11 changes: 10 additions & 1 deletion src/webview/js/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,16 @@ const eventUpdateHandlers = {
const handleMessageEvent: MessageEventListener = e => {
scrollEventsDisabled = true;
const decodedData = decodeURIComponent(escape(window.atob(e.data)));
const updateEvents: WebViewUpdateEvent[] = JSON.parse(decodedData);
const rawUpdateEvents = JSON.parse(decodedData);
const updateEvents: WebViewUpdateEvent[] = rawUpdateEvents.map(updateEvent => ({
...updateEvent,
// A URL object doesn't round-trip through JSON; we get the string
// representation. So, "revive" it back into a URL object.
...(updateEvent.auth
? { auth: { ...updateEvent.auth, realm: new URL(updateEvent.auth.realm) } }
: {}),
}));
Comment on lines +622 to +630
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, kind of ugly, isn't it. :-/ Seems fine for a workaround, and I don't have any immediate ideas for a way to do this (and the similar spot in handleInitialLoad) more cleanly without a fair amount more code; but we'll want to keep an eye on this area whenever adding more complexity to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, my thoughts exactly. 😦


updateEvents.forEach((uevent: WebViewUpdateEvent) => {
eventLogger.maybeCaptureInboundEvent(uevent);
// $FlowFixMe
Expand Down