Skip to content

Commit

Permalink
Make tab group updates update date
Browse files Browse the repository at this point in the history
  • Loading branch information
justin13888 committed Oct 31, 2024
1 parent 4294b3a commit 171cccd
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions shiba/utils/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const updateTabGroup = async (id: string, updates: Partial<TabGroup>) =>
const tabGroup = await store.get(id);
if (tabGroup) {
Object.assign(tabGroup, updates);
tabGroup.timeModified = Date.now();
store.put(tabGroup);
} else {
return false;
Expand Down Expand Up @@ -222,6 +223,28 @@ export const getTabGroupById = async (
return db.get("tabGroups", tabGroupId);
};

/**
* Get tab group IDs by workspace ID.
* @param workspaceId Workspace ID
* @returns Array of tab group IDs if workspace exists. Otherwise, undefined.
*/
export const getTabGroupIdsByWorkspaceId = async (workspaceId: string): Promise<string[] | undefined> => {
// Check if workspace ID exists
const db = await dbPromise;
const workspace = await db.get("workspace", workspaceId);

if (workspace) {
const tx = db.transaction("tabGroups", "readonly");
const store = tx.objectStore("tabGroups");
const index = store.index("byTimeCreated");
const tabGroups = await index.getAll();

return tabGroups.map((tabGroup) => tabGroup.id);
}

return undefined;
}

/**
* @returns List of all tab groups
*/
Expand Down

0 comments on commit 171cccd

Please sign in to comment.