Skip to content

Commit

Permalink
meta: Add working identities query inside component
Browse files Browse the repository at this point in the history
Will expand upon this later.
  • Loading branch information
donovanglover committed May 2, 2024
1 parent eeba1e2 commit 6beed27
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
export default function RootPage (): React.ReactElement {
const status = browser.contextualIdentities !== undefined ? 'All good to go.' : 'browser.contextualIdentities not available.'

const eventHandler = (event: React.MouseEvent<HTMLButtonElement>): void => {
if (event.currentTarget.value === 'create') {
browser.tabs.create({
url: 'about:blank',
cookieStoreId: '1'
}).then().catch(e => { console.log(e) })
}
}

browser.contextualIdentities.query({})
.then((identities) => {
console.log(identities)

if (identities.length === 0) {
console.log('No identities returned from the API.')
}
}).catch(err => {
console.warn(err)
})

return (
<div className="w-96">
<h1 className='text-red-100'>Vite + React</h1>
<div className="p-4">
<p>{status}</p>
<button className='text-center text-4xl font-bold' onClick={eventHandler}>New Tab Identity</button>
</div>
)
}

0 comments on commit 6beed27

Please sign in to comment.