Commit 5eb1ac77 authored by Alejandro Celaya's avatar Alejandro Celaya Committed by Alejandro Celaya

Rename toastMessagePushed message to toastMessageAdded to match actions from toast messenger

parent 42774ce6
...@@ -602,10 +602,11 @@ export class Sidebar implements Destroyable { ...@@ -602,10 +602,11 @@ export class Sidebar implements Destroyable {
} }
this._updateLayoutState(true); this._updateLayoutState(true);
this._sidebarRPC.call('sidebarOpened');
} }
close() { close() {
this._sidebarRPC.call('sidebarClosed');
if (this.iframeContainer) { if (this.iframeContainer) {
this.iframeContainer.style.marginLeft = ''; this.iframeContainer.style.marginLeft = '';
this.iframeContainer.classList.add('sidebar-collapsed'); this.iframeContainer.classList.add('sidebar-collapsed');
...@@ -618,7 +619,6 @@ export class Sidebar implements Destroyable { ...@@ -618,7 +619,6 @@ export class Sidebar implements Destroyable {
} }
this._updateLayoutState(false); this._updateLayoutState(false);
this._sidebarRPC.call('sidebarClosed');
} }
/** /**
......
...@@ -159,7 +159,7 @@ export class FrameSyncService { ...@@ -159,7 +159,7 @@ export class FrameSyncService {
*/ */
private _scheduleAnchorStatusUpdate: DebouncedFunction<[]>; private _scheduleAnchorStatusUpdate: DebouncedFunction<[]>;
/** Tells if the sidebar is currently open or closed */ /** Indicates if the sidebar is currently open or closed */
private _sidebarIsOpen: boolean; private _sidebarIsOpen: boolean;
// Test seam // Test seam
...@@ -198,7 +198,7 @@ export class FrameSyncService { ...@@ -198,7 +198,7 @@ export class FrameSyncService {
this._pendingAnchorStatusUpdates.clear(); this._pendingAnchorStatusUpdates.clear();
}, 10); }, 10);
this._sidebarIsOpen = true; this._sidebarIsOpen = false;
this._setupSyncToGuests(); this._setupSyncToGuests();
this._setupHostEvents(); this._setupHostEvents();
...@@ -532,10 +532,12 @@ export class FrameSyncService { ...@@ -532,10 +532,12 @@ export class FrameSyncService {
} }
private _setupToastMessengerEvents() { private _setupToastMessengerEvents() {
this._toastMessenger.on('toastMessagePushed', (message: ToastMessage) => { this._toastMessenger.on('toastMessageAdded', (message: ToastMessage) => {
// Forward hidden messages to "host" when sidebar is collapsed // Forward hidden messages to "host" when sidebar is collapsed, with the
// intention that another container can be used to render those messages
// there, ensuring screen readers announce them.
if (message.visuallyHidden && !this._sidebarIsOpen) { if (message.visuallyHidden && !this._sidebarIsOpen) {
this.notifyHost('toastMessagePushed', message); this.notifyHost('toastMessageAdded', message);
} }
}); });
this._toastMessenger.on('toastMessageDismissed', (messageId: string) => { this._toastMessenger.on('toastMessageDismissed', (messageId: string) => {
......
...@@ -1127,31 +1127,31 @@ describe('FrameSyncService', () => { ...@@ -1127,31 +1127,31 @@ describe('FrameSyncService', () => {
}); });
}); });
context('when a toast message is pushed', () => { context('when a toast message is added', () => {
it('forwards the message to the host if it is hidden and the sidebar is collapsed', () => { it('forwards the message to the host if it is hidden and the sidebar is collapsed', () => {
const message = { visuallyHidden: true }; const message = { visuallyHidden: true };
emitHostEvent('sidebarClosed'); emitHostEvent('sidebarClosed');
fakeToastMessenger.emit('toastMessagePushed', message); fakeToastMessenger.emit('toastMessageAdded', message);
assert.calledWith(hostRPC().call, 'toastMessagePushed', message); assert.calledWith(hostRPC().call, 'toastMessageAdded', message);
}); });
it('ignores the message if it is not hidden', () => { it('ignores the message if it is not hidden', () => {
const message = { visuallyHidden: false }; const message = { visuallyHidden: false };
emitHostEvent('sidebarClosed'); fakeToastMessenger.emit('toastMessageAdded', message);
fakeToastMessenger.emit('toastMessagePushed', message);
assert.neverCalledWith(hostRPC().call, 'toastMessagePushed', message); assert.neverCalledWith(hostRPC().call, 'toastMessageAdded', message);
}); });
it('ignores the message if the sidebar is not collapsed', () => { it('ignores the message if the sidebar is not collapsed', () => {
const message = { visuallyHidden: true }; const message = { visuallyHidden: true };
fakeToastMessenger.emit('toastMessagePushed', message); emitHostEvent('sidebarOpened');
fakeToastMessenger.emit('toastMessageAdded', message);
assert.neverCalledWith(hostRPC().call, 'toastMessagePushed', message); assert.neverCalledWith(hostRPC().call, 'toastMessageAdded', message);
}); });
}); });
......
...@@ -132,7 +132,7 @@ export class ToastMessengerService extends TinyEmitter { ...@@ -132,7 +132,7 @@ export class ToastMessengerService extends TinyEmitter {
isDismissed: false, isDismissed: false,
...message, ...message,
}); });
this.emit('toastMessagePushed', message); this.emit('toastMessageAdded', message);
if (autoDismiss) { if (autoDismiss) {
// Attempt to dismiss message after a set time period. NB: The message may // Attempt to dismiss message after a set time period. NB: The message may
......
...@@ -235,7 +235,7 @@ export type SidebarToHostEvent = ...@@ -235,7 +235,7 @@ export type SidebarToHostEvent =
/** /**
* The sidebar is asking the host to toast a message * The sidebar is asking the host to toast a message
*/ */
| 'toastMessagePushed' | 'toastMessageAdded'
/** /**
* The sidebar is asking the host to dismiss a toast message * The sidebar is asking the host to dismiss a toast message
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment