-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
meta: Add working identities query inside component
Will expand upon this later.
- Loading branch information
1 parent
eeba1e2
commit 6beed27
Showing
1 changed file
with
25 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
) | ||
} |