Skip to content

Commit

Permalink
[FB] PWA | Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
surapunoyousei committed Nov 7, 2023
1 parent bbeed17 commit 2c0e4a9
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions browser/components/sessionstore/SessionSaver.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -250,37 +250,36 @@ var SessionSaverInternal = {
}

stopWatchStart("COLLECT_DATA_MS");
let state = lazy.SessionStore.getCurrentState(forceUpdateAllWindows);
let windows = state.windows;

for (let window of windows) {
for (let tab of window.tabs) {
let ssbEnabled = tab.floorpSSB == "true";
if (ssbEnabled && windows.length == 1){
this.updateLastSaveTime();
return Promise.resolve();
} else if (ssbEnabled) {
// Remove Window
delete state.windows[window];
}
}
// Floorp Injections
let state = lazy.SessionStore.getCurrentState(forceUpdateAllWindows);

function shouldUpdateLastSaveTime(ssbEnabled, windows) {
return ssbEnabled && windows.length === 1;
}

for (let windowKey in state.windows) {
let window = state.windows[windowKey];

function shouldRemoveWindow(ssbEnabled) {
return ssbEnabled;
}

function removeWindowFromState(windowKey) {
delete state.windows[windowKey];
delete state._closedWindows[windowKey];
delete state.windows.empty_slot;
}

for (let window of state.windows) {
for (let tab of window.tabs) {
let ssbEnabled = tab.floorpSSB == "true";
if (ssbEnabled && Object.keys(state.windows).length == 1){
let ssbEnabled = tab.floorpSSB === "true";
if (shouldUpdateLastSaveTime(ssbEnabled, state.windows)) {
this.updateLastSaveTime();
return Promise.resolve();
} else if (ssbEnabled) {
// Remove Window
delete state.windows[windowKey];
delete state._closedWindows[windowKey];
} else if (shouldRemoveWindow(ssbEnabled)) {
removeWindowFromState(window.key);
}
}
}

lazy.PrivacyFilter.filterPrivateWindowsAndTabs(state);

// Make sure we only write worth saving tabs to disk.
Expand Down

0 comments on commit 2c0e4a9

Please sign in to comment.