mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-09 19:28:06 +01:00
[PM-5189] Working through content script port improvement
This commit is contained in:
parent
2174bf1c0c
commit
ce35ce4183
@ -68,8 +68,9 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
private delayedCloseTimeout: number | NodeJS.Timeout;
|
private delayedCloseTimeout: number | NodeJS.Timeout;
|
||||||
private startInlineMenuFadeInSubject = new Subject<void>();
|
private startInlineMenuFadeInSubject = new Subject<void>();
|
||||||
private cancelInlineMenuFadeInSubject = new Subject<boolean>();
|
private cancelInlineMenuFadeInSubject = new Subject<boolean>();
|
||||||
|
private startUpdateInlineMenuPositionSubject = new Subject<chrome.runtime.MessageSender>();
|
||||||
|
private cancelUpdateInlineMenuPositionSubject = new Subject<void>();
|
||||||
private repositionInlineMenuSubject = new Subject<chrome.runtime.MessageSender>();
|
private repositionInlineMenuSubject = new Subject<chrome.runtime.MessageSender>();
|
||||||
private updateInlineMenuPositionSubject = new Subject<chrome.runtime.MessageSender>();
|
|
||||||
private rebuildSubFrameOffsetsSubject = new Subject<chrome.runtime.MessageSender>();
|
private rebuildSubFrameOffsetsSubject = new Subject<chrome.runtime.MessageSender>();
|
||||||
private focusedFieldData: FocusedFieldData;
|
private focusedFieldData: FocusedFieldData;
|
||||||
private isFieldCurrentlyFocused: boolean = false;
|
private isFieldCurrentlyFocused: boolean = false;
|
||||||
@ -161,19 +162,20 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
switchMap((sender) => this.repositionInlineMenu(sender)),
|
switchMap((sender) => this.repositionInlineMenu(sender)),
|
||||||
)
|
)
|
||||||
.subscribe();
|
.subscribe();
|
||||||
this.updateInlineMenuPositionSubject
|
|
||||||
.pipe(
|
|
||||||
debounceTime(250),
|
|
||||||
switchMap((sender) => this.updateInlineMenuPositionAfterRepositionEvent(sender)),
|
|
||||||
)
|
|
||||||
.subscribe();
|
|
||||||
this.rebuildSubFrameOffsetsSubject
|
this.rebuildSubFrameOffsetsSubject
|
||||||
.pipe(
|
.pipe(
|
||||||
throttleTime(600),
|
throttleTime(650),
|
||||||
switchMap((sender) => this.rebuildSubFrameOffsets(sender)),
|
switchMap((sender) => this.rebuildSubFrameOffsets(sender)),
|
||||||
)
|
)
|
||||||
.subscribe();
|
.subscribe();
|
||||||
|
|
||||||
|
merge(
|
||||||
|
this.startUpdateInlineMenuPositionSubject.pipe(debounceTime(150)),
|
||||||
|
this.cancelUpdateInlineMenuPositionSubject,
|
||||||
|
)
|
||||||
|
.pipe(switchMap((sender) => this.updateInlineMenuPositionAfterRepositionEvent(sender)))
|
||||||
|
.subscribe();
|
||||||
|
|
||||||
// FadeIn Observable behavior
|
// FadeIn Observable behavior
|
||||||
merge(
|
merge(
|
||||||
this.startInlineMenuFadeInSubject.pipe(debounceTime(150)),
|
this.startInlineMenuFadeInSubject.pipe(debounceTime(150)),
|
||||||
@ -449,8 +451,10 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
*
|
*
|
||||||
* @param sender - The sender of the message
|
* @param sender - The sender of the message
|
||||||
*/
|
*/
|
||||||
private async updateInlineMenuPositionAfterRepositionEvent(sender: chrome.runtime.MessageSender) {
|
private async updateInlineMenuPositionAfterRepositionEvent(
|
||||||
if (!this.isFieldCurrentlyFocused) {
|
sender: chrome.runtime.MessageSender | void,
|
||||||
|
) {
|
||||||
|
if (!sender || !this.isFieldCurrentlyFocused) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1363,7 +1367,8 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async triggerSubFrameFocusInRebuild({ sender }: chrome.runtime.Port) {
|
private async triggerSubFrameFocusInRebuild({ sender }: chrome.runtime.Port) {
|
||||||
this.rebuildSubFrameOffsetsSubject.next(sender);
|
await this.rebuildSubFrameOffsets(sender);
|
||||||
|
this.cancelUpdateInlineMenuPositionSubject.next();
|
||||||
this.repositionInlineMenuSubject.next(sender);
|
this.repositionInlineMenuSubject.next(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1387,7 +1392,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
this.rebuildSubFrameOffsetsSubject.next(sender);
|
this.rebuildSubFrameOffsetsSubject.next(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateInlineMenuPositionSubject.next(sender);
|
this.startUpdateInlineMenuPositionSubject.next(sender);
|
||||||
};
|
};
|
||||||
|
|
||||||
private async closeInlineMenuAfterReposition(sender: chrome.runtime.MessageSender) {
|
private async closeInlineMenuAfterReposition(sender: chrome.runtime.MessageSender) {
|
||||||
|
Loading…
Reference in New Issue
Block a user