Skip to content

Commit

Permalink
build(Twinkle): remove unused var; replace null with empty string; op…
Browse files Browse the repository at this point in the history
…timize logic (#1498)

* build(Twinkle): remove unused var; replace null with empty string; optimize logic

* build(Twinkle): remove unused var; replace null with empty string; optimize logic
  • Loading branch information
WaitSpringQW authored Aug 27, 2024
1 parent 8129373 commit 9cbb089
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 45 deletions.
36 changes: 13 additions & 23 deletions dist/Twinkle/Twinkle.js

Large diffs are not rendered by default.

34 changes: 12 additions & 22 deletions src/Twinkle/modules/twinkle.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,11 +450,6 @@ import {api} from './api';
/**
* **************** General initialization code ****************
*/
const scripturl = mw.util.getUrl(`User:${mw.config.get('wgUserName')}/twinkleoptions.js`, {
action: 'raw',
ctype: 'text/javascript',
happy: 'yes',
});
// Retrieve the user's Twinkle preferences (window.Twinkle.prefs)
Twinkle.prefs ||= {};
void api
Expand All @@ -468,24 +463,19 @@ import {api} from './api';
rvlimit: '1',
})
.then((response) => {
let isSuccess;
const content = response['query'].pages[0].revisions[0].content ?? null;
if (content) {
try {
// eslint-disable-next-line no-eval
window.eval(content);
isSuccess = true;
} catch {
isSuccess = false;
if (!response['query'].pages[0].missing) {
const content = response['query'].pages[0].revisions[0].content ?? '';
if (content !== '') {
try {
// eslint-disable-next-line no-eval
window.eval(content);
} catch {
void mw.notify(window.wgULS('未能加载您的Twinkle参数设置', '未能載入您的Twinkle偏好設定'), {
type: 'error',
tag: 'twinkle',
});
}
}
} else {
isSuccess = false;
}
if (!isSuccess) {
void mw.notify(window.wgULS('未能加载您的Twinkle参数设置', '未能載入您的Twinkle偏好設定'), {
type: 'error',
tag: 'twinkle',
});
}
})
.fail(() => {
Expand Down

0 comments on commit 9cbb089

Please sign in to comment.