Skip to content

Commit b71bf19

Browse files
committed
fix block /unblock
1 parent 7e71eba commit b71bf19

File tree

2 files changed

+30
-32
lines changed

2 files changed

+30
-32
lines changed

src/service-worker.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,9 @@
1-
import { storageUtils } from "./lib/storage";
2-
31
chrome.action.setBadgeBackgroundColor({
42
color: [0, 0, 0, 255],
53
});
64
chrome.action.setBadgeTextColor({ color: "#FFFFFF" });
75

86
chrome.runtime.onMessage.addListener(async (message, sender, sendResponse) => {
9-
if (message.type === "UPDATED_RULE_STATS") {
10-
const rules = await storageUtils.loadRules();
11-
console.log("message stats", message, rules);
12-
const updatedRules = rules.map((rule) =>
13-
message.rules.find((messageRule) =>
14-
messageRule.id === rule.id ? message.rule : rule,
15-
),
16-
);
17-
await storageUtils.saveRules(updatedRules);
18-
}
19-
207
if (message.type === "updateBadge") {
218
chrome.action.setBadgeTextColor({
229
color: "#FFFFFF",

src/side-panel-app.tsx

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ const App: React.FC = () => {
6464
"1.00": "Explicitly about this context",
6565
};
6666

67-
const getBlockedElements = async (tabId) => {};
68-
6967
useEffect(() => {
7068
const initializeGetActiveTab = async () => {
7169
const [tab] = await chrome.tabs.query({
@@ -219,19 +217,21 @@ const App: React.FC = () => {
219217
if (output) {
220218
contextScores = output.context_scores;
221219
}
220+
console.log("Output from AI model:", output);
222221
if (contextScores) {
223222
const maxScore = Math.max(...Object.values(contextScores));
224223
if (maxScore <= contextScore[0]) {
224+
console.log("Unblock safe");
225225
setUnblockSafe(true);
226226
return;
227227
}
228228
}
229229
} catch (err) {
230230
setError(err);
231231
setHasAnalysis(false);
232+
setUnblockSafe(false);
232233
} finally {
233234
setIsLoading(false);
234-
setUnblockSafe(false);
235235
controller.abort();
236236
}
237237
};
@@ -488,22 +488,33 @@ const App: React.FC = () => {
488488
</CardTitle>
489489
</div>
490490
</CardHeader>
491-
<CardContent className="py-3 space-y-2">
492-
<div className="text-sm text-muted-foreground">
493-
{unblockSafe
494-
? "This content does not appear to be relevant to the blocked context based on surrounding text analysis."
495-
: "This content appears to be relevant to the blocked context based on surrounding text analysis."}
496-
</div>
497-
<div className="flex items-center gap-2 p-2 text-sm rounded-md bg-primary/10">
498-
<AlertCircle className="w-4 h-4 text-primary" />
499-
<span className="text-primary">
500-
Recommended:{" "}
501-
{unblockSafe
502-
? "Unblock content"
503-
: "Keep content blocked"}
504-
</span>
505-
</div>
506-
</CardContent>
491+
{unblockSafe ? (
492+
<CardContent className="py-3 space-y-2">
493+
<div className="text-sm text-muted-foreground">
494+
This content does not appear to be relevant to the
495+
blocked context based on surrounding text analysis.
496+
</div>
497+
<div className="flex items-center gap-2 p-2 text-sm rounded-md bg-primary/10">
498+
<AlertCircle className="w-4 h-4 text-primary" />
499+
<span className="text-primary">
500+
Recommended: Unblock content
501+
</span>
502+
</div>
503+
</CardContent>
504+
) : (
505+
<CardContent className="py-3 space-y-2">
506+
<div className="text-sm text-muted-foreground">
507+
This content appears to be relevant to the blocked
508+
context based on surrounding text analysis.
509+
</div>
510+
<div className="flex items-center gap-2 p-2 text-sm rounded-md bg-primary/10">
511+
<AlertCircle className="w-4 h-4 text-primary" />
512+
<span className="text-primary">
513+
Recommended: Keep content blocked
514+
</span>
515+
</div>
516+
</CardContent>
517+
)}
507518
</Card>
508519
) : (
509520
<Card className="w-full bg-muted/50">

0 commit comments

Comments
 (0)