Skip to content

Commit

Permalink
feat: Add option to exclude pinned tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
navorite committed Oct 15, 2023
1 parent a21c2d2 commit 09bfe30
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
7 changes: 7 additions & 0 deletions src/lib/components/options/pages/General.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@
}}
/>

<Switch
title="Exculde pinned tabs from session"
checked={$settings.excludePinned}
on:change={() =>
settings.changeSetting('excludePinned', !$settings.excludePinned)}
/>

<TagEditor />

<div class="flex gap-2">
Expand Down
5 changes: 4 additions & 1 deletion src/lib/components/popup/sessions/CurrentSession.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@
//should fix inconsistency in update flags
timeout = setTimeout(async () => {
$session = await getSession($settings.urlFilterList);
$session = await getSession({
pinned: !$settings.excludePinned,
url: $settings.urlFilterList
});
if ($settings.selectionId === 'current')
selection.selectById($session.id);
Expand Down
3 changes: 2 additions & 1 deletion src/lib/stores/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export const settings = (() => {
autoSaveMaxSessions: autoSaveDefaults.autoSaveMaxSessions,
autoSaveTimer: autoSaveDefaults.autoSaveTimer,
tags: {},
doNotAskForTitle: true
doNotAskForTitle: true,
excludePinned: true
};

const { subscribe, set, update } = writable(defaultSettings);
Expand Down
1 change: 1 addition & 0 deletions src/lib/types/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,5 @@ export interface ESettings {
}
>;
doNotAskForTitle: boolean;
excludePinned: boolean;
}
22 changes: 7 additions & 15 deletions src/lib/utils/getSession.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import browser from 'webextension-polyfill';
import type {
ESession,
ETab,
QueryInfo,
URLFilterList,
compressOptions
} from '@/lib/types';
import type { ESession, ETab, QueryInfo, compressOptions } from '@/lib/types';
import { compress_options, tabAttr } from '@/lib/constants/shared';
import { compress as compressLZ } from 'lz-string';
import { getExtensionURL } from '@/lib/utils/extension';
Expand Down Expand Up @@ -52,7 +46,7 @@ export async function getTabs(
}

// Get current session - TODO: arg: options?: compressOptions goes undefined after 1st call
export async function getSession(urlFilterList?: URLFilterList) {
export async function getSession(queryInfo?: QueryInfo) {
const session: ESession = {
title: 'Current Session',
windows: [],
Expand All @@ -62,16 +56,14 @@ export async function getSession(urlFilterList?: URLFilterList) {
tabsNumber: 0
};

if (!queryInfo) queryInfo = {};

session.windows = await browser?.windows?.getAll();

for (const window of session.windows) {
window.tabs = await getTabs(
{
windowId: window.id,
url: urlFilterList as undefined
},
compress_options
);
queryInfo.windowId = window.id;

window.tabs = await getTabs(queryInfo, compress_options);

session.tabsNumber += window.tabs.length;
}
Expand Down

0 comments on commit 09bfe30

Please sign in to comment.