Skip to content
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

[PM-18549] Do not clear route or view persistence on tab change #13523

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { switchMap, merge, delay, filter, concatMap, map, first, of } from "rxjs";
import { switchMap, delay, filter, concatMap } from "rxjs";

import { CommandDefinition, MessageListener } from "@bitwarden/common/platform/messaging";
import {
Expand All @@ -14,7 +12,6 @@
GlobalStateProvider,
} from "@bitwarden/common/platform/state";

import { BrowserApi } from "../browser/browser-api";
import { fromChromeEvent } from "../browser/from-chrome-event";

const popupClosedPortName = "new_popup";
Expand Down Expand Up @@ -78,27 +75,9 @@
.pipe(concatMap(() => this.popupViewCacheState.update(() => null)))
.subscribe();

merge(
// on tab changed, excluding extension tabs
fromChromeEvent(chrome.tabs.onActivated).pipe(
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(""))),
),

// on popup closed, with 2 minute delay that is cancelled by re-opening the popup
fromChromeEvent(chrome.runtime.onConnect).pipe(
// on popup closed, with 2 minute delay that is cancelled by re-opening the popup
fromChromeEvent(chrome.runtime.onConnect)

Check warning on line 79 in apps/browser/src/platform/services/popup-view-cache-background.service.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/platform/services/popup-view-cache-background.service.ts#L79

Added line #L79 was not covered by tests
.pipe(
filter(([port]) => port.name === popupClosedPortName),
switchMap(([port]) =>
fromChromeEvent(port.onDisconnect).pipe(
Expand All @@ -108,9 +87,7 @@
),
),
),
),
)
.pipe(switchMap(() => this.clearState()))
)
.subscribe();
}

Expand Down