refactor: remove unnecessary arrow function wrap
- add installed handler
This commit is contained in:
parent
90399c53a8
commit
6853158790
|
@ -30,8 +30,7 @@
|
|||
});
|
||||
};
|
||||
|
||||
const attachInstalledListeners = () => {
|
||||
window.addEventListener('message', event => {
|
||||
const installedHandler = event => {
|
||||
if (
|
||||
event.data
|
||||
&& event.data.type === 'ouc-is-installed'
|
||||
|
@ -53,7 +52,10 @@
|
|||
sendInstalledCallback(callbackObject);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const attachInstalledListeners = () => {
|
||||
window.addEventListener('message', installedHandler);
|
||||
};
|
||||
|
||||
const doHandshake = () => {
|
||||
|
@ -102,9 +104,7 @@
|
|||
});
|
||||
};
|
||||
|
||||
const attachHandshakeListeners = () => {
|
||||
// Wait for the handshake request, then start it
|
||||
window.addEventListener('message', event => {
|
||||
const handshakeHandler = event => {
|
||||
if (
|
||||
event.data
|
||||
&& event.data.type === 'ouc-handshake-question'
|
||||
|
@ -112,7 +112,11 @@
|
|||
) {
|
||||
doHandshake();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const attachHandshakeListeners = () => {
|
||||
// Wait for the handshake request, then start it
|
||||
window.addEventListener('message', handshakeHandler);
|
||||
};
|
||||
|
||||
const sendInstallCallback = data => {
|
||||
|
@ -124,9 +128,7 @@
|
|||
});
|
||||
};
|
||||
|
||||
const attachInstallListeners = () => {
|
||||
// Wait for an install event, then save the theme
|
||||
window.addEventListener('message', event => {
|
||||
const installHandler = event => {
|
||||
if (
|
||||
event.data
|
||||
&& event.data.type === 'ouc-install-usercss'
|
||||
|
@ -144,13 +146,19 @@
|
|||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
(() => {
|
||||
const attachInstallListeners = () => {
|
||||
// Wait for an install event, then save the theme
|
||||
window.addEventListener('message', installHandler);
|
||||
};
|
||||
|
||||
window.removeEventListener('message', installHandler);
|
||||
window.removeEventListener('message', handshakeHandler);
|
||||
window.removeEventListener('message', installedHandler);
|
||||
|
||||
attachHandshakeListeners();
|
||||
attachInstallListeners();
|
||||
attachInstalledListeners();
|
||||
askHandshake();
|
||||
})();
|
||||
})();
|
||||
|
|
Loading…
Reference in New Issue
Block a user