-
Notifications
You must be signed in to change notification settings - Fork 829
fix: share main webview session with internal video chat window #3359
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
Open
rodrigok
wants to merge
8
commits into
master
Choose a base branch
from
chore/videoconf-new-window-session-share
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
93a4c68
fix: share main webview session with internal video chat window
rodrigok c5f4cbf
fix: harden video call window session sharing for production
jeanfbrito 10f31d5
feat: openInMainWindow bridge to navigate the main window from the vi…
rodrigok 3e93e6c
fix: route open-in-main-window to the call's origin server
jeanfbrito 389c987
feat: add videoCallWindow.close() bridge to close the video call window
rodrigok c2575af
fix: focus the existing video call window when reopening the same con…
rodrigok 6db25a2
fix: open external links from the video call window in the system bro…
rodrigok 5e6f239
fix: address review feedback on video call session sharing
jeanfbrito File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| type IpcListener = (event: unknown, path: string) => void; | ||
|
|
||
| const ipcListeners = new Map<string, IpcListener>(); | ||
| const on = jest.fn((channel: string, listener: IpcListener) => { | ||
| ipcListeners.set(channel, listener); | ||
| }); | ||
|
|
||
| jest.mock('electron', () => ({ | ||
| ipcRenderer: { | ||
| on: (channel: string, listener: IpcListener) => on(channel, listener), | ||
| }, | ||
| })); | ||
|
|
||
| const emit = (path: string) => { | ||
| const listener = ipcListeners.get('navigate-to-route'); | ||
| if (!listener) throw new Error('navigate-to-route listener not registered'); | ||
| listener({}, path); | ||
| }; | ||
|
|
||
| describe('servers/preload/navigateToRoute', () => { | ||
| let onNavigateToRoute: (cb: (path: string) => void) => void; | ||
| let listenToNavigateToRouteRequests: () => void; | ||
|
|
||
| beforeEach(async () => { | ||
| jest.resetModules(); | ||
| ipcListeners.clear(); | ||
| on.mockClear(); | ||
| const mod = await import('./navigateToRoute'); | ||
| onNavigateToRoute = mod.onNavigateToRoute; | ||
| listenToNavigateToRouteRequests = mod.listenToNavigateToRouteRequests; | ||
| }); | ||
|
|
||
| it('registers the ipcRenderer listener only once', () => { | ||
| listenToNavigateToRouteRequests(); | ||
| listenToNavigateToRouteRequests(); | ||
| expect(on).toHaveBeenCalledTimes(1); | ||
| expect(on).toHaveBeenCalledWith('navigate-to-route', expect.any(Function)); | ||
| }); | ||
|
|
||
| it('delivers the path to a callback registered before the event', () => { | ||
| listenToNavigateToRouteRequests(); | ||
| const cb = jest.fn(); | ||
| onNavigateToRoute(cb); | ||
|
|
||
| emit('/channel/general'); | ||
|
|
||
| expect(cb).toHaveBeenCalledWith('/channel/general'); | ||
| }); | ||
|
|
||
| it('buffers a path that arrives before the callback registers, then flushes once', () => { | ||
| listenToNavigateToRouteRequests(); | ||
|
|
||
| emit('/admin/rooms'); | ||
|
|
||
| const cb = jest.fn(); | ||
| onNavigateToRoute(cb); | ||
| expect(cb).toHaveBeenCalledTimes(1); | ||
| expect(cb).toHaveBeenCalledWith('/admin/rooms'); | ||
|
|
||
| // The buffered path is consumed: a later registration gets nothing extra. | ||
| const cb2 = jest.fn(); | ||
| onNavigateToRoute(cb2); | ||
| expect(cb2).not.toHaveBeenCalled(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import { ipcRenderer } from 'electron'; | ||
|
|
||
| let navigateCallback: ((path: string) => void) | null = null; | ||
| let pendingPath: string | null = null; | ||
|
|
||
| // Registered by the web client to receive in-app route changes requested by the | ||
| // desktop shell (e.g. from the standalone video call window). `path` is a | ||
| // server-relative route, e.g. "/channel/general". | ||
| export const onNavigateToRoute = (callback: (path: string) => void): void => { | ||
| navigateCallback = callback; | ||
| if (pendingPath) { | ||
| callback(pendingPath); | ||
| pendingPath = null; | ||
| } | ||
| }; | ||
|
|
||
| let listening = false; | ||
|
|
||
| // Relays the main-process 'navigate-to-route' event (delivered to this preload's | ||
| // ipcRenderer, since the server webview is contextIsolated) to the web client's | ||
| // callback. Buffers the latest path if a request arrives before the web client | ||
| // has registered its handler. | ||
| export const listenToNavigateToRouteRequests = (): void => { | ||
| if (listening) { | ||
| return; | ||
| } | ||
| listening = true; | ||
|
|
||
| ipcRenderer.on('navigate-to-route', (_event, path: string) => { | ||
| if (navigateCallback) { | ||
| navigateCallback(path); | ||
| } else { | ||
| pendingPath = path; | ||
| } | ||
| }); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.