jerrod-lankford / google-voice-desktop-app

An electron shell wrapper around the google voice website
246 stars 37 forks source link

Multi-User Support #77

Closed eFail closed 3 years ago

eFail commented 3 years ago

Changes

Multi-User Support

This change adds support for switching between multiple Google Voice accounts under the user icon in the top-right corner of the Google Voice home page. image

Today, the application doesn't allow users to add multiple Google Voice accounts. This occurs because the application intercepts "new-window" events and opens the target URL using shell.openExternal(). The result is that when the user clicks the "Add another account" link in Google Voice, they're taken to a web page in their external browser to complete the action. This adds the new user in the browser context, but does not add it in the Electron application context, where it's actually needed.

To fix this, we grant an exception to the following two URLs:

Rather than open any of the above URLs in a new window, we have our main window navigate to them instead. The result is that the entire "Add another account" flow now takes place within the main window. Additionally, when switching between accounts, each account is loaded in the main window, rather than in a secondary window, which is what Google Voice does when used in a regular browser. In a future change, it would be possible to update the application such that additional accounts are opened in their own windows, and each account/window is given its own icon in the notification area. But for this initial solution, the desired behaviour is to only allow the user to use one account at a time.

"Reload" item in notification area context menu

For the two URLs mentioned above, we consider any URL starting with the noted prefix to be that URL (i.e. we use String.startsWith() for comparison purposes. In testing multi-user support, I have not yet found any scenario where this causes a URL to be navigated to which absolutely must be launched in a new window instead. However, in the even that this changelist ever does result in the user being permanently navigated away from the Google Voice home page without any way to get back, we also add a **Reload** item to the notification area context menu. When clicked, the main window simply reloads Google Voice.

This new menu item also serves as a convenient way of getting users unstuck when they encounter the infamous "white screen" bug, where the main application window becomes a blank canvas after returning to the application after a period of inactivity.

How Tested?