Skip to content

Commit

Permalink
ui fixes and sw updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dd3v committed Feb 13, 2023
1 parent cb0367c commit 6ac2cf7
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 9 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = {
'max-len': 'off',
'no-restricted-syntax': ['error', 'ForInStatement', 'LabeledStatement', 'WithStatement'],
'no-use-before-define': ['error', { functions: false }],
'no-param-reassign': ['error', { props: false }],
},
overrides: [
{
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change Log

### v1.1.1
- UI fixes
- SW improvements

### v1.1.0
- a green icon is shown when a bookmark has already been created
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "favbox",
"version": "1.1.0",
"version": "1.1.1",
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
Expand Down
10 changes: 5 additions & 5 deletions src/components/bookmark/BookmarkTools.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
<Tab v-slot="{ selected }" as="template">
<button
:class="[
'w-full rounded-lg py-1 text-sm font-medium leading-5 text-gray-700',
'w-full rounded-lg py-1 text-sm font-medium leading-5 text-gray-500',
' focus:outline-none ',
selected
? 'bg-white shadow dark:bg-neutral-900 dark:text-neutral-400'
: 'text-gray-500 hover:bg-white/[0.12] hover:text-gray-700',
? 'bg-white shadow dark:bg-neutral-900 dark:text-white'
: 'text-gray-500 dark:text-white hover:bg-white/[0.12] hover:text-gray-700',
]"
>
Preview page
Expand All @@ -26,11 +26,11 @@
<Tab v-slot="{ selected }" as="template">
<button
:class="[
'w-full rounded-lg py-1 text-sm font-medium leading-5 text-gray-700',
'w-full rounded-lg py-1 text-sm font-medium leading-5 text-gray-500',
'focus:outline-none ',
selected
? 'bg-white shadow dark:bg-neutral-900 dark:text-white'
: 'text-gray-500 hover:bg-white/[0.12] hover:text-gray-700',
: 'text-gray-500 dark:text-white hover:bg-white/[0.12] hover:text-gray-700',
]"
>
Edit bookmark
Expand Down
11 changes: 10 additions & 1 deletion src/extension/content.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import Parser from '@/libs/parser';

let port;
function connect() {
port = chrome.runtime.connect({ name: 'favbox' });
port.onDisconnect.addListener(connect);
port.onMessage.addListener((msg) => {
console.log('received', msg, 'from bg');
});
}
try {
connect();
const parser = new Parser(document.location.href, document);
const pageInfo = parser.getFullPageInfo();
await chrome.runtime.sendMessage({ action: 'cache', data: pageInfo });
} catch (e) {
console.error('Caching error', e);
console.error('Content script error', e);
}
22 changes: 22 additions & 0 deletions src/extension/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,28 @@ chrome.bookmarks.onRemoved.addListener(async (id, removeInfo) => {
}
});

chrome.runtime.onConnect.addListener((port) => {
if (port.name !== 'favbox') return;
port.onMessage.addListener(onMessage);
port.onDisconnect.addListener(deleteTimer);
port.timer = setTimeout(forceReconnect, 150000, port);
});

function onMessage(msg, port) {
console.log('received', msg, 'from', port.sender);
}
function forceReconnect(port) {
console.warn('Reconnect...');
deleteTimer(port);
port.disconnect();
}
function deleteTimer(port) {
if (port.timer) {
clearTimeout(port.timer);
delete port.timer;
}
}

const storage = await chrome.storage.session.get('import');
if (storage?.import !== true) {
console.time('Execution time');
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.development.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "FavBox",
"description": "Clear and modern bookmarking tool.",
"version": "1.1.0",
"version": "1.1.1",
"permissions": ["bookmarks", "activeTab", "tabs", "storage"],
"background": {
"service_worker": "/sw.js"
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.production.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "FavBox",
"description": "Clear and modern bookmarking tool.",
"version": "1.1.0",
"version": "1.1.1",
"permissions": ["bookmarks", "activeTab", "tabs", "storage"],
"background": {
"service_worker": "/sw.js"
Expand Down

0 comments on commit 6ac2cf7

Please sign in to comment.