From 07b203b719425881ff9386971b9b66fe521a10da Mon Sep 17 00:00:00 2001 From: Cutls Date: Sat, 11 May 2019 01:31:15 +0900 Subject: [PATCH] TheDesk Usamin (18.4.0) --- app/about.html | 3 +- app/js/login/login.js | 11 +- app/js/tl/misskeyparse.js | 40 +- app/js/tl/notification.js | 6 +- app/js/tl/parse.js | 4 +- app/js/tl/tl.js | 854 +++++++++++++++--------------- app/js/ui/layout.js | 14 +- app/main/system.js | 2 +- app/package.json | 8 +- app/view/en/index.html | 16 +- app/view/en/setting.html | 2 +- app/view/ja/index.html | 16 +- app/view/ja/setting.html | 2 +- app/view/make/index.sample.html | 14 +- app/view/make/make.js | 2 +- app/view/make/setting.sample.html | 2 +- app/view/ps/index.html | 16 +- app/view/ps/setting.html | 2 +- 18 files changed, 516 insertions(+), 498 deletions(-) diff --git a/app/about.html b/app/about.html index 610b87a1..1d5ccca2 100644 --- a/app/about.html +++ b/app/about.html @@ -87,7 +87,8 @@ a,button{
Node.js
-
Copyright © Cutls P 2018 All rights reserved.
+
Copyright © TheDesk 2018
+ Main developer(author): Cutls P
Thanks:toneji/popn_ja/kPherox and all users ❤️
Web site
diff --git a/app/js/login/login.js b/app/js/login/login.js index ba14aecd..e3cef8b4 100644 --- a/app/js/login/login.js +++ b/app/js/login/login.js @@ -33,11 +33,6 @@ function ck() { var acct=obj[key]; if(acct.domain){ refresh(key,true) - var domain = localStorage.getItem("domain_" + key); - if(localStorage.getItem("mode_" + domain)=="misskey"){ - localStorage.removeItem("misskey_wss_" + key) - connectMisskey(key) - } } }); if (obj[0].domain) { @@ -48,7 +43,9 @@ if (obj[0].domain) { } } } -ck(); + ck(); + + //ログインポップアップ function login(url) { if($('#linux:checked').val()=="on"){ @@ -505,7 +502,7 @@ function multiSelector() { $("#add-acct-sel").append(''); } $('select').material_select('update'); - parseColumn(); + parseColumn(true); } //バージョンエンコ diff --git a/app/js/tl/misskeyparse.js b/app/js/tl/misskeyparse.js index 640d31a3..3a8c7040 100644 --- a/app/js/tl/misskeyparse.js +++ b/app/js/tl/misskeyparse.js @@ -976,9 +976,6 @@ function goGoogle(id) { var misskeyws=[] var misskeywsstate=[] function connectMisskey(acct_id) { - console.log("C Msky:"+acct_id) - - var domain = localStorage.getItem("domain_" + acct_id); var at = localStorage.getItem("acct_"+ acct_id + "_at"); var start = "wss://" + domain + @@ -1034,6 +1031,12 @@ function connectMisskey(acct_id) { say(obj.text) } var templete = misskeyParse([obj], col.type, acct_id, tlid, "", mute); + misskeyws[wsid].send(JSON.stringify({ + type: 'sn', + body: { + id: obj.id + } + })) var pool = localStorage.getItem("pool_" + tlid); if (pool) { pool = templete + pool; @@ -1043,38 +1046,29 @@ function connectMisskey(acct_id) { localStorage.setItem("pool_" + tlid, pool); scrollck(); jQuery("time.timeago").timeago(); + }else if (data.type == "noteUpdated") { + if(data.body.type=="reacted"){ + console.log(data.body.id) + reactRefresh(acct_id,data.body.id) + }else if(data.body.type=="deleted"){ + $("#pub_"+data.body.id).hide(); + $("#pub_"+data.body.id).remove(); + } + } } misskeyws[wsid].onerror = function (error) { console.error("Error closing"); console.error(error); misskeywsstate[wsid]=false - if (mode == "error") { - $("#notice_icon_" + tlid).addClass("red-text"); - todo('WebSocket Error ' + error); - } else { - var errorct = localStorage.getItem("wserror_" + tlid) * 1 + 1; - localStorage.setItem("wserror_" + tlid, errorct); - if (errorct < 3) { - //reconnector(tlid, type, acct_id, data, "error"); - } - } + connectMisskey(acct_id) return false; }; misskeyws[wsid].onclose = function () { console.log("Closing"); console.log(tlid); misskeywsstate[wsid]=false - if (mode == "error") { - $("#notice_icon_" + tlid).addClass("red-text"); - todo('WebSocket Closed'); - } else { - var errorct = localStorage.getItem("wserror_" + tlid) * 1 + 1; - localStorage.setItem("wserror_" + tlid, errorct); - if (errorct < 3) { - //reconnector(tlid, type, acct_id, data, "error"); - } - } + connectMisskey(acct_id) return false; }; diff --git a/app/js/tl/notification.js b/app/js/tl/notification.js index 1f25c9c6..0808ac90 100644 --- a/app/js/tl/notification.js +++ b/app/js/tl/notification.js @@ -15,7 +15,6 @@ function notfColumn(acct_id, tlid, sys){ native="yes"; } var domain = localStorage.getItem("domain_" + acct_id); - console.log(start) var httpreq = new XMLHttpRequest(); if(localStorage.getItem("mode_" + domain)=="misskey"){ var misskey=true; @@ -205,7 +204,11 @@ function notfCommon(acct_id, tlid, sys) { } $("#notf-box").addClass("fetched"); todc(); + notfWS(misskey,acct_id,tlid,domain,at) }); + +} +function notfWS(misskey,acct_id,tlid,domain,at){ if(!misskey){ if(localStorage.getItem("streaming_" + acct_id)){ var wss=localStorage.getItem("streaming_" + acct_id) @@ -255,6 +258,7 @@ function notfCommon(acct_id, tlid, sys) { } websocketNotf[acct_id].onerror = function(error) { console.error('WebSocket Error ' + error); + notfWS(misskey,acct_id,tlid,domain,at) }; } } diff --git a/app/js/tl/parse.js b/app/js/tl/parse.js index 680ca080..5e6f10af 100644 --- a/app/js/tl/parse.js +++ b/app/js/tl/parse.js @@ -887,8 +887,8 @@ function userparse(obj, auth, acct_id, tlid, popup) { } if (auth) { var authhtml = 'person_add person_add_disabled'; + toot.id + '\',\'authorize\',' + acct_id + ')" title="Accept">person_add person_add_disabled'; } else { var authhtml = ""; } diff --git a/app/js/tl/tl.js b/app/js/tl/tl.js index 21ac0e2a..043c2979 100644 --- a/app/js/tl/tl.js +++ b/app/js/tl/tl.js @@ -1,5 +1,5 @@ //TL取得 -moreloading=false; +moreloading = false; function tl(type, data, acct_id, tlid, delc, voice, mode) { scrollevent(); localStorage.removeItem("morelock"); @@ -16,7 +16,7 @@ function tl(type, data, acct_id, tlid, delc, voice, mode) { }; var multi = localStorage.getItem("column"); var obj = JSON.parse(multi); - localStorage.setItem("card_" + obj.length,"true"); + localStorage.setItem("card_" + obj.length, "true"); obj.push(add); console.log(obj); var json = JSON.stringify(obj); @@ -24,7 +24,7 @@ function tl(type, data, acct_id, tlid, delc, voice, mode) { parseColumn(); return; } - + if (!type) { var type = localStorage.getItem("now"); if (!type) { @@ -32,26 +32,26 @@ function tl(type, data, acct_id, tlid, delc, voice, mode) { var type = "local"; } } - if (type == "mix" && localStorage.getItem("mode_" + domain)!="misskey") { + if (type == "mix" && localStorage.getItem("mode_" + domain) != "misskey") { //Integratedなら飛ばす - $("#notice_" + tlid).text("Integrated TL(" + localStorage.getItem( + $("#notice_" + tlid).text("Integrated TL(" + localStorage.getItem( "user_" + acct_id) + "@" + domain + ")"); - $("#notice_icon_" + tlid).text("merge_type"); - mixtl(acct_id, tlid, "integrated",delc,voice); + $("#notice_icon_" + tlid).text("merge_type"); + mixtl(acct_id, tlid, "integrated", delc, voice); return; - }else if (type == "plus") { + } else if (type == "plus") { //Local+なら飛ばす - $("#notice_" + tlid).text("Local+ TL(" + localStorage.getItem( + $("#notice_" + tlid).text("Local+ TL(" + localStorage.getItem( "user_" + acct_id) + "@" + domain + ")"); - $("#notice_icon_" + tlid).text("people_outline"); - mixtl(acct_id, tlid, "plus",delc,voice); + $("#notice_icon_" + tlid).text("people_outline"); + mixtl(acct_id, tlid, "plus", delc, voice); return; - }else if (type == "notf") { + } else if (type == "notf") { //通知なら飛ばす notf(acct_id, tlid, 'direct'); $("#notice_" + tlid).text(cap(type, data, acct_id) + "(" + localStorage.getItem( "user_" + acct_id) + "@" + domain + ")"); - $("#notice_icon_" + tlid).text("notifications"); + $("#notice_icon_" + tlid).text("notifications"); return; }/*else if (type == "dm") { //DMなら飛ばす @@ -63,93 +63,93 @@ function tl(type, data, acct_id, tlid, delc, voice, mode) { }*/ localStorage.setItem("now", type); todo(cap(type) + " TL Loading..."); - var at = localStorage.getItem("acct_"+ acct_id + "_at"); - if(type!="noauth"){ - var hdr={ + var at = localStorage.getItem("acct_" + acct_id + "_at"); + if (type != "noauth") { + var hdr = { 'content-type': 'application/json', 'Authorization': 'Bearer ' + at }; $("#notice_" + tlid).text(cap(type, data, acct_id) + "(" + localStorage.getItem( "user_" + acct_id) + "@" + domain + ")"); - }else{ - var hdr={ + } else { + var hdr = { 'content-type': 'application/json' }; - domain=acct_id; + domain = acct_id; $("#notice_" + tlid).text("Glance TL(" + domain + ")"); } - $("#notice_icon_" + tlid).text(icon(type)); - if(localStorage.getItem("mode_" + domain)=="misskey"){ - var misskey=true; - var url=misskeycom(type, data); - var start = "https://" + domain + "/api/notes/"+url; - var method="POST"; - var req={}; - if(type!="noauth"){ - req.i=at; - } - - if(type=="local-media"||type=="pub-media"){ - req.mediaOnly=true; - } - if(type=="tag"){ - req.tag=data; - } - if(type=="list"){ - req.listId=data; - } - req.limit=20; - var i={ - method: method, - headers: hdr, - body: JSON.stringify(req), - } - }else{ - var misskey=false; - var url=com(type, data); - if(type=="tag"){ - var tag = localStorage.getItem("tag-range"); - if(tag=="local"){ - url=url+"local=true"; - } - } - if(type=="dm"){ - var start = "https://" + domain + "/api/v1/conversations"; - }else{ - var start = "https://" + domain + "/api/v1/timelines/" + url; - } - var method="GET"; - var i={ - method: method, - headers: hdr - }; + $("#notice_icon_" + tlid).text(icon(type)); + if (localStorage.getItem("mode_" + domain) == "misskey") { + var misskey = true; + var url = misskeycom(type, data); + var start = "https://" + domain + "/api/notes/" + url; + var method = "POST"; + var req = {}; + if (type != "noauth") { + req.i = at; } - + + if (type == "local-media" || type == "pub-media") { + req.mediaOnly = true; + } + if (type == "tag") { + req.tag = data; + } + if (type == "list") { + req.listId = data; + } + req.limit = 20; + var i = { + method: method, + headers: hdr, + body: JSON.stringify(req), + } + } else { + var misskey = false; + var url = com(type, data); + if (type == "tag") { + var tag = localStorage.getItem("tag-range"); + if (tag == "local") { + url = url + "local=true"; + } + } + if (type == "dm") { + var start = "https://" + domain + "/api/v1/conversations"; + } else { + var start = "https://" + domain + "/api/v1/timelines/" + url; + } + var method = "GET"; + var i = { + method: method, + headers: hdr + }; + } + console.log(start); - fetch(start, i).then(function(response) { + fetch(start, i).then(function (response) { return response.json(); - }).catch(function(error) { + }).catch(function (error) { todo(error); console.error(error); - }).then(function(json) { + }).then(function (json) { console.log(json) $("#landing_" + tlid).hide(); - if(localStorage.getItem("filter_"+ acct_id)!="undefined"){ - var mute=getFilterType(JSON.parse(localStorage.getItem("filter_"+ acct_id)),type); - }else{ - var mute=[]; + if (localStorage.getItem("filter_" + acct_id) != "undefined") { + var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), type); + } else { + var mute = []; } - if(misskey){ + if (misskey) { var templete = misskeyParse(json, type, acct_id, tlid, "", mute); - }else{ + } else { var templete = parse(json, type, acct_id, tlid, "", mute, type); - localStorage.setItem("lastobj_"+ tlid,json[0].id) + localStorage.setItem("lastobj_" + tlid, json[0].id) } $("#timeline_" + tlid).html(templete); additional(acct_id, tlid); jQuery("time.timeago").timeago(); todc(); - reload(type, '', acct_id, tlid, data, mute, delc,voice); + reload(type, '', acct_id, tlid, data, mute, delc, voice); $(window).scrollTop(0); }); } @@ -160,24 +160,24 @@ function reload(type, cc, acct_id, tlid, data, mute, delc, voice, mode) { var type = localStorage.getItem("now"); } var domain = localStorage.getItem("domain_" + acct_id); - var at = localStorage.getItem("acct_"+ acct_id + "_at"); + var at = localStorage.getItem("acct_" + acct_id + "_at"); localStorage.setItem("now", type); - if(localStorage.getItem("mode_" + domain)=="misskey"){ - var misskey=true; - var key=localStorage.getItem("misskey_wss_" + acct_id) - var send='{"type":"connect","body":{"channel":"'+typePs(type)+'","id":"'+tlid+'"}}' - while(1){ - if(misskeywsstate[key]){ + if (localStorage.getItem("mode_" + domain) == "misskey") { + var misskey = true; + var key = localStorage.getItem("misskey_wss_" + acct_id) + var send = '{"type":"connect","body":{"channel":"' + typePs(type) + '","id":"' + tlid + '"}}' + var mskyset = setInterval(function () { + if (misskeywsstate[key]) { misskeyws[key].send(send) - break + clearInterval(mskyset) } - } - }else{ - var misskey=false; - if(localStorage.getItem("streaming_" + acct_id)){ - var wss=localStorage.getItem("streaming_" + acct_id) - }else{ - var wss="wss://"+domain + }, 100); + } else { + var misskey = false; + if (localStorage.getItem("streaming_" + acct_id)) { + var wss = localStorage.getItem("streaming_" + acct_id) + } else { + var wss = "wss://" + domain } if (type == "home") { var start = wss + @@ -195,140 +195,140 @@ function reload(type, cc, acct_id, tlid, data, mute, delc, voice, mode) { var start = wss + "/api/v1/streaming/?stream=public:local:media&only_media=true&access_token=" + at; } else if (type == "tag") { - if(type=="tag"){ + if (type == "tag") { var tag = localStorage.getItem("tag-range"); - if(tag=="local"){ - data=data+"&local=true"; + if (tag == "local") { + data = data + "&local=true"; } } var start = wss + - "/api/v1/streaming/?stream=hashtag&tag=" + data +"&access_token=" + at; + "/api/v1/streaming/?stream=hashtag&tag=" + data + "&access_token=" + at; } else if (type == "noauth") { - var start = "wss://" + acct_id+ + var start = "wss://" + acct_id + "/api/v1/streaming/?stream=public:local"; - } else if (type=="list"){ + } else if (type == "list") { var start = wss + - "/api/v1/streaming/?stream=list&list=" + data +"&access_token=" + at; - } else if (type=="dm"){ + "/api/v1/streaming/?stream=list&list=" + data + "&access_token=" + at; + } else if (type == "dm") { var start = wss + "/api/v1/streaming/?stream=direct&access_token=" + at; } - console.log(start); - var wsid = websocket.length; - localStorage.setItem("wss_" + tlid, wsid); - websocket[wsid] = new WebSocket(start); - websocket[wsid].onopen = function(mess) { - console.log(tlid + ":Connect Streaming API:" + type); - console.log(mess); - $("#notice_icon_" + tlid).removeClass("red-text"); - } - websocket[wsid].onmessage = function(mess) { - console.log(tlid + ":Receive Streaming API:"); - console.log(JSON.parse(mess.data)); - if(misskey){ - if (JSON.parse(mess.data).type == "note") { - var obj = JSON.parse(mess.data).body; - if(voice){ - say(obj.text) - } - websocketNotf[acct_id].send(JSON.stringify({ - type: 'capture', - id: obj.id - })) - var templete = misskeyParse([obj], type, acct_id, tlid,"",mute); - var pool = localStorage.getItem("pool_" + tlid); - if (pool) { - pool = templete + pool; - } else { - pool = templete - } - localStorage.setItem("pool_" + tlid, pool); - scrollck(); - jQuery("time.timeago").timeago(); - } - }else{ - var typeA = JSON.parse(mess.data).event; - if (typeA == "delete") { - var del=localStorage.getItem("delete"); - if(del>10){ - reconnector(tlid,type,acct_id,data) - }else{ - localStorage.setItem("delete",del*1+1) - } - var obj = JSON.parse(mess.data).payload; - if(delc=="true"){ - $("#timeline_"+tlid+" [toot-id=" + JSON.parse(mess.data).payload + "]").addClass("emphasized"); - $("#timeline_"+tlid+" [toot-id=" + JSON.parse(mess.data).payload + "]").addClass("by_delcatch"); - }else{ - $("[toot-id=" + JSON.parse(mess.data).payload + "]").hide(); - $("[toot-id=" + JSON.parse(mess.data).payload + "]").remove(); - } - - } else if (typeA == "update" || typeA == "conversation") { - localStorage.removeItem("delete"); - var obj = JSON.parse(JSON.parse(mess.data).payload); - console.log(obj); - if($("#timeline_" + tlid +" [toot-id=" + obj.id + "]").length < 1){ - if(voice){ - say(obj.content) - } - var templete = parse([obj], type, acct_id, tlid,"",mute, type); - if ($("timeline_box_"+tlid+"_box .tl-box").scrollTop() === 0) { - $("#timeline_" + tlid).prepend(templete); - }else{ - var pool = localStorage.getItem("pool_" + tlid); - if (pool) { - pool = templete + pool; - } else { - pool = templete - } - localStorage.setItem("pool_" + tlid, pool); + console.log(start); + var wsid = websocket.length; + localStorage.setItem("wss_" + tlid, wsid); + websocket[wsid] = new WebSocket(start); + websocket[wsid].onopen = function (mess) { + console.log(tlid + ":Connect Streaming API:" + type); + console.log(mess); + $("#notice_icon_" + tlid).removeClass("red-text"); + } + websocket[wsid].onmessage = function (mess) { + console.log(tlid + ":Receive Streaming API:"); + console.log(JSON.parse(mess.data)); + if (misskey) { + if (JSON.parse(mess.data).type == "note") { + var obj = JSON.parse(mess.data).body; + if (voice) { + say(obj.text) } + websocketNotf[acct_id].send(JSON.stringify({ + type: 'capture', + id: obj.id + })) + var templete = misskeyParse([obj], type, acct_id, tlid, "", mute); + var pool = localStorage.getItem("pool_" + tlid); + if (pool) { + pool = templete + pool; + } else { + pool = templete + } + localStorage.setItem("pool_" + tlid, pool); scrollck(); - additional(acct_id, tlid); jQuery("time.timeago").timeago(); - }else{ - todo("二重取得発生中"); } - - todc(); - }else if(typeA=="filters_changed"){ - filterUpdate(acct_id); + } else { + var typeA = JSON.parse(mess.data).event; + if (typeA == "delete") { + var del = localStorage.getItem("delete"); + if (del > 10) { + reconnector(tlid, type, acct_id, data) + } else { + localStorage.setItem("delete", del * 1 + 1) + } + var obj = JSON.parse(mess.data).payload; + if (delc == "true") { + $("#timeline_" + tlid + " [toot-id=" + JSON.parse(mess.data).payload + "]").addClass("emphasized"); + $("#timeline_" + tlid + " [toot-id=" + JSON.parse(mess.data).payload + "]").addClass("by_delcatch"); + } else { + $("[toot-id=" + JSON.parse(mess.data).payload + "]").hide(); + $("[toot-id=" + JSON.parse(mess.data).payload + "]").remove(); + } + + } else if (typeA == "update" || typeA == "conversation") { + localStorage.removeItem("delete"); + var obj = JSON.parse(JSON.parse(mess.data).payload); + console.log(obj); + if ($("#timeline_" + tlid + " [toot-id=" + obj.id + "]").length < 1) { + if (voice) { + say(obj.content) + } + var templete = parse([obj], type, acct_id, tlid, "", mute, type); + if ($("timeline_box_" + tlid + "_box .tl-box").scrollTop() === 0) { + $("#timeline_" + tlid).prepend(templete); + } else { + var pool = localStorage.getItem("pool_" + tlid); + if (pool) { + pool = templete + pool; + } else { + pool = templete + } + localStorage.setItem("pool_" + tlid, pool); + } + scrollck(); + additional(acct_id, tlid); + jQuery("time.timeago").timeago(); + } else { + todo("二重取得発生中"); + } + + todc(); + } else if (typeA == "filters_changed") { + filterUpdate(acct_id); + } } + + } - - - } - websocket[wsid].onerror = function(error) { - console.error("Error closing"); - console.error(error); - if(mode=="error"){ - $("#notice_icon_" + tlid).addClass("red-text"); - todo('WebSocket Error ' + error); - }else{ - var errorct=localStorage.getItem("wserror_" + tlid)*1+1; - localStorage.setItem("wserror_" + tlid,errorct); - if(errorct<3){ - reconnector(tlid,type,acct_id,data,"error"); + websocket[wsid].onerror = function (error) { + console.error("Error closing"); + console.error(error); + if (mode == "error") { + $("#notice_icon_" + tlid).addClass("red-text"); + todo('WebSocket Error ' + error); + } else { + var errorct = localStorage.getItem("wserror_" + tlid) * 1 + 1; + localStorage.setItem("wserror_" + tlid, errorct); + if (errorct < 3) { + reconnector(tlid, type, acct_id, data, "error"); + } } - } - return false; - }; - websocket[wsid].onclose = function() { - console.log("Closing"); - console.log(tlid); - if(mode=="error"){ - $("#notice_icon_" + tlid).addClass("red-text"); - todo('WebSocket Closed'); - }else{ - var errorct=localStorage.getItem("wserror_" + tlid)*1+1; - localStorage.setItem("wserror_" + tlid,errorct); - if(errorct<3){ - reconnector(tlid,type,acct_id,data,"error"); + return false; + }; + websocket[wsid].onclose = function () { + console.log("Closing"); + console.log(tlid); + if (mode == "error") { + $("#notice_icon_" + tlid).addClass("red-text"); + todo('WebSocket Closed'); + } else { + var errorct = localStorage.getItem("wserror_" + tlid) * 1 + 1; + localStorage.setItem("wserror_" + tlid, errorct); + if (errorct < 3) { + reconnector(tlid, type, acct_id, data, "error"); + } } - } - return false; - }; + return false; + }; } } @@ -339,108 +339,108 @@ function moreload(type, tlid) { var acct_id = obj[tlid].domain; if (!type) { var type = obj[tlid].type; - }else{ + } else { var data; } - if(type=="tag"){ - var data=obj[tlid].data; + if (type == "tag") { + var data = obj[tlid].data; var tag = localStorage.getItem("tag-range"); - if(tag=="local"){ - data=data+"&local=true"; + if (tag == "local") { + data = data + "&local=true"; } - }else if(type=="list"){ - var data=obj[tlid].data; + } else if (type == "list") { + var data = obj[tlid].data; } var sid = $("#timeline_" + tlid + " .cvo").last().attr("unique-id"); if (sid && !moreloading) { - if (type == "mix" && localStorage.getItem("mode_" + localStorage.getItem("domain_" + acct_id))!="misskey") { - mixmore(tlid,"integrated"); + if (type == "mix" && localStorage.getItem("mode_" + localStorage.getItem("domain_" + acct_id)) != "misskey") { + mixmore(tlid, "integrated"); return; - }else if (type == "plus" && localStorage.getItem("mode_" + localStorage.getItem("domain_" + acct_id))!="misskey") { - mixmore(tlid,"plus"); + } else if (type == "plus" && localStorage.getItem("mode_" + localStorage.getItem("domain_" + acct_id)) != "misskey") { + mixmore(tlid, "plus"); return; - }else if (type == "notf") { + } else if (type == "notf") { notfmore(tlid); return; - }else if (type == "tootsearch") { - var data=obj[tlid].data; - moreTs(tlid,data); + } else if (type == "tootsearch") { + var data = obj[tlid].data; + moreTs(tlid, data); return; } - moreloading=true; + moreloading = true; localStorage.setItem("now", type); todo(cap(type) + " TL MoreLoading"); - if(type!="noauth"){ - var at = localStorage.getItem("acct_"+ acct_id + "_at"); - var hdr={ + if (type != "noauth") { + var at = localStorage.getItem("acct_" + acct_id + "_at"); + var hdr = { 'content-type': 'application/json', 'Authorization': 'Bearer ' + at }; - var domain = localStorage.getItem("domain_" + acct_id); - }else{ - var hdr={ + var domain = localStorage.getItem("domain_" + acct_id); + } else { + var hdr = { 'content-type': 'application/json' }; - domain=acct_id; + domain = acct_id; } - if(localStorage.getItem("mode_" + domain)=="misskey"){ - var misskey=true; - hdr={ + if (localStorage.getItem("mode_" + domain) == "misskey") { + var misskey = true; + hdr = { 'content-type': 'application/json' }; - var url=misskeycom(type, data); - var start = "https://" + domain + "/api/notes/"+url; - var method="POST"; - var req={}; - if(type!="noauth"){ - req.i=at; + var url = misskeycom(type, data); + var start = "https://" + domain + "/api/notes/" + url; + var method = "POST"; + var req = {}; + if (type != "noauth") { + req.i = at; } - if(type=="local-media"||type=="pub-media"){ - req.mediaOnly=true; + if (type == "local-media" || type == "pub-media") { + req.mediaOnly = true; } - if(type=="tag"){ - req.tag=data; + if (type == "tag") { + req.tag = data; } - if(type=="list"){ - req.listId=data; + if (type == "list") { + req.listId = data; } - req.untilId=sid; - req.limit=20; - var i={ + req.untilId = sid; + req.limit = 20; + var i = { method: method, headers: hdr, body: JSON.stringify(req), } - }else{ - var misskey=false; - var start = "https://" + domain + "/api/v1/timelines/" + com(type,data) + - "max_id=" + sid; - if(type=="dm"){ + } else { + var misskey = false; + var start = "https://" + domain + "/api/v1/timelines/" + com(type, data) + + "max_id=" + sid; + if (type == "dm") { var start = "https://" + domain + "/api/v1/conversations?" + "max_id=" + sid; } - var method="GET"; - var i={ + var method = "GET"; + var i = { method: method, headers: hdr }; } - fetch(start, i).then(function(response) { + fetch(start, i).then(function (response) { return response.json(); - }).catch(function(error) { + }).catch(function (error) { todo(error); console.error(error); - }).then(function(json) { + }).then(function (json) { console.log(json); - if(misskey){ - var templete = misskeyParse(json, '', acct_id, tlid,"",mute); - }else{ - var templete = parse(json, '', acct_id, tlid,"",mute, type); + if (misskey) { + var templete = misskeyParse(json, '', acct_id, tlid, "", mute); + } else { + var templete = parse(json, '', acct_id, tlid, "", mute, type); } $("#timeline_" + tlid).append(templete); additional(acct_id, tlid); jQuery("time.timeago").timeago(); - moreloading=false; + moreloading = false; todc(); }); } @@ -453,115 +453,115 @@ function tlDiff(type, data, acct_id, tlid, delc, voice, mode) { var acct_id = obj[tlid].domain; if (!type) { var type = obj[tlid].type; - }else{ + } else { var data; } - if(type=="tag"){ - var data=obj[tlid].data; + if (type == "tag") { + var data = obj[tlid].data; var tag = localStorage.getItem("tag-range"); - if(tag=="local"){ - data=data+"&local=true"; + if (tag == "local") { + data = data + "&local=true"; } - }else if(type=="list"){ - var data=obj[tlid].data; + } else if (type == "list") { + var data = obj[tlid].data; } var sid = $("#timeline_" + tlid + " .cvo").first().attr("unique-id"); if (sid && !moreloading) { - if (type == "mix" && localStorage.getItem("mode_" + localStorage.getItem("domain_" + acct_id))!="misskey") { + if (type == "mix" && localStorage.getItem("mode_" + localStorage.getItem("domain_" + acct_id)) != "misskey") { return; - }else if (type == "plus" && localStorage.getItem("mode_" + localStorage.getItem("domain_" + acct_id))!="misskey") { + } else if (type == "plus" && localStorage.getItem("mode_" + localStorage.getItem("domain_" + acct_id)) != "misskey") { return; - }else if (type == "notf") { + } else if (type == "notf") { return; } - moreloading=true; + moreloading = true; localStorage.setItem("now", type); todo(cap(type) + " TL MoreLoading"); - if(type!="noauth"){ - var at = localStorage.getItem("acct_"+ acct_id + "_at"); - var hdr={ + if (type != "noauth") { + var at = localStorage.getItem("acct_" + acct_id + "_at"); + var hdr = { 'content-type': 'application/json', 'Authorization': 'Bearer ' + at }; - var domain = localStorage.getItem("domain_" + acct_id); - }else{ - var hdr={ + var domain = localStorage.getItem("domain_" + acct_id); + } else { + var hdr = { 'content-type': 'application/json' }; - domain=acct_id; + domain = acct_id; } - if(localStorage.getItem("mode_" + domain)=="misskey"){ - var misskey=true; - hdr={ + if (localStorage.getItem("mode_" + domain) == "misskey") { + var misskey = true; + hdr = { 'content-type': 'application/json' }; - var url=misskeycom(type, data); - var start = "https://" + domain + "/api/notes/"+url; - var method="POST"; - var req={}; - if(type!="noauth"){ - req.i=at; + var url = misskeycom(type, data); + var start = "https://" + domain + "/api/notes/" + url; + var method = "POST"; + var req = {}; + if (type != "noauth") { + req.i = at; } - if(type=="local-media"||type=="pub-media"){ - req.mediaOnly=true; + if (type == "local-media" || type == "pub-media") { + req.mediaOnly = true; } - if(type=="tag"){ - req.tag=data; + if (type == "tag") { + req.tag = data; } - if(type=="list"){ - req.listId=data; + if (type == "list") { + req.listId = data; } - req.sinceId=sid; - req.limit=20; - var i={ + req.sinceId = sid; + req.limit = 20; + var i = { method: method, headers: hdr, body: JSON.stringify(req), } - }else{ - var misskey=false; - var start = "https://" + domain + "/api/v1/timelines/" + com(type,data) + - "since_id=" + sid; - if(type=="dm"){ + } else { + var misskey = false; + var start = "https://" + domain + "/api/v1/timelines/" + com(type, data) + + "since_id=" + sid; + if (type == "dm") { var start = "https://" + domain + "/api/v1/conversations?" + "since_id=" + sid; } - var method="GET"; - var i={ + var method = "GET"; + var i = { method: method, headers: hdr }; } - - - fetch(start, i).then(function(response) { + + + fetch(start, i).then(function (response) { return response.json(); - }).catch(function(error) { + }).catch(function (error) { todo(error); console.error(error); - }).then(function(json) { + }).then(function (json) { console.log(json); - if(misskey){ - var templete = misskeyParse(json, '', acct_id, tlid,"",mute); - }else{ - var templete = parse(json, '', acct_id, tlid,"",mute, type); + if (misskey) { + var templete = misskeyParse(json, '', acct_id, tlid, "", mute); + } else { + var templete = parse(json, '', acct_id, tlid, "", mute, type); } $("#timeline_" + tlid).prepend(templete); additional(acct_id, tlid); jQuery("time.timeago").timeago(); - moreloading=false; + moreloading = false; todc(); }); } } //TL再取得 -function reloadTL(type, data, acct_id, key, delc,voice){ - tl(type, data, acct_id, key, delc,voice,""); +function reloadTL(type, data, acct_id, key, delc, voice) { + tl(type, data, acct_id, key, delc, voice, ""); } //WebSocket切断 function tlCloser() { - Object.keys(websocket).forEach(function(tlid) { + Object.keys(websocket).forEach(function (tlid) { if (websocketOld[tlid]) { websocketOld[tlid].close(); console.log("Close Streaming API: Old" + tlid); @@ -574,7 +574,7 @@ function tlCloser() { }); websocket = []; - Object.keys(websocketHome).forEach(function(tlid) { + Object.keys(websocketHome).forEach(function (tlid) { if (websocketHome[tlid]) { websocketHome[tlid].close(); console.log("Close Streaming API:MixHome" + tlid); @@ -582,7 +582,7 @@ function tlCloser() { }); websocketHome = []; - Object.keys(websocketLocal).forEach(function(tlid) { + Object.keys(websocketLocal).forEach(function (tlid) { if (websocketLocal[tlid]) { websocketLocal[tlid].close(); console.log("Close Streaming API:MixLocal" + tlid); @@ -590,80 +590,86 @@ function tlCloser() { }); websocketLocal = []; - Object.keys(websocketNotf).forEach(function(tlid) { + Object.keys(websocketNotf).forEach(function (tlid) { if (websocketNotf[tlid]) { websocketNotf[tlid].close(); console.log("Close Streaming API:Notf" + tlid); } }); - websocketNotf = []; + Object.keys(misskeyws).forEach(function (tlid) { + if (misskeyws[tlid]) { + misskeyws[tlid].close(); + console.log("Close Streaming API:Misskey" + tlid); + } + }); + misskeyws={} } //TLのタイトル function cap(type, data, acct_id) { //独自ロケール var locale = localStorage.getItem("locale"); - if(locale=="yes"){ - var locale=false; + if (locale == "yes") { + var locale = false; } if (type == "home") { - if(localStorage.getItem("home_" + acct_id) && !locale){ - var response=localStorage.getItem("home_" + acct_id); - }else{ - var response="Home TL"; + if (localStorage.getItem("home_" + acct_id) && !locale) { + var response = localStorage.getItem("home_" + acct_id); + } else { + var response = "Home TL"; } } else if (type == "local") { - if(localStorage.getItem("local_" + acct_id) && !locale){ - var response=localStorage.getItem("local_" + acct_id); - }else{ - var response="Local TL"; + if (localStorage.getItem("local_" + acct_id) && !locale) { + var response = localStorage.getItem("local_" + acct_id); + } else { + var response = "Local TL"; } } else if (type == "local-media") { - if(localStorage.getItem("local_" + acct_id) && !locale){ - var response=localStorage.getItem("local_" + acct_id)+"("+lang.lang_tl_media +")"; - }else{ - var response="Local TL(Media)"; + if (localStorage.getItem("local_" + acct_id) && !locale) { + var response = localStorage.getItem("local_" + acct_id) + "(" + lang.lang_tl_media + ")"; + } else { + var response = "Local TL(Media)"; } } else if (type == "pub") { - if(localStorage.getItem("public_" + acct_id) && !locale){ - var response=localStorage.getItem("public_" + acct_id); - }else{ - var response="Federated TL"; + if (localStorage.getItem("public_" + acct_id) && !locale) { + var response = localStorage.getItem("public_" + acct_id); + } else { + var response = "Federated TL"; } } else if (type == "pub-media") { - if(localStorage.getItem("public_" + acct_id) && !locale){ - var response=localStorage.getItem("public_" + acct_id)+"("+lang.lang_tl_media +")"; - }else{ - var response="Federated TL(Media)"; + if (localStorage.getItem("public_" + acct_id) && !locale) { + var response = localStorage.getItem("public_" + acct_id) + "(" + lang.lang_tl_media + ")"; + } else { + var response = "Federated TL(Media)"; } } else if (type == "tag") { - var response= "#" + escapeHTML(data) + var response = "#" + escapeHTML(data) } else if (type == "list") { - var ltitle=localStorage.getItem("list_"+data+"_"+acct_id); - var response= "List(" + ltitle + ")" + var ltitle = localStorage.getItem("list_" + data + "_" + acct_id); + var response = "List(" + ltitle + ")" } else if (type == "notf") { - if(localStorage.getItem("notification_" + acct_id) && !locale){ - var response=localStorage.getItem("notification_" + acct_id); - }else{ - var response="Notification TL"; + if (localStorage.getItem("notification_" + acct_id) && !locale) { + var response = localStorage.getItem("notification_" + acct_id); + } else { + var response = "Notification TL"; } } else if (type == "noauth") { - var response= "Glance TL" + var response = "Glance TL" } else if (type == "dm") { - var response= "DM" + var response = "DM" } else if (type == "mix") { - if(localStorage.getItem("mode_" + localStorage.getItem("domain_" + acct_id))=="misskey"){ - var response= "Social TL" - }else{ - var response= "Integrated" + if (localStorage.getItem("mode_" + localStorage.getItem("domain_" + acct_id)) == "misskey") { + var response = "Social TL" + } else { + var response = "Integrated" } } else if (type == "plus") { - var response= "Local+" - }else if (type == "webview") { - var response="Twitter" - }else if (type == "tootsearch") { - var response="tootsearch(" + escapeHTML(data) + ")"; + var response = "Local+" + } else if (type == "webview") { + var response = "Twitter" + } else if (type == "tootsearch") { + var response = "tootsearch(" + escapeHTML(data) + ")"; } return response; } @@ -682,14 +688,14 @@ function com(type, data) { return "public?only_media=true&" } else if (type == "tag") { return "tag/" + data + "?" - }else if (type == "list") { + } else if (type == "list") { return "list/" + data + "?" - }else if (type=="dm") { + } else if (type == "dm") { return "direct?" } } //Misskey -function typePs(type){ +function typePs(type) { if (type == "home") { return "homeTimeline" } else if (type == "local" || type == "noauth") { @@ -702,14 +708,14 @@ function typePs(type){ return "hybridTimeline" } else if (type == "tag") { return "hashtag" - }else if (type == "list") { + } else if (type == "list") { return "userList" } } function misskeycom(type, data) { if (type == "home") { return "timeline" - }else if (type == "mix") { + } else if (type == "mix") { return "hybrid-timeline" } else if (type == "local" || type == "noauth") { return "local-timeline" @@ -721,7 +727,7 @@ function misskeycom(type, data) { return "global-timeline" } else if (type == "tag") { return "search_by_tag" - }else if (type == "list") { + } else if (type == "list") { return "user-list-timeline" } } @@ -729,93 +735,93 @@ function misskeycom(type, data) { //TLのアイコン function icon(type) { if (type == "home") { - var response="home"; + var response = "home"; } else if (type == "local") { - var response="people_outline"; + var response = "people_outline"; } else if (type == "local-media") { - var response="people_outline"; + var response = "people_outline"; } else if (type == "pub") { - var response="language"; + var response = "language"; } else if (type == "pub-media") { - var response="language"; + var response = "language"; } else if (type == "tag") { - var response="whatshot"; + var response = "whatshot"; } else if (type == "list") { - var response="view_headline"; + var response = "view_headline"; } else if (type == "notf") { - var response="notifications"; + var response = "notifications"; } else if (type == "noauth") { - var response="people_outline"; + var response = "people_outline"; } else if (type == "dm") { - var response="mail_outline"; + var response = "mail_outline"; } else if (type == "mix") { - var response="merge_type"; + var response = "merge_type"; } else if (type == "plus") { - var response="merge_type"; - }else if (type == "webview") { - var response="language"; - }else if (type == "tootsearch") { - var response="search"; + var response = "merge_type"; + } else if (type == "webview") { + var response = "language"; + } else if (type == "tootsearch") { + var response = "search"; } return response; } -function strAlive(){ - var date = new Date() ; - var a = date.getTime() ; - var unix = Math.floor( a / 1000 ) ; +function strAlive() { + var date = new Date(); + var a = date.getTime(); + var unix = Math.floor(a / 1000); var col = localStorage.getItem("column"); - if(col){ + if (col) { var obj = JSON.parse(col); - Object.keys(obj).forEach(function(key) { - if($("#notice_icon_" + key).hasClass("red-text")){ - var type=obj[key].type; - var acct_id=obj[key].domain; - var data=obj[key].data; + Object.keys(obj).forEach(function (key) { + if ($("#notice_icon_" + key).hasClass("red-text")) { + var type = obj[key].type; + var acct_id = obj[key].domain; + var data = obj[key].data; localStorage.removeItem("wserror_" + tlid) - reconnector(key,type,acct_id,data,"error"); + reconnector(key, type, acct_id, data, "error"); } }); } return; } -function strAliveInt(){ - setTimeout(strAlive, 10000); +function strAliveInt() { + setTimeout(strAlive, 10000); } -function reconnector(tlid,type,acct_id,data,mode){ - console.log("Reconnector:"+mode) - if(type=="mix" || type=="integrated" || type=="plus"){ - if(localStorage.getItem("voice_" + tlid)){ - var voice=true; - }else{ - var voice=false; +function reconnector(tlid, type, acct_id, data, mode) { + console.log("Reconnector:" + mode) + if (type == "mix" || type == "integrated" || type == "plus") { + if (localStorage.getItem("voice_" + tlid)) { + var voice = true; + } else { + var voice = false; } - if(localStorage.getItem("filter_"+ acct_id)!="undefined"){ - var mute=getFilterType(JSON.parse(localStorage.getItem("filter_"+ acct_id)),type); - }else{ - var mute=[]; + if (localStorage.getItem("filter_" + acct_id) != "undefined") { + var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), type); + } else { + var mute = []; } - var wssh=localStorage.getItem("wssH_" + tlid); + var wssh = localStorage.getItem("wssH_" + tlid); websocketHome[wssh].close(); - var wssl=localStorage.getItem("wssL_" + tlid); + var wssl = localStorage.getItem("wssL_" + tlid); websocketLocal[wssl].close(); - mixre(acct_id, tlid, type, mute,"",voice,mode); - }else if(type=="notf"){ + mixre(acct_id, tlid, type, mute, "", voice, mode); + } else if (type == "notf") { notfColumn(acct_id, tlid, "") - }else{ - var wss=localStorage.getItem("wss_" + tlid); + } else { + var wss = localStorage.getItem("wss_" + tlid); websocket[wss].close(); - if(localStorage.getItem("voice_" + tlid)){ - var voice=true; - }else{ - var voice=false; + if (localStorage.getItem("voice_" + tlid)) { + var voice = true; + } else { + var voice = false; } - if(localStorage.getItem("filter_"+ acct_id)!="undefined"){ - var mute=getFilterType(JSON.parse(localStorage.getItem("filter_"+ acct_id)),type); - }else{ - var mute=[]; + if (localStorage.getItem("filter_" + acct_id) != "undefined") { + var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), type); + } else { + var mute = []; } - reload(type, '', acct_id, tlid, data, mute, "",voice,mode); + reload(type, '', acct_id, tlid, data, mute, "", voice, mode); } Materialize.toast(lang.lang_tl_reconnect, 2000); } diff --git a/app/js/ui/layout.js b/app/js/ui/layout.js index 4ea773c3..7338e7db 100644 --- a/app/js/ui/layout.js +++ b/app/js/ui/layout.js @@ -20,7 +20,7 @@ $('.type').click(function() { $("#type-sel").val($(this).attr("data-type")) }) //最初、カラム変更時に発火 -function parseColumn() { +function parseColumn(dontclose) { console.log("parse"); var size = localStorage.getItem("size"); if (size) { @@ -31,11 +31,14 @@ function parseColumn() { if(localStorage.getItem("menu-done")){ $("#fukidashi").addClass("hide") } - tlCloser(); + if(!dontclose){ + tlCloser(); + } + var multi = localStorage.getItem("multi"); if (multi) { var obj = JSON.parse(multi); - + var templete; Object.keys(obj).forEach(function(key) { var acct = obj[key]; @@ -49,6 +52,11 @@ function parseColumn() { ckdb(key); //フィルターデータ読もう getFilter(key); + var domain = localStorage.getItem("domain_" + key); + if(localStorage.getItem("mode_" + domain)=="misskey"){ + localStorage.removeItem("misskey_wss_" + key) + connectMisskey(key) + } }); } var acctlist=obj; diff --git a/app/main/system.js b/app/main/system.js index 05f86167..db6387ee 100644 --- a/app/main/system.js +++ b/app/main/system.js @@ -73,7 +73,7 @@ function system(mainWindow, dir, lang) { var ver = app.getVersion() var window = new BrowserWindow({ width: 300, - height: 460, + height: 480, "transparent": false, // ウィンドウの背景を透過 "frame": false, // 枠の無いウィンドウ "resizable": false diff --git a/app/package.json b/app/package.json index 52b9dedc..9014e41a 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "thedesk", - "version": "18.3.3", + "version": "18.4.0", "description": "TheDesk is a Mastodon client for PC.", "repository": "https://github.com/cutls/TheDesk", "main": "main.js", @@ -11,15 +11,15 @@ "build:all": "electron-builder --win --linux", "build:win": "electron-builder --win" }, - "keywords": [], + "keywords": ["mastodon","client","electron","thedesk"], "bugs": { "url": "https://github.com/cutls/TheDesk/issues", - "email": "mstdn@thedesk.top" + "email": "web-pro@cutls.com" }, "homepage": "https://thedesk.top", "author": { "name": "Cutls", - "url": "https://kirishima.clooud/@Cutls", + "url": "https://cutls.com/@Cutls", "email": "web-pro@cutls.com" }, "contributor": [ diff --git a/app/view/en/index.html b/app/view/en/index.html index d1cfdf25..f2b87b30 100644 --- a/app/view/en/index.html +++ b/app/view/en/index.html @@ -36,7 +36,7 @@