Fix: if account is null #102
This commit is contained in:
parent
b12c18aa08
commit
30aee556f1
|
@ -491,7 +491,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
|
||||||
if (urlCont) {
|
if (urlCont) {
|
||||||
urlindv = urlindv.replace(/[.*+?^=!:${}()|[\]\/\\]/g, "\\$&")
|
urlindv = urlindv.replace(/[.*+?^=!:${}()|[\]\/\\]/g, "\\$&")
|
||||||
var encoded = encodeURI(urlCont[4])
|
var encoded = encodeURI(urlCont[4])
|
||||||
var punycoded = "xn--"+punycode.encode(urlCont[2])
|
var punycoded = "xn--" + punycode.encode(urlCont[2])
|
||||||
var eUrl = urlCont[1] + "://" + punycoded + "." + urlCont[3] + "/" + encoded
|
var eUrl = urlCont[1] + "://" + punycoded + "." + urlCont[3] + "/" + encoded
|
||||||
var regExp = new RegExp('href="' + urlindv + '"', "g")
|
var regExp = new RegExp('href="' + urlindv + '"', "g")
|
||||||
console.log(eUrl, regExp)
|
console.log(eUrl, regExp)
|
||||||
|
@ -915,119 +915,122 @@ function userparse(obj, auth, acct_id, tlid, popup) {
|
||||||
var datetype = localStorage.getItem("datetype");
|
var datetype = localStorage.getItem("datetype");
|
||||||
Object.keys(obj).forEach(function (key) {
|
Object.keys(obj).forEach(function (key) {
|
||||||
var toot = obj[key];
|
var toot = obj[key];
|
||||||
console.log(["Parsing", toot])
|
if (toot) {
|
||||||
if (!toot.username) {
|
console.log(["Parsing", toot])
|
||||||
var raw = toot;
|
if (!toot.username) {
|
||||||
toot = toot.account;
|
var raw = toot;
|
||||||
var notf = true;
|
toot = toot.account;
|
||||||
} else {
|
var notf = true;
|
||||||
var notf = false;
|
} else {
|
||||||
}
|
var notf = false;
|
||||||
if (toot.locked) {
|
|
||||||
var locked = ' <i class="fas fa-lock red-text"></i>';
|
|
||||||
} else {
|
|
||||||
var locked = "";
|
|
||||||
}
|
|
||||||
if (auth == "request") {
|
|
||||||
var authhtml = '<i class="material-icons gray pointer" onclick="request(\'' +
|
|
||||||
toot.id + '\',\'authorize\',' + acct_id + ')" title="Accept">person_add</i> <i class="material-icons gray pointer" onclick="request(\'' +
|
|
||||||
toot.id + '\',\'reject\',' + acct_id + ')" title="Reject">person_add_disabled</i>';
|
|
||||||
} else {
|
|
||||||
var authhtml = "";
|
|
||||||
}
|
|
||||||
var ftxt = lang.lang_parse_followed;
|
|
||||||
if (!locale && localStorage.getItem("followlocale_" + acct_id)) {
|
|
||||||
ftxt = localStorage.getItem("followlocale_" + acct_id);
|
|
||||||
}
|
|
||||||
if (popup > 0 || popup == -1 || notf) {
|
|
||||||
var notftext = ftxt + '<br>';
|
|
||||||
} else {
|
|
||||||
var notftext = "";
|
|
||||||
}
|
|
||||||
var memory = localStorage.getItem("notice-mem");
|
|
||||||
if (popup >= 0 && obj.length < 5 && notftext != memory) {
|
|
||||||
M.toast({ html: escapeHTML(toot.display_name) + ":" + ftxt, displayLength: popup * 1000 })
|
|
||||||
$(".notf-icon_" + tlid).addClass("red-text");
|
|
||||||
localStorage.setItem("notice-mem", notftext);
|
|
||||||
notftext = "";
|
|
||||||
var native = localStorage.getItem("nativenotf");
|
|
||||||
if (!native) {
|
|
||||||
native = "yes";
|
|
||||||
}
|
}
|
||||||
if (native == "yes") {
|
if (toot.locked) {
|
||||||
var os = localStorage.getItem("platform");
|
var locked = ' <i class="fas fa-lock red-text"></i>';
|
||||||
var options = {
|
} else {
|
||||||
body: toot.display_name + "(" + toot.acct + ")" + ftxt,
|
var locked = "";
|
||||||
icon: toot.avatar
|
}
|
||||||
};
|
if (auth == "request") {
|
||||||
var domain = localStorage.getItem("domain_" + acct_id);
|
var authhtml = '<i class="material-icons gray pointer" onclick="request(\'' +
|
||||||
if (os == "darwin") {
|
toot.id + '\',\'authorize\',' + acct_id + ')" title="Accept">person_add</i> <i class="material-icons gray pointer" onclick="request(\'' +
|
||||||
var n = new Notification('TheDesk:' + domain, options);
|
toot.id + '\',\'reject\',' + acct_id + ')" title="Reject">person_add_disabled</i>';
|
||||||
} else {
|
} else {
|
||||||
var nativeNotfOpt = [
|
var authhtml = "";
|
||||||
'TheDesk:' + domain,
|
}
|
||||||
toot.display_name + "(" + toot.acct + ")" + ftxt,
|
var ftxt = lang.lang_parse_followed;
|
||||||
toot.avatar,
|
if (!locale && localStorage.getItem("followlocale_" + acct_id)) {
|
||||||
"userdata",
|
ftxt = localStorage.getItem("followlocale_" + acct_id);
|
||||||
acct_id,
|
}
|
||||||
toot.id
|
if (popup > 0 || popup == -1 || notf) {
|
||||||
]
|
var notftext = ftxt + '<br>';
|
||||||
postMessage(["nativeNotf", nativeNotfOpt], "*")
|
} else {
|
||||||
|
var notftext = "";
|
||||||
|
}
|
||||||
|
var memory = localStorage.getItem("notice-mem");
|
||||||
|
if (popup >= 0 && obj.length < 5 && notftext != memory) {
|
||||||
|
M.toast({ html: escapeHTML(toot.display_name) + ":" + ftxt, displayLength: popup * 1000 })
|
||||||
|
$(".notf-icon_" + tlid).addClass("red-text");
|
||||||
|
localStorage.setItem("notice-mem", notftext);
|
||||||
|
notftext = "";
|
||||||
|
var native = localStorage.getItem("nativenotf");
|
||||||
|
if (!native) {
|
||||||
|
native = "yes";
|
||||||
|
}
|
||||||
|
if (native == "yes") {
|
||||||
|
var os = localStorage.getItem("platform");
|
||||||
|
var options = {
|
||||||
|
body: toot.display_name + "(" + toot.acct + ")" + ftxt,
|
||||||
|
icon: toot.avatar
|
||||||
|
};
|
||||||
|
var domain = localStorage.getItem("domain_" + acct_id);
|
||||||
|
if (os == "darwin") {
|
||||||
|
var n = new Notification('TheDesk:' + domain, options);
|
||||||
|
} else {
|
||||||
|
var nativeNotfOpt = [
|
||||||
|
'TheDesk:' + domain,
|
||||||
|
toot.display_name + "(" + toot.acct + ")" + ftxt,
|
||||||
|
toot.avatar,
|
||||||
|
"userdata",
|
||||||
|
acct_id,
|
||||||
|
toot.id
|
||||||
|
]
|
||||||
|
postMessage(["nativeNotf", nativeNotfOpt], "*")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (toot.display_name) {
|
||||||
if (toot.display_name) {
|
var dis_name = escapeHTML(toot.display_name);
|
||||||
var dis_name = escapeHTML(toot.display_name);
|
} else {
|
||||||
} else {
|
var dis_name = toot.username;
|
||||||
var dis_name = toot.username;
|
}
|
||||||
}
|
//ネイティブ通知
|
||||||
//ネイティブ通知
|
|
||||||
|
|
||||||
if (toot.emojis) {
|
if (toot.emojis) {
|
||||||
var actemojick = toot.emojis[0];
|
var actemojick = toot.emojis[0];
|
||||||
} else {
|
} else {
|
||||||
var actemojick = false;
|
var actemojick = false;
|
||||||
}
|
}
|
||||||
//絵文字があれば
|
//絵文字があれば
|
||||||
if (actemojick) {
|
if (actemojick) {
|
||||||
Object.keys(toot.emojis).forEach(function (key5) {
|
Object.keys(toot.emojis).forEach(function (key5) {
|
||||||
var emoji = toot.emojis[key5];
|
var emoji = toot.emojis[key5];
|
||||||
var shortcode = emoji.shortcode;
|
var shortcode = emoji.shortcode;
|
||||||
var emoji_url = '<img draggable="false" src="' + emoji.url +
|
var emoji_url = '<img draggable="false" src="' + emoji.url +
|
||||||
'" class="emoji-img" data-emoji="' + shortcode + '" alt=" :' + shortcode + ': ">';
|
'" class="emoji-img" data-emoji="' + shortcode + '" alt=" :' + shortcode + ': ">';
|
||||||
var regExp = new RegExp(":" + shortcode + ":", "g");
|
var regExp = new RegExp(":" + shortcode + ":", "g");
|
||||||
dis_name = dis_name.replace(regExp, emoji_url);
|
dis_name = dis_name.replace(regExp, emoji_url);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (dis_name) {
|
if (dis_name) {
|
||||||
dis_name = twemoji.parse(dis_name);
|
dis_name = twemoji.parse(dis_name);
|
||||||
}
|
}
|
||||||
if (toot.avatar) {
|
if (toot.avatar) {
|
||||||
var avatar = toot.avatar;
|
var avatar = toot.avatar;
|
||||||
} else {
|
} else {
|
||||||
var avatar = "../../img/missing.svg";
|
var avatar = "../../img/missing.svg";
|
||||||
|
}
|
||||||
|
|
||||||
|
templete = templete +
|
||||||
|
'<div class="cvo" style="padding-top:5px;" user-id="' + toot.id + '"><div class="area-notice">' +
|
||||||
|
notftext +
|
||||||
|
'</div><div class="area-icon"><a onclick="udg(\'' + toot.id + '\',' +
|
||||||
|
acct_id + ');" user="' + toot.acct + '" class="udg">' +
|
||||||
|
'<img draggable="false" src="' + avatar + '" width="40" class="prof-img" user="' + toot
|
||||||
|
.acct + '"></a></div>' +
|
||||||
|
'<div class="area-display_name"><div class="flex-name"><span class="user">' +
|
||||||
|
dis_name + '</span>' +
|
||||||
|
'<span class="sml gray" style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis;user-select:auto; cursor:text;"> @' +
|
||||||
|
toot.acct + locked + '</span>' +
|
||||||
|
'</div>' +
|
||||||
|
'</div>' +
|
||||||
|
'<div style="justify-content:space-around" class="area-toot"> <div class="cbadge" style="width:100px;">Follows:' +
|
||||||
|
toot.following_count +
|
||||||
|
'</div><div class="cbadge" style="width:100px;">Followers:' + toot.followers_count +
|
||||||
|
'</div>' + authhtml +
|
||||||
|
'</div>' +
|
||||||
|
'</div>' +
|
||||||
|
'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
templete = templete +
|
|
||||||
'<div class="cvo" style="padding-top:5px;" user-id="' + toot.id + '"><div class="area-notice">' +
|
|
||||||
notftext +
|
|
||||||
'</div><div class="area-icon"><a onclick="udg(\'' + toot.id + '\',' +
|
|
||||||
acct_id + ');" user="' + toot.acct + '" class="udg">' +
|
|
||||||
'<img draggable="false" src="' + avatar + '" width="40" class="prof-img" user="' + toot
|
|
||||||
.acct + '"></a></div>' +
|
|
||||||
'<div class="area-display_name"><div class="flex-name"><span class="user">' +
|
|
||||||
dis_name + '</span>' +
|
|
||||||
'<span class="sml gray" style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis;user-select:auto; cursor:text;"> @' +
|
|
||||||
toot.acct + locked + '</span>' +
|
|
||||||
'</div>' +
|
|
||||||
'</div>' +
|
|
||||||
'<div style="justify-content:space-around" class="area-toot"> <div class="cbadge" style="width:100px;">Follows:' +
|
|
||||||
toot.following_count +
|
|
||||||
'</div><div class="cbadge" style="width:100px;">Followers:' + toot.followers_count +
|
|
||||||
'</div>' + authhtml +
|
|
||||||
'</div>' +
|
|
||||||
'</div>' +
|
|
||||||
'</div>';
|
|
||||||
|
|
||||||
});
|
});
|
||||||
return templete;
|
return templete;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user