Move comms to ts (1/3)
This commit is contained in:
parent
08fceafc17
commit
006c9ef975
@ -1,31 +0,0 @@
|
|||||||
import Debug from '../../conf/Debug';
|
|
||||||
import BrowserDetect from '../../conf/BrowserDetect';
|
|
||||||
|
|
||||||
if (process.env.CHANNEL !== 'stable'){
|
|
||||||
console.info("Loading Comms");
|
|
||||||
}
|
|
||||||
|
|
||||||
class Comms {
|
|
||||||
static async sendMessage(message){
|
|
||||||
|
|
||||||
if(BrowserDetect.firefox){
|
|
||||||
return browser.runtime.sendMessage(message);
|
|
||||||
} else {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
chrome.runtime.sendMessage(message, function(response){
|
|
||||||
// Chrome/js shittiness mitigation — remove this line and an empty array will be returned
|
|
||||||
var r = response;
|
|
||||||
resolve(r);
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.env.CHANNEL !== 'stable'){
|
|
||||||
console.info("Comms loaded");
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Comms;
|
|
19
src/ext/lib/comms/Comms.ts
Normal file
19
src/ext/lib/comms/Comms.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import Debug from '../../conf/Debug';
|
||||||
|
import BrowserDetect from '../../conf/BrowserDetect';
|
||||||
|
import { browser } from 'webextension-polyfill-ts';
|
||||||
|
|
||||||
|
if (process.env.CHANNEL !== 'stable'){
|
||||||
|
console.info("Loading Comms");
|
||||||
|
}
|
||||||
|
|
||||||
|
class Comms {
|
||||||
|
static async sendMessage(message){
|
||||||
|
browser.runtime.sendMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.env.CHANNEL !== 'stable'){
|
||||||
|
console.info("Comms loaded");
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Comms;
|
Loading…
Reference in New Issue
Block a user