From 725f0f789a27725e86b517fc124bc65e19d8fa66 Mon Sep 17 00:00:00 2001 From: Cutls Date: Sat, 15 Jun 2019 01:25:51 +0900 Subject: [PATCH] Remove: node on notification/parse.js #86 --- app/js/platform/preload.js | 47 +++++++++++++++++++++++++++ app/js/tl/notification.js | 14 ++++---- app/js/tl/parse.js | 66 ++++++-------------------------------- app/main/system.js | 6 ++++ 4 files changed, 68 insertions(+), 65 deletions(-) diff --git a/app/js/platform/preload.js b/app/js/platform/preload.js index 19f30b2e..2c7718d3 100644 --- a/app/js/platform/preload.js +++ b/app/js/platform/preload.js @@ -17,6 +17,8 @@ onmessage = function (e) { ipc.send("dialogCW", e.data[1]) } else if (e.data[0] == "nativeNotf") { ipc.send('native-notf', e.data[1]); + } else if (e.data[0] == "dialogClient") { + ipc.send("dialogClient", e.data[1]) } } //version.js @@ -87,6 +89,51 @@ ipc.on('dialogCWRender', function (event, arg) { post("pass"); } }); +//parse.js +ipc.on('dialogClientRender', function (event, arg) { + if (arg === 1) { + var cli = localStorage.getItem("client_emp"); + var obj = JSON.parse(cli); + if (!obj) { + var obj = []; + obj.push(name); + M.toast({ html: escapeHTML(name) + lang.lang_status_emphas, displayLength: 2000 }) + } else { + var can; + Object.keys(obj).forEach(function (key) { + var cliT = obj[key]; + if (cliT != name && !can) { + can = false; + } else { + can = true; + obj.splice(key, 1); + M.toast({ html: escapeHTML(name) + lang.lang_status_unemphas, displayLength: 2000 }) + } + }); + if (!can) { + obj.push(name); + M.toast({ html: escapeHTML(name) + lang.lang_status_emphas, displayLength: 2000 }) + } else { + + } + } + var json = JSON.stringify(obj); + localStorage.setItem("client_emp", json); + } else if (arg === 2) { + var cli = localStorage.getItem("client_mute"); + var obj = JSON.parse(cli); + if (!obj) { + obj = []; + } + obj.push(name); + var json = JSON.stringify(obj); + localStorage.setItem("client_mute", json); + M.toast({ html: escapeHTML(name) + lang.lang_parse_mute, displayLength: 2000 }) + } else { + return; + } + parseColumn(); +}); /* var webviewDom = document.getElementById('webview'); const { diff --git a/app/js/tl/notification.js b/app/js/tl/notification.js index 397862df..9cf5025a 100644 --- a/app/js/tl/notification.js +++ b/app/js/tl/notification.js @@ -58,9 +58,7 @@ function notfColumn(acct_id, tlid, sys) { if (key > 14) { ct = "15+"; } - var electron = require("electron"); - var ipc = electron.ipcRenderer; - var os = electron.remote.process.platform; + var os = localStorage.getItem("platform"); var options = { body: ct + lang.lang_notf_new, icon: localStorage.getItem("prof_" + acct_id) @@ -68,7 +66,8 @@ function notfColumn(acct_id, tlid, sys) { if (os == "darwin") { var n = new Notification('TheDesk:' + domain, options); } else { - ipc.send('native-notf', ['TheDesk:' + domain, ct + lang.lang_notf_new, localStorage.getItem("prof_" + acct_id)]); + var nativeNotfOpt=['TheDesk:' + domain, ct + lang.lang_notf_new, localStorage.getItem("prof_" + acct_id)] + postMessage(["nativeNotf", nativeNotfOpt], "*") } } @@ -164,9 +163,7 @@ function notfCommon(acct_id, tlid, sys) { if (key > 14) { ct = "15+"; } - var electron = require("electron"); - var ipc = electron.ipcRenderer; - var os = electron.remote.process.platform; + var os = localStorage.getItem("platform"); var options = { body: ct + lang.lang_notf_new, icon: localStorage.getItem("prof_" + acct_id) @@ -174,7 +171,8 @@ function notfCommon(acct_id, tlid, sys) { if (os == "darwin") { var n = new Notification('TheDesk:' + domain, options); } else { - ipc.send('native-notf', ['TheDesk:' + domain, ct + lang.lang_notf_new, localStorage.getItem("prof_" + acct_id)]); + var nativeNotfOpt=['TheDesk:' + domain, ct + lang.lang_notf_new, localStorage.getItem("prof_" + acct_id)] + postMessage(["nativeNotf", nativeNotfOpt], "*") } } diff --git a/app/js/tl/parse.js b/app/js/tl/parse.js index 5b4d524e..04754c4c 100644 --- a/app/js/tl/parse.js +++ b/app/js/tl/parse.js @@ -304,9 +304,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) { request.send(); } if (native == "yes") { - var electron = require("electron"); - var ipc = electron.ipcRenderer; - var os = electron.remote.process.platform; + var os = localStorage.getItem("platform"); var options = { body: toot.account.display_name + "(" + toot.account.acct + ")" + what + "\n\n" + $.strip_tags(toot.status.content), icon: toot.account.avatar @@ -314,14 +312,15 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) { if (os == "darwin") { var n = new Notification('TheDesk:' + domain, options); } else { - ipc.send('native-notf', [ + var nativeNotfOpt = [ 'TheDesk:' + domain, toot.account.display_name + "(" + toot.account.acct + ")" + what + "\n\n" + $.strip_tags(toot.status.content), toot.account.avatar, "toot", acct_id, toot.status.id - ]); + ] + postMessage(["nativeNotf", nativeNotfOpt], "*") } } if (localStorage.getItem("hasNotfC_" + acct_id) != "true") { @@ -929,9 +928,7 @@ function userparse(obj, auth, acct_id, tlid, popup) { native = "yes"; } if (native == "yes") { - var electron = require("electron"); - var ipc = electron.ipcRenderer; - var os = electron.remote.process.platform; + var os = localStorage.getItem("platform"); var options = { body: toot.display_name + "(" + toot.acct + ")" + ftxt, icon: toot.avatar @@ -940,14 +937,15 @@ function userparse(obj, auth, acct_id, tlid, popup) { if (os == "darwin") { var n = new Notification('TheDesk:' + domain, options); } else { - ipc.send('native-notf', [ + var nativeNotfOpt = [ 'TheDesk:' + domain, toot.display_name + "(" + toot.acct + ")" + ftxt, toot.avatar, "userdata", acct_id, toot.id - ]); + ] + postMessage(["nativeNotf", nativeNotfOpt], "*") } } } @@ -1011,59 +1009,13 @@ function userparse(obj, auth, acct_id, tlid, popup) { function client(name) { if (name != "Unknown") { //聞く - var electron = require("electron"); - var remote = electron.remote; - var dialog = remote.dialog; const options = { type: 'info', title: lang.lang_parse_clientop, message: name + lang.lang_parse_clienttxt, buttons: [lang.lang_parse_clientno, lang.lang_parse_clientemp, lang.lang_parse_clientmute] } - dialog.showMessageBox(options, function (arg) { - if (arg === 1) { - var cli = localStorage.getItem("client_emp"); - var obj = JSON.parse(cli); - if (!obj) { - var obj = []; - obj.push(name); - M.toast({ html: escapeHTML(name) + lang.lang_status_emphas, displayLength: 2000 }) - } else { - var can; - Object.keys(obj).forEach(function (key) { - var cliT = obj[key]; - if (cliT != name && !can) { - can = false; - } else { - can = true; - obj.splice(key, 1); - M.toast({ html: escapeHTML(name) + lang.lang_status_unemphas, displayLength: 2000 }) - } - }); - if (!can) { - obj.push(name); - M.toast({ html: escapeHTML(name) + lang.lang_status_emphas, displayLength: 2000 }) - } else { - - } - } - var json = JSON.stringify(obj); - localStorage.setItem("client_emp", json); - } else if (arg === 2) { - var cli = localStorage.getItem("client_mute"); - var obj = JSON.parse(cli); - if (!obj) { - obj = []; - } - obj.push(name); - var json = JSON.stringify(obj); - localStorage.setItem("client_mute", json); - M.toast({ html: escapeHTML(name) + lang.lang_parse_mute, displayLength: 2000 }) - } else { - return; - } - parseColumn(); - }) + postMessage(["dialogClient", options], "*") } } \ No newline at end of file diff --git a/app/main/system.js b/app/main/system.js index 2f02927e..249029ba 100644 --- a/app/main/system.js +++ b/app/main/system.js @@ -67,6 +67,12 @@ function system(mainWindow, dir, lang) { e.sender.webContents.send('dialogCWRender', arg); }); }) + //クライアントのダイアログ + ipc.on('dialogClient', function (e, args) { + dialog.showMessageBox(args, function (arg) { + e.sender.webContents.send('dialogClientRender', arg); + }); + }) //ハードウェアアクセラレーションの無効化 ipc.on('ha', function (e, arg) {