feat: improved extension and applied list

This commit is contained in:
Andre Henriques 2024-10-04 12:07:56 +01:00
parent 4b4eb1ab02
commit 69c60986ff
3 changed files with 24 additions and 35 deletions

View File

@ -392,7 +392,7 @@ class ApplicationService(
public fun findApplicationByUrl(user: UserDb, url: String, unique_url: String?): Application? {
if (unique_url != null) {
val unique =
val unique: List<Application> =
db.query(
"select * from applications where unique_url=? and user_id=?",
arrayOf(unique_url, user.id),
@ -405,7 +405,7 @@ class ApplicationService(
}
}
val applications =
val applications: List<Application> =
db.query(
"select * from applications where url=? and user_id=?",
arrayOf(url, user.id),

View File

@ -31,9 +31,9 @@ browser.runtime.onMessage.addListener(async (message, sender, sendResponse) => {
return;
}
if (message.type === "R_GET_DATA_FROM_PAGE") {
let windowList = (await browser.storage.local.get("windows")).windows ?? [];
if (windowList.length !== 1) return;
const tab = await browser.tabs.get(windowList[0]);
let windowList = (await browser.storage.local.get("windows")).windows;
if (!windowList) return;
const tab = await browser.tabs.get(windowList);
browser.tabs.sendMessage(tab.id, {
type: "GET_DATA_FROM_PAGE",
});
@ -41,8 +41,8 @@ browser.runtime.onMessage.addListener(async (message, sender, sendResponse) => {
}
if (message.type !== "MY_GET_URL") return;
let windowList = (await browser.storage.local.get("windows")).windows ?? [];
if (windowList.length !== 1) {
let windowList = (await browser.storage.local.get("windows")).windows;
if (!windowList) {
browser.tabs.sendMessage(sender.tab.id, {
type: "MY_GET_URL_R",
error: "Invalid number of pages marked as target",
@ -51,7 +51,7 @@ browser.runtime.onMessage.addListener(async (message, sender, sendResponse) => {
return;
}
const tab = await browser.tabs.get(windowList[0]);
const tab = await browser.tabs.get(windowList);
browser.tabs.sendMessage(tab.id, {
type: "GET_DATA_FROM_PAGE",
@ -66,45 +66,26 @@ browser.runtime.onMessage.addListener(async (message, sender, sendResponse) => {
async function startup() {
await browser.storage.local.set({
windows: [],
windows: null,
interesetWindows: [],
});
// Clear the menus from the prev install
// Clear the menus from the prev install / startup
browser.menus.removeAll();
browser.menus.create({
id: "mark-page",
title: "Mark Page As the Glassdoor target",
contexts: ["all"],
});
browser.menus.create({
id: "mark-page-clear",
title: "Clear Marked Pages",
title: "Mark Page As the Url target",
contexts: ["all"],
});
browser.menus.onClicked.addListener(async function (e, tab) {
let windowList =
(await browser.storage.local.get("windows")).windows ?? [];
console.log("test", e.menuItemId, e.menuItemId === "mark-page-clear");
if (e.menuItemId === "mark-page") {
console.log("marking page", tab);
if (windowList.includes(tab.id)) {
windowList = windowList.filter((a) => a !== tab.id);
} else {
windowList.push(tab.id);
}
} else if (e.menuItemId === "mark-page-clear") {
windowList = [];
console.log("clear");
}
await browser.storage.local.set({
windows: windowList,
windows: tab.id,
});
}
});
}
browser.runtime.onInstalled.addListener(startup);
browser.runtime.onStartup.addListener(startup);

View File

@ -25,8 +25,16 @@
<div class:animate-pulse={applicationStore.dragging?.id === item.id}>
<h2 class="text-lg text-blue-500">
{item.title}
{#if item.company}
<div class="text-violet-800">
@ {item.company}
</div>
{/if}
</h2>
<a href={item.url} class="text-violet-600 overflow-hidden whitespace-nowrap block">
<a
href={item.url}
class="text-violet-600 overflow-hidden whitespace-nowrap block"
>
{item.url}
</a>
</div>