Skip to content

Commit 34c9f9c

Browse files
committed
chore: wrap instead of manual try, catch
1 parent 9910602 commit 34c9f9c

File tree

9 files changed

+8629
-2803
lines changed

9 files changed

+8629
-2803
lines changed

changelog.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@
33
## Version 0.46.0 (2021-06-)
44
### New Features
55
1. Added modes to "Random fill deck" button
6+
1. Added "new card" toast
67
### Fixes
7-
1. Fixed deck storage loading (hopefully?)
8+
1. Fixed deck storage loading
9+
1. Fixed chat not showing up with certain settings
10+
### Plugins
11+
1. Expose `underscript.utils`
12+
1. Expose `underscript.lib`
13+
1. BootstrapDialog events `BootstrapDialog:create|show|shown|hide|hidden`
814

915
## Version 0.45.1 (2021-06-16)
1016
1. Fixed import bug (what does testing mean?)\

package-lock.json

Lines changed: 8611 additions & 2783 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"gulp-insert": "^0.5.0",
4040
"gulp-rename": "^1.4.0",
4141
"gulp-replace": "^1.0.0",
42+
"parcel": "^2.0.0-nightly.750",
4243
"replace": "^1.2.1",
4344
"rollup": "^2.35.1",
4445
"rollup-plugin-cleanup": "^3.2.1"

src/base/chat/newLinkify.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ wrap(() => {
77

88
eventManager.on('ChatDetected', () => {
99
// TODO: check regex (linting errors)
10-
const regex = /\b((?:https?:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»]))/gi;
10+
const regex = /\b((?:https?:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()[\]{};:'".,<>?«»]))/gi;
1111
globalSet('linkify', function linkify(text) {
1212
if (settings.value('underscript.disable.linkify')) {
1313
return this.super(text);

src/hooks/BootstrapDialog.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ wrap(() => {
33
const original = args[`on${key}`];
44
function wrapper(dialog) {
55
if (typeof original === 'function') {
6-
original(dialog);
6+
wrap(() => original(dialog), `BootstrapDialog:on${key}`);
77
}
88
eventManager.emit(`BootstrapDialog:${key}`, dialog);
99
}

src/hooks/game.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ wrap(() => {
66
eventManager.on(':loaded', () => {
77
function callGameHooks(data, original) {
88
const run = !eventManager.cancelable.emit('PreGameEvent', data).canceled;
9-
try {
10-
if (run) original(data);
11-
} catch (e) {
12-
console.error(e); // eslint-disable-line no-console
9+
if (run) {
10+
wrap(() => original(data));
1311
}
1412
eventManager.emit('GameEvent', data);
1513
}

src/hooks/play.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ onPage('Play', () => {
1717
globalSet('onMessage', function onMessage(event) {
1818
const data = JSON.parse(event.data);
1919
eventManager.emit(`pre:${data.action}`, data);
20-
try {
21-
this.super(event);
22-
} catch (e) {
23-
console.error(e); // eslint-disable-line no-console
24-
}
20+
wrap(() => this.super(event));
2521
eventManager.emit('Play:Message', data);
2622
eventManager.emit(data.action, data);
2723
});

src/hooks/spectate.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ onPage('Spectate', () => {
55
eventManager.on(':loaded', () => {
66
function callGameHooks(data, original) {
77
const run = !eventManager.emit('PreGameEvent', data, data.action === 'getResult').canceled;
8-
try {
9-
if (run) original(data);
10-
} catch (e) {
11-
console.error(e); // eslint-disable-line no-console
8+
if (run) {
9+
wrap(() => original(data));
1210
}
1311
eventManager.emit('GameEvent', data);
1412
}

src/utils/settings.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,16 +472,14 @@ const settings = wrap(() => {
472472
}
473473

474474
function importSettings(string) {
475-
try {
475+
wrap(() => {
476476
// TODO: Call setting events?
477477
const parsed = JSON.parse(atob(string));
478478
fn.each(parsed, (val, key) => {
479479
console.log(key, val);
480480
localStorage.setItem(key, val);
481481
});
482-
} catch (e) {
483-
console.error(e);
484-
}
482+
});
485483
}
486484

487485
// Add our button last
@@ -498,6 +496,7 @@ const settings = wrap(() => {
498496
if (!this.enabled()) {
499497
return 'Settings temporarily unavailable';
500498
}
499+
return undefined;
501500
},
502501
});
503502
});

0 commit comments

Comments
 (0)