Skip to content

Commit 58da3fe

Browse files
committed
Merge branch 'v0.3.3'
2 parents 941520e + e3d3451 commit 58da3fe

File tree

11 files changed

+34
-24
lines changed

11 files changed

+34
-24
lines changed

consts.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ class Consts {
1414
};
1515
static messageTypes = {
1616
gestures: 'gestures',
17-
updateStorage: 'updateStorage',
18-
getSettings: 'getSettings'
17+
updateStorage: 'updateStorage'
1918
};
2019
}

content-scripts/canvas-event-handler.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ class CanvasEventHandler {
55
#lineColor = '#000000';
66
#lineWidth = 2;
77

8-
constructor(canvas) {
8+
constructor(canvas, storage) {
99
this.#canvas = canvas;
1010
this.#context = canvas.getContext('2d');
1111
this.#resetPosition();
1212
const thisRef = this;
13-
chrome.runtime.sendMessage({ type: Consts.messageTypes.getSettings }, function (response) {
14-
console.debug(response);
15-
thisRef.#lineColor = response?.lineColor ?? '#000000';
16-
thisRef.#lineWidth = response?.lineWidth ?? 2;
13+
storage.getSettingsAsync().then((settings) => {
14+
thisRef.#lineColor = settings?.lineColor ?? '#000000';
15+
thisRef.#lineWidth = settings?.lineWidth ?? 2;
1716
});
1817
}
1918

content-scripts/content-event-handler.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ class ContentEventHandler {
5050

5151
canvasHandler.removeFromDom();
5252
const gestures = gesturesHandler.getGestures();
53-
console.debug(gestures);
5453
if (gestures.length === 0) {
5554
return;
5655
}

content-scripts/settings-storage.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class SettingsStorage {
2+
#settingsStorageKey = 'simpleMouseGesturesSettings';
3+
4+
async getSettingsAsync() {
5+
const settings = await this.#getFromStorageAsync(this.#settingsStorageKey);
6+
7+
return { ...settings };
8+
}
9+
10+
async #getFromStorageAsync(storageKey) {
11+
const value = await chrome.storage.local.get([storageKey]);
12+
if (!value.hasOwnProperty(storageKey)) {
13+
return;
14+
}
15+
16+
try {
17+
return JSON.parse(value[storageKey]);
18+
} catch (e) {
19+
console.error(e);
20+
}
21+
}
22+
}

content.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
const gesturesHandler = new GesturesHandler();
22
const canvasBuilder = new CanvasBuilder();
33
const canvas = canvasBuilder.build();
4-
const canvasEventHandler = new CanvasEventHandler(canvas);
4+
const storage = new SettingsStorage();
5+
const canvasEventHandler = new CanvasEventHandler(canvas, storage);
56
canvasEventHandler.registerEvent();
67
const canvasHandler = new CanvasHandler(canvasEventHandler, canvas);
78
const contentEventHandler = new ContentEventHandler(gesturesHandler, canvasHandler);

manifest.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"manifest_version": 3,
33
"name": "Simple Mouse Gestures",
44
"description": "Extension that provides the ability to define mouse gestures that will run specific actions in your Google Chrome browser",
5-
"version": "0.3.2",
6-
"version_name": "0.3.2 beta",
5+
"version": "0.3.3",
6+
"version_name": "0.3.3 beta",
77
"icons": {
88
"16": "images/icon-16.png",
99
"32": "images/icon-32.png",
@@ -19,6 +19,7 @@
1919
"content-scripts/canvas-builder.js",
2020
"content-scripts/canvas-event-handler.js",
2121
"content-scripts/canvas-handler.js",
22+
"content-scripts/settings-storage.js",
2223
"content-scripts/content-event-handler.js",
2324
"content.js"
2425
],

service-worker-scripts/operation-resolver.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,8 @@ export class OperationResolver {
6666

6767
async resolveAsync(gestures) {
6868
const serializedGestures = this.#serializeGestures(gestures);
69-
console.debug(serializedGestures);
7069

7170
const operationKey = this.#storage.getOperationKey(serializedGestures);
72-
console.debug(operationKey);
7371
if (operationKey === undefined) {
7472
return;
7573
}
@@ -79,7 +77,6 @@ export class OperationResolver {
7977
}
8078

8179
const element = OperationResolver.operations[operationKey];
82-
console.debug(element);
8380
await element.operation.doAsync();
8481
}
8582

service-worker-scripts/operations/go-back-operation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export class GoBackOperation {
33
try {
44
await chrome.tabs.goBack();
55
} catch (error) {
6-
console.debug(error);
6+
console.error(error);
77
}
88
}
99
}

service-worker-scripts/operations/go-forward-operation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export class GoForwardOperation {
33
try {
44
await chrome.tabs.goForward();
55
} catch (error) {
6-
console.debug(error);
6+
console.error(error);
77
}
88
}
99
}

service-worker-scripts/storage.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export class Storage {
4040
}
4141

4242
async #initMapAsync() {
43-
console.log('initMapAsync');
4443
const map = await this.#getFromStorageAsync(this.#mapStorageKey);
4544
if (map !== undefined) {
4645
this.#map = map;
@@ -66,8 +65,6 @@ export class Storage {
6665

6766
async #getFromStorageAsync(storageKey) {
6867
const value = await chrome.storage.local.get([storageKey]);
69-
console.log('getFromStorage');
70-
console.debug(value);
7168
if (!value.hasOwnProperty(storageKey)) {
7269
return;
7370
}
@@ -82,7 +79,6 @@ export class Storage {
8279
async #saveInStorageAsync(storageKey, data) {
8380
const obj = {};
8481
obj[storageKey] = JSON.stringify(data);
85-
console.log(obj);
8682
await chrome.storage.local.set(obj);
8783
}
8884
}

0 commit comments

Comments
 (0)