cannot fav and bt

This commit is contained in:
cutls 2019-10-11 23:50:25 +09:00
parent f74e2262dc
commit 1917531c54
3 changed files with 485 additions and 483 deletions

View File

@ -10,23 +10,25 @@ function fav(id, acct_id, remote) {
var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/statuses/" + id + "/" + flag;
var httpreq = new XMLHttpRequest();
httpreq.open('POST', start, true);
httpreq.setRequestHeader('Content-Type', 'application/json');
httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
httpreq.open("POST", start, true);
httpreq.setRequestHeader("Content-Type", "application/json");
httpreq.setRequestHeader("Authorization", "Bearer " + at);
httpreq.responseType = "json";
httpreq.send();
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
if (json.reblog) {
json = json.reblog
json = json.reblog;
}
if (remote != "remote") {
//APIのふぁぼカウントがおかしい
if ($("[toot-id=" + id + "] .fav_ct").text() == json.favourites_count) {
if ($("[unique-id=" + id + "] .fav_ct").text() == json.favourites_count) {
if (flag == "unfavourite") {
var fav = json.favourites_count - 1;
if ( fav * 1 < 0){ fav = 0}
if (fav * 1 < 0) {
fav = 0;
}
} else {
var fav = json.favourites_count;
//var fav = json.favourites_count;
@ -34,20 +36,20 @@ function fav(id, acct_id, remote) {
} else {
var fav = json.favourites_count;
}
$("[toot-id=" + id + "] .fav_ct").text(fav);
$("[toot-id=" + id + "] .rt_ct").text(json.reblogs_count);
if ($("[toot-id=" + id + "]").hasClass("faved")) {
$("[toot-id=" + id + "]").removeClass("faved");
$("[unique-id=" + id + "] .fav_ct").text(fav);
$("[unique-id=" + id + "] .rt_ct").text(json.reblogs_count);
if ($("[unique-id=" + id + "]").hasClass("faved")) {
$("[unique-id=" + id + "]").removeClass("faved");
$(".fav_" + id).removeClass("yellow-text");
} else {
$("[toot-id=" + id + "]").addClass("faved");
$("[unique-id=" + id + "]").addClass("faved");
$(".fav_" + id).addClass("yellow-text");
}
} else {
M.toast({ html: lang.lang_status_favWarn, displayLength: 1000 })
}
M.toast({ html: lang.lang_status_favWarn, displayLength: 1000 });
}
}
};
}
//ブースト
@ -61,9 +63,9 @@ function rt(id, acct_id, remote, vis) {
var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/statuses/" + id + "/" + flag;
var httpreq = new XMLHttpRequest();
httpreq.open('POST', start, true);
httpreq.setRequestHeader('Content-Type', 'application/json');
httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
httpreq.open("POST", start, true);
httpreq.setRequestHeader("Content-Type", "application/json");
httpreq.setRequestHeader("Authorization", "Bearer " + at);
httpreq.responseType = "json";
if (vis) {
httpreq.send(JSON.stringify({ visibility: vis }));
@ -74,46 +76,44 @@ function rt(id, acct_id, remote, vis) {
if (httpreq.readyState === 4) {
var json = httpreq.response;
if (json.reblog) {
json = json.reblog
json = json.reblog;
}
console.log(["Success: boost", json]);
if (remote != "remote") {
$("[toot-id=" + id + "] .fav_ct").text(json.favourites_count);
$("[unique-id=" + id + "] .fav_ct").text(json.favourites_count);
if (!json.reblog) {
if (flag == "unreblog") {
var rt = json.reblogs_count - 1;
if ( rt * 1 < 0){ rt = 0}
if (rt * 1 < 0) {
rt = 0;
}
} else {
var rt = json.reblogs_count;
}
$("[toot-id=" + id + "] .rt_ct").text(rt);
$("[unique-id=" + id + "] .rt_ct").text(rt);
} else {
$("[toot-id=" + id + "] .rt_ct").text(json.reblogs_count);
$("[unique-id=" + id + "] .rt_ct").text(json.reblogs_count);
}
if ($("[toot-id=" + id + "]").hasClass("rted")) {
$("[toot-id=" + id + "]").removeClass("rted");
if ($("[unique-id=" + id + "]").hasClass("rted")) {
$("[unique-id=" + id + "]").removeClass("rted");
$(".rt_" + id).removeClass("light-blue-text");
} else {
$("[toot-id=" + id + "]").addClass("rted");
$("[unique-id=" + id + "]").addClass("rted");
$(".rt_" + id).addClass("light-blue-text");
}
} else {
M.toast({ html: lang.lang_status_btWarn, displayLength: 1000 })
}
}
}
};
}
function boostWith(vis) {
var id = $("#tootmodal").attr("data-id");
var acct_id = $("#tootmodal").attr("data-acct");
rt(id, acct_id, false, vis)
rt(id, acct_id, false, vis);
}
//フォロー
function follow(acct_id, remote) {
if (!acct_id && acct_id != "selector") {
var acct_id = $('#his-data').attr("use-acct");
var acct_id = $("#his-data").attr("use-acct");
} else if (acct_id == "selector") {
var acct_id = $("#user-acct-sel").val();
}
@ -134,14 +134,14 @@ function follow(acct_id, remote) {
var start = "https://" + domain + "/api/v1/accounts/" + id + "/" + flag;
if (localStorage.getItem("mode_" + domain) == "misskey") {
var start = "https://" + domain + "/api/following/" + flagm;
var ent = { "i": at, "userId": id }
var ent = { i: at, userId: id };
} else if (remote == "true" && flag == "follow") {
var ent = {}
var ent = {};
}
var httpreq = new XMLHttpRequest();
httpreq.open('POST', start, true);
httpreq.setRequestHeader('Content-Type', 'application/json');
httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
httpreq.open("POST", start, true);
httpreq.setRequestHeader("Content-Type", "application/json");
httpreq.setRequestHeader("Authorization", "Bearer " + at);
httpreq.responseType = "json";
httpreq.send(JSON.stringify(ent));
httpreq.onreadystatechange = function() {
@ -156,40 +156,40 @@ function follow(acct_id, remote) {
$("#his-follow-btn").text(lang.lang_status_unfollow);
}
}
}
};
}
//ブロック
function block(acct_id) {
if ($("#his-data").hasClass("blocking")) {
var flag = "unblock";
var txt = lang.lang_status_unmute
var txt = lang.lang_status_unmute;
} else {
var flag = "block";
var txt = lang.lang_status_block
var txt = lang.lang_status_block;
}
Swal.fire({
title: txt,
text: "",
type: 'warning',
type: "warning",
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: lang.lang_yesno,
cancelButtonText: lang.lang_no
}).then((result) => {
}).then(result => {
if (result.value) {
if (!acct_id) {
var acct_id = $('#his-data').attr("use-acct");
var acct_id = $("#his-data").attr("use-acct");
}
var id = $("#his-data").attr("user-id");
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/accounts/" + id + "/" + flag;
var httpreq = new XMLHttpRequest();
httpreq.open('POST', start, true);
httpreq.setRequestHeader('Content-Type', 'application/json');
httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
httpreq.open("POST", start, true);
httpreq.setRequestHeader("Content-Type", "application/json");
httpreq.setRequestHeader("Authorization", "Bearer " + at);
httpreq.responseType = "json";
httpreq.send();
httpreq.onreadystatechange = function() {
@ -202,10 +202,9 @@ function block(acct_id) {
$("#his-block-btn").text(lang.lang_status_unblock);
}
}
}
};
}
});
}
//ミュート
@ -213,41 +212,41 @@ function muteDo(acct_id) {
if ($("#his-data").hasClass("muting")) {
var flag = "unmute";
var flagm = "delete";
var txt = lang.lang_status_unmute
var txt = lang.lang_status_unmute;
} else {
var flag = "mute";
var flagm = "create";
var txt = lang.lang_status_mute
var txt = lang.lang_status_mute;
}
Swal.fire({
title: txt,
text: "",
type: 'warning',
type: "warning",
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: lang.lang_yesno,
cancelButtonText: lang.lang_no
}).then((result) => {
}).then(result => {
if (result.value) {
if (!acct_id) {
var acct_id = $('#his-data').attr("use-acct");
var acct_id = $("#his-data").attr("use-acct");
}
var id = $("#his-data").attr("user-id");
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
if (localStorage.getItem("mode_" + domain) == "misskey") {
var start = "https://" + domain + "/api/mute/" + flagm;
var ent = { "i": at, "userId": id }
var ent = { i: at, userId: id };
var rq = JSON.stringify(ent);
} else {
var start = "https://" + domain + "/api/v1/accounts/" + id + "/" + flag;
var rq = "";
}
var httpreq = new XMLHttpRequest();
httpreq.open('POST', start, true);
httpreq.setRequestHeader('Content-Type', 'application/json');
httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
httpreq.open("POST", start, true);
httpreq.setRequestHeader("Content-Type", "application/json");
httpreq.setRequestHeader("Authorization", "Bearer " + at);
httpreq.responseType = "json";
httpreq.send(rq);
httpreq.onreadystatechange = function() {
@ -260,10 +259,9 @@ function muteDo(acct_id) {
$("#his-mute-btn").text(lang.lang_status_unmute);
}
}
}
};
}
});
}
//投稿削除
@ -273,8 +271,8 @@ function del(id, acct_id) {
if (localStorage.getItem("mode_" + domain) == "misskey") {
var start = "https://" + domain + "/api/notes/delete";
var httpreq = new XMLHttpRequest();
httpreq.open('POST', start, true);
httpreq.setRequestHeader('Content-Type', 'application/json');
httpreq.open("POST", start, true);
httpreq.setRequestHeader("Content-Type", "application/json");
httpreq.responseType = "json";
httpreq.send(JSON.stringify({ i: at, noteId: id }));
$("[toot-id=" + id + "]").hide();
@ -282,36 +280,36 @@ function del(id, acct_id) {
} else {
var start = "https://" + domain + "/api/v1/statuses/" + id;
var httpreq = new XMLHttpRequest();
httpreq.open('DELETE', start, true);
httpreq.setRequestHeader('Content-Type', 'application/json');
httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
httpreq.open("DELETE", start, true);
httpreq.setRequestHeader("Content-Type", "application/json");
httpreq.setRequestHeader("Authorization", "Bearer " + at);
httpreq.responseType = "json";
httpreq.send();
}
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
}
}
};
}
//redraft
function redraft(id, acct_id) {
Swal.fire({
title: lang.lang_status_redraftTitle,
text: lang.lang_status_redraft,
type: 'warning',
type: "warning",
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: lang.lang_yesno,
cancelButtonText: lang.lang_no
}).then((result) => {
}).then(result => {
if (result.value) {
show();
del(id, acct_id);
$("#post-acct-sel").prop("disabled", true);
$("#post-acct-sel").val(acct_id);
$('select').formSelect();
mdCheck()
$("select").formSelect();
mdCheck();
var medias = $("[toot-id=" + id + "]").attr("data-medias");
var vismode = $("[toot-id=" + id + "] .vis-data").attr("data-vis");
vis(vismode);
@ -321,7 +319,9 @@ function redraft(id, acct_id) {
if (i < ct) {
var url = $(elem).attr("src");
console.log("Play back image data:" + url);
$('#preview').append('<img src="' + url + '" style="width:50px; max-height:100px;">');
$("#preview").append(
'<img src="' + url + '" style="width:50px; max-height:100px;">'
);
}
});
var html = $("[toot-id=" + id + "] .toot").html();
@ -341,7 +341,7 @@ function redraft(id, acct_id) {
$("#cw-text").val(cwtxt);
}
}
})
});
}
//ピン留め
function pin(id, acct_id) {
@ -354,9 +354,9 @@ function pin(id, acct_id) {
var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/statuses/" + id + "/" + flag;
var httpreq = new XMLHttpRequest();
httpreq.open('POST', start, true);
httpreq.setRequestHeader('Content-Type', 'application/json');
httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
httpreq.open("POST", start, true);
httpreq.setRequestHeader("Content-Type", "application/json");
httpreq.setRequestHeader("Authorization", "Bearer " + at);
httpreq.responseType = "json";
httpreq.send();
httpreq.onreadystatechange = function() {
@ -371,18 +371,19 @@ function pin(id, acct_id) {
$(".pin_" + id).addClass("blue-text");
}
}
}
};
}
//フォロリク
function request(id, flag, acct_id) {
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/follow_requests/" + id + "/" + flag;
var start =
"https://" + domain + "/api/v1/follow_requests/" + id + "/" + flag;
var httpreq = new XMLHttpRequest();
httpreq.open('POST', start, true);
httpreq.setRequestHeader('Content-Type', 'application/json');
httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
httpreq.open("POST", start, true);
httpreq.setRequestHeader("Content-Type", "application/json");
httpreq.setRequestHeader("Authorization", "Bearer " + at);
httpreq.responseType = "json";
httpreq.send();
httpreq.onreadystatechange = function() {
@ -391,21 +392,21 @@ function request(id, flag, acct_id) {
console.log(["Success: request", "type:" + flag, json]);
showReq();
}
}
};
}
//ドメインブロック(未実装)
function domainblock(add, flag, acct_id) {
if (!acct_id) {
var acct_id = $('#his-data').attr("use-acct");
var acct_id = $("#his-data").attr("use-acct");
}
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/domain_blocks"
var start = "https://" + domain + "/api/v1/domain_blocks";
var httpreq = new XMLHttpRequest();
httpreq.open('POST', start, true);
httpreq.setRequestHeader('Content-Type', 'application/json');
httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
httpreq.open("POST", start, true);
httpreq.setRequestHeader("Content-Type", "application/json");
httpreq.setRequestHeader("Authorization", "Bearer " + at);
httpreq.responseType = "json";
httpreq.send();
httpreq.onreadystatechange = function() {
@ -414,12 +415,12 @@ function domainblock(add, flag, acct_id) {
console.log(["Success: domain block", json]);
showDom();
}
}
};
}
function addDomainblock() {
var domain = $("#domainblock").val();
domainblock(domain, 'POST');
domainblock(domain, "POST");
}
//ユーザー強調
function empUser() {
@ -429,7 +430,7 @@ function empUser() {
if (!obj) {
var obj = [];
obj.push(id);
M.toast({ html: id + lang.lang_status_emphas, displayLength: 4000 })
M.toast({ html: id + lang.lang_status_emphas, displayLength: 4000 });
} else {
var can;
Object.keys(obj).forEach(function(key) {
@ -439,7 +440,7 @@ function empUser() {
} else {
can = true;
obj.splice(key, 1);
M.toast({ html: id + lang.lang_status_unemphas, displayLength: 4000 })
M.toast({ html: id + lang.lang_status_unemphas, displayLength: 4000 });
}
});
}
@ -459,29 +460,28 @@ function pinUser() {
var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/accounts/" + id + "/" + flag;
var httpreq = new XMLHttpRequest();
httpreq.open('POST', start, true);
httpreq.setRequestHeader('Content-Type', 'application/json');
httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
httpreq.open("POST", start, true);
httpreq.setRequestHeader("Content-Type", "application/json");
httpreq.setRequestHeader("Authorization", "Bearer " + at);
httpreq.responseType = "json";
httpreq.send();
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
if ($("#his-end-btn").hasClass("endorsed")) {
$("#his-end-btn").removeClass("endorsed")
$("#his-end-btn").text(lang.lang_status_endorse)
$("#his-end-btn").removeClass("endorsed");
$("#his-end-btn").text(lang.lang_status_endorse);
} else {
$("#his-end-btn").addClass("endorsed")
$("#his-end-btn").text(lang.lang_status_unendorse)
}
$("#his-end-btn").addClass("endorsed");
$("#his-end-btn").text(lang.lang_status_unendorse);
}
}
};
}
//URLコピー
function tootUriCopy(url) {
execCopy(url);
M.toast({ html: lang.lang_details_url, displayLength: 1500 })
M.toast({ html: lang.lang_details_url, displayLength: 1500 });
}
//他のアカウントで…
@ -490,26 +490,29 @@ function staEx(mode) {
var acct_id = $("#status-acct-sel").val();
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v2/search?resolve=true&q=" + url
var start = "https://" + domain + "/api/v2/search?resolve=true&q=" + url;
fetch(start, {
method: 'GET',
method: "GET",
headers: {
'content-type': 'application/json',
'Authorization': 'Bearer ' + at
"content-type": "application/json",
Authorization: "Bearer " + at
}
}).then(function (response) {
})
.then(function(response) {
return response.json();
}).catch(function (error) {
})
.catch(function(error) {
todo(error);
console.error(error);
}).then(function (json) {
})
.then(function(json) {
var id = json.statuses[0].id;
if (mode == "rt") {
rt(id, acct_id, 'remote')
rt(id, acct_id, "remote");
} else if (mode == "fav") {
fav(id, acct_id, 'remote')
fav(id, acct_id, "remote");
} else if (mode == "reply") {
reEx(id)
reEx(id);
}
});
return;
@ -525,13 +528,12 @@ function toggleAction(id, tlid, acct_id) {
if (!$(tlide + " [toot-id=" + id + "]").hasClass("ext-mode")) {
$(tlide + " [toot-id=" + id + "] .type-a").hide();
$(tlide + " [toot-id=" + id + "] .type-b").show();
$(tlide + " [toot-id=" + id + "]").addClass("ext-mode")
$(tlide + " [toot-id=" + id + "]").addClass("ext-mode");
$(tlide + " [toot-id=" + id + "] .act-icon").text("expand_less");
} else {
$(tlide + " [toot-id=" + id + "] .type-b").hide();
$(tlide + " [toot-id=" + id + "] .type-a").show();
$(tlide + " [toot-id=" + id + "]").removeClass("ext-mode")
$(tlide + " [toot-id=" + id + "]").removeClass("ext-mode");
$(tlide + " [toot-id=" + id + "] .act-icon").text("expand_more");
}
}

View File

@ -869,7 +869,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
'<div class="action ' + can_rt + ' ' + disp["rt"] + ' ' + noauth + '"><a onclick="rt(\'' + uniqueid + '\',' + acct_id +
',\'' + tlid +
'\')" class="waves-effect waves-dark btn-flat actct bt-btn" style="padding:0" title="' + lang.lang_parse_bt + '"><i class="fas fa-retweet ' +
if_rt + ' rt_' + toot.id + '"></i><span class="rt_ct">' + toot.reblogs_count +
if_rt + ' rt_' + uniqueid + '"></i><span class="rt_ct">' + toot.reblogs_count +
'</span></a></div>' +
'<div class="action ' + can_rt + ' ' + disp["qt"] + ' ' + noauth + ' ' + qtClass + '"><a onclick="qt(\'' + toot.id + '\',' + acct_id +
',\'' + toot.account.acct + '\',\'' + toot.url +
@ -877,7 +877,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
'<div class="action ' + disp["fav"] + ' ' + noauth + '"><a onclick="fav(\'' + uniqueid + '\',' + acct_id +
',\'' + tlid +
'\')" class="waves-effect waves-dark btn-flat actct fav-btn" style="padding:0" title="' + lang.lang_parse_fav + '"><i class="fas text-darken-3 fa-star' +
if_fav + ' fav_' + toot.id + '"></i><span class="fav_ct">' + toot.favourites_count +
if_fav + ' fav_' + uniqueid + '"></i><span class="fav_ct">' + toot.favourites_count +
'</a></span></div>' +
'<div class="' + if_mine + ' action ' + disp["del"] + ' ' + noauth + '"><a onclick="del(\'' + toot.id + '\',' +
acct_id +

View File

@ -1,6 +1,6 @@
{
"name": "thedesk",
"version": "18.11.1",
"version": "18.11.2",
"description": "TheDesk is a Mastodon client for PC.",
"repository": "https://github.com/cutls/TheDesk",
"main": "main.js",
@ -63,7 +63,7 @@
},
"optionalDependencies": {
"font-manager": "^0.3.0",
"itunes-nowplaying-mac": "cutls/itunes-nowplaying-mac"
"itunes-nowplaying-mac": "0.3.1"
},
"devDependencies": {
"electron": "^6.0.12",