1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-11 10:10:25 +01:00

[PM-9455] FireFox back handling (#10867)

* Refactor `POPUP_VIEW_MEMORY` to use `disk` rather than memory for the browser extension.

- When FireFox opens the popup in an standalone window memory is lost, thus causing the `popup-route-history` to be lost and back navigation ceases to work

* spelling

* revert state definition change

* add `onUpdated` event for firefox

* rework observable handling

* remove unneeded `from`
This commit is contained in:
Nick Krantz 2024-09-17 08:42:57 -05:00 committed by GitHub
parent c05b6eb116
commit a42006763d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 3 deletions

View File

@ -1,4 +1,4 @@
import { switchMap, merge, delay, filter, concatMap, map } from "rxjs";
import { switchMap, merge, delay, filter, concatMap, map, first, of } from "rxjs";
import { CommandDefinition, MessageListener } from "@bitwarden/common/platform/messaging";
import {
@ -61,7 +61,18 @@ export class PopupViewCacheBackgroundService {
merge(
// on tab changed, excluding extension tabs
fromChromeEvent(chrome.tabs.onActivated).pipe(
switchMap(([tabInfo]) => BrowserApi.getTab(tabInfo.tabId)),
switchMap((tabs) => BrowserApi.getTab(tabs[0].tabId)),
switchMap((tab) => {
// FireFox sets the `url` to "about:blank" and won't populate the `url` until the `onUpdated` event
if (tab.url !== "about:blank") {
return of(tab);
}
return fromChromeEvent(chrome.tabs.onUpdated).pipe(
first(),
switchMap(([tabId]) => BrowserApi.getTab(tabId)),
);
}),
map((tab) => tab.url || tab.pendingUrl),
filter((url) => !url.startsWith(chrome.runtime.getURL(""))),
),

View File

@ -2,7 +2,7 @@ import { GlobalState } from "./global-state";
import { KeyDefinition } from "./key-definition";
/**
* A provider for geting an implementation of global state scoped to the given key.
* A provider for getting an implementation of global state scoped to the given key.
*/
export abstract class GlobalStateProvider {
/**