Skip to content

Commit 0b417de

Browse files
committed
Fixing issue with long issues and some ui fixes
1 parent db50855 commit 0b417de

3 files changed

Lines changed: 36 additions & 12 deletions

File tree

background.js

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,14 @@ let currentScanFilter = FILTER_OPTIONS.BOTH;
5353
function normalizeFilter(value) {
5454
return Object.values(FILTER_OPTIONS).includes(value) ? value : FILTER_OPTIONS.BOTH;
5555
}
56-
try { chrome.action.setPopup({ popup: 'popup.html' }); } catch (err) { console.warn('Popup attach failed:', err); }
56+
try {
57+
chrome.action.setPopup({ popup: 'popup.html' });
58+
} catch (err) {
59+
console.warn('Popup attach failed:', err);
60+
}
5761

58-
let originTabId; // Store the ID of the tab that initiated the license check
62+
// Store the ID of the tab that initiated the license check
63+
let originTabId;
5964
const dmp = new DiffMatchPatch();
6065
// In-memory cache of license term-frequency vectors (populated on demand)
6166
let licenseVectorsCache = null; // { license_key: { word: freq, ... } }
@@ -65,13 +70,17 @@ const activeScans = new Set();
6570

6671
// Database version - increment when structure changes
6772
const DB_VERSION = 2;
68-
73+
let dbInstance = null;
74+
let dbOpenPromise = null;
6975
/**
7076
* Open (and create/upgrade) the IndexedDB database.
7177
* @returns {Promise<IDBDatabase>}
7278
*/
7379
function openDatabase() {
74-
return new Promise((resolve, reject) => {
80+
if (dbInstance) return Promise.resolve(dbInstance);
81+
if (dbOpenPromise) return dbOpenPromise;
82+
83+
dbOpenPromise = new Promise((resolve, reject) => {
7584
const request = indexedDB.open('LicenseDB', DB_VERSION);
7685

7786
request.onupgradeneeded = (event) => {
@@ -91,13 +100,23 @@ function openDatabase() {
91100
};
92101

93102
request.onsuccess = (event) => {
94-
resolve(event.target.result);
103+
dbInstance = event.target.result;
104+
dbInstance.onclose = () => { dbInstance = null; dbOpenPromise = null; };
105+
dbInstance.onversionchange = () => {
106+
dbInstance?.close();
107+
dbInstance = null;
108+
dbOpenPromise = null;
109+
};
110+
resolve(dbInstance);
95111
};
96112

97113
request.onerror = (event) => {
114+
dbOpenPromise = null;
98115
reject(`IndexedDB error: ${event.target.errorCode}`);
99116
};
100117
});
118+
119+
return dbOpenPromise;
101120
}
102121

103122
/**
@@ -504,7 +523,7 @@ async function loadAllVectors() {
504523
return licenseVectorsCache;
505524
}
506525

507-
// === Added caches for advanced similarity metrics ===
526+
// Added caches for advanced similarity metrics
508527
let docFreqCache = null; // { term: documentFrequency }
509528
let totalDocsCache = 0;
510529
const licenseShingleCache = {}; // { license_key: Set<string> }

content.css

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,17 @@
3737
font-size: 22px;
3838
cursor: pointer;
3939
transition: all 0.2s ease;
40-
border-radius: 50%;
4140
width: 32px;
4241
height: 32px;
43-
display: flex;
44-
align-items: center;
45-
justify-content: center;
46-
opacity: 0.7;
42+
min-width: 32px;
43+
min-height: 32px;
44+
max-width: 32px;
45+
max-height: 32px;
46+
border-radius: 50%;
47+
box-sizing: border-box;
48+
padding: 0;
49+
line-height: 1;
50+
flex: 0 0 auto;
4751
}
4852

4953
#license-diff-ui .license-diff-close:hover {
@@ -67,6 +71,7 @@
6771

6872
#license-diff-theme select {
6973
padding: 4px 22px 4px 8px;
74+
width: auto;
7075
border-radius: 8px;
7176
border: 1px solid rgba(0, 0, 0, 0.15);
7277
font-size: 12px;

options.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@
183183
</style>
184184
</head>
185185
<body>
186-
<h1>LicenseDB Diff Options</h1>
186+
<h1>LicenseDB License Diff Options</h1>
187187

188188
<div class="card">
189189
<h2>Database Information</h2>

0 commit comments

Comments
 (0)