zulip-desktop icon indicating copy to clipboard operation
zulip-desktop copied to clipboard

[WIP] Add zulip:// URI scheme for navigating within app

Open kanishk98 opened this issue 5 years ago • 25 comments


What's this PR do?

Registers links starting with zulip:// to open with the Zulip app. Redirects users with installed app to the correct narrow and server (only if the domain is already saved) in the desktop app.

Any background context you want to provide?

Discussion at #470.

Screenshots?

deeplinking

You have tested this PR on:

  • [x] Windows
  • [ ] Linux/Ubuntu
  • [x] macOS

kanishk98 avatar Apr 08 '19 15:04 kanishk98

Is this compatible with the Zulip Android app, which also uses zulip:// URLs? If we’re going to do this, we should make sure to keep them compatible.

andersk avatar Apr 08 '19 20:04 andersk

If we’re going to do this, we should make sure to keep them compatible.

@andersk can you explain what you mean by compatible here?

kanishk98 avatar Apr 09 '19 01:04 kanishk98

The mobile app's existing use of zulip:// URLs is only for an authentication flow.

But yes, we should coordinate with the mobile team on what URL syntax we want to use for this because the two apps will end up sharing that syntax.

timabbott avatar Apr 09 '19 17:04 timabbott

For the benefit of everyone in this thread, I texted Boris on czo yesterday and asked him to have a look at this PR. Waiting for his suggestions. :)

kanishk98 avatar Apr 10 '19 06:04 kanishk98

I don't think we need to call the execPath. Also, you need to register the app's protocol in the package.json. https://github.com/oikonomopo/electron-deep-linking-mac-win https://stackoverflow.com/questions/43912119/open-app-and-pass-parameters-with-deep-linking-using-electron-macos https://discuss.atom.io/t/enable-deep-linking/27518/7

akashnimare avatar Apr 12 '19 11:04 akashnimare

I don't think we need to call the execPath.

Right, I wasn't sure about this earlier. We should note that this will raise an error in development mode when a developer tries to use this feature because then if Zulip isn't installed the conventional way, it won't find an executable. (happened to me while testing) I ran npm run dist and worked fine. I'll remove execPath.

Also, you need to register the app's protocol in the package.json.

I don't see the need - the system registers the app's protocol regardless, if we just use the current method. Can you explain why this is required if the feature works both on npm start and npm run dist?

kanishk98 avatar Apr 12 '19 17:04 kanishk98

I don't see the need - the system registers the app's protocol regardless, if we just use the current method.

I think this is required for macOS.

https://stackoverflow.com/questions/45809064/registering-custom-protocol-at-installation-process-in-electron-app

akashnimare avatar Apr 12 '19 18:04 akashnimare

I think this is required for macOS.

I checked it on a Mac in debug mode, without creating an executable. It worked well then. I'll check once more to make sure, and also create an executable for testing.

I'll post back later tonight (I'll have to borrow a Mac, can't do that immediately)

kanishk98 avatar Apr 12 '19 18:04 kanishk98

I'll post back later tonight

I checked this on a Mac and the protocol is registered, but since the open-url event passes the URL as a string rather than as an array (which is the case on Windows), redirection doesn't happen on macOS. Simple enough problem, I'll push a fix.

kanishk98 avatar Apr 13 '19 05:04 kanishk98

Alright, I've done a couple of things.

  1. Made sure that the scheme works for Windows, both in dev and production. (the API needs different arguments in different cases for Windows)
  2. Fixed macOS redirection problems.
  3. Added a reload view to make redirection more obvious.

@akashnimare let me know if it works for you now.

kanishk98 avatar Apr 13 '19 13:04 kanishk98

Haven't tested this yet, just out of curiosity from the gif, does this work if the app is not currently running.

abhigyank avatar Apr 15 '19 13:04 abhigyank

Haven't tested this yet, just out of curiosity from the gif, does this work if the app is not currently running.

It does, tested that. :)

kanishk98 avatar Apr 15 '19 13:04 kanishk98

@kanishk98 i think we only need the URI scheme for the production environment and not for the dev environment. Also, i want to work on this. Ping me if some work is required on this.

vsvipul avatar May 14 '19 09:05 vsvipul

i think we only need the URI scheme for the production environment and not for the dev environment.

I agree, but it's not really that big of a hassle to include it in the dev environment. Just an extra condition that makes the experience better for Windows developers too.

Also, i want to work on this. Ping me if some work is required on this.

Thanks a ton! I didn't see this earlier, so I ended up testing out electron-builder configs that focus and start the app when the browser receives a zulip:// URL. That seems to work properly right now, and I'm trying to figure how to catch the URL on Linux systems (again, macOS and Windows work well with just the Electron APIs). I'll text you if I get stuck with some Linux stuff.

kanishk98 avatar May 19 '19 03:05 kanishk98

@kanishk98 is this ready to review or still WIP?

akashnimare avatar Jun 10 '19 16:06 akashnimare

This is WIP, I encountered a few bugs in the redirect logic that I haven't fixed yet.

kanishk98 avatar Jun 10 '19 16:06 kanishk98

@kanishk98 i went through the PR. What seems to be the issue here? Maybe, i can help.

vsvipul avatar Jun 12 '19 15:06 vsvipul

What seems to be the issue here? Maybe, i can help

That'd be great. Basically the app doesn't redirect to the intended URL if it's not running (the URL just opens up the app and then it stays there). I'm working on this right now, so I'll PM you for some help.

kanishk98 avatar Jun 12 '19 19:06 kanishk98

To update everyone keeping an eye on this PR, there are some problems with <webview> that cause bugs with the redirection flow in the app. I've not been able to identify them, mostly because they're pretty erratic across operating systems and I think that it's best if I keep this on hold until work with the move to BrowserView is complete. That should address the problems with this PR.

kanishk98 avatar Jul 27 '19 19:07 kanishk98

@kanishk98 are we planning to work on this after BrowserView PR gets merge?

akashnimare avatar Aug 13 '19 20:08 akashnimare

are we planning to work on this after BrowserView PR gets merge?

Yeah, I've rechecked the logic for the redirection and the reloading of the <webview> (controlled by the loadURL() method, not us) is pretty erratic. I'd suggest we wait until that happens because we'll have to change things a bit anyway.

kanishk98 avatar Aug 14 '19 09:08 kanishk98

Heads up @kanishk98, we just merged some commits that conflict with the changes your made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the upstream/master branch and resolve your pull request's merge conflicts accordingly.

zulipbot avatar Nov 13 '19 09:11 zulipbot

An alternative to this, or addition, would be a way to paste a URL into the Zulip App. I get emails with Zulip App URLs. If I open them in the browser, it loads the web app. The emails would have to use the zulip:// scheme instead of https:// for this PR to work with emails. But that would be confusing if the user isn't using the app.

A way to handle any URL may be to paste the URL into the Zulip App search bar and hit enter and have the Zulip App recognize and go to it.

six8 avatar Jul 24 '20 16:07 six8

But that would be confusing if the user isn't using the app

Hmm, I'm not sure if I agree with this statement. I'd say that OSes are fairly vocal when redirecting users to desktop apps from URLs - think Windows when it asks if you want to open a Zoom link in the app. Shouldn't that make things obvious to the user?

kanishk98 avatar Jul 28 '20 01:07 kanishk98

@akashnimare in case we're planning to pick this up this week or so, I can fix the conflicts and work with @manavmehta on this.

kanishk98 avatar Jul 28 '20 01:07 kanishk98