newcomer notifiation

This commit is contained in:
cutls 2022-12-05 23:12:33 +09:00
parent f5d42fa806
commit ccc6d96172
5 changed files with 34 additions and 28 deletions

View File

@ -41,7 +41,7 @@ function notfColumn(acct_id, tlid, sys) {
httpreq.responseType = 'json'
httpreq.send(body)
httpreq.onreadystatechange = function() {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response
if (this.status !== 200) {
@ -56,7 +56,7 @@ function notfColumn(acct_id, tlid, sys) {
var templete = ''
var lastnotf = localStorage.getItem('lastnotf_' + acct_id)
localStorage.setItem('lastnotf_' + acct_id, json[0].id)
Object.keys(json).forEach(function(key) {
Object.keys(json).forEach(function (key) {
var obj = json[key]
if (lastnotf == obj.id && key > 0 && native == 'yes') {
var ct = key
@ -71,8 +71,8 @@ function notfColumn(acct_id, tlid, sys) {
var n = new Notification('TheDesk:' + domain, options)
}
var mute = getFilterTypeByAcct(acct_id, 'notif')
//Pleromaにはmoveというtypeがあるらしい。何が互換APIじゃ
if (obj.type != 'follow' && obj.type != 'move' && obj.type != 'follow_request') {
//Pleromaにはmoveというtypeがあるらしい。何が互換APIじゃ
if (obj.type !== 'follow' && obj.type !== 'move' && obj.type !== 'request' && obj.type !== 'admin.sign_up') {
if (misskey) {
templete = templete + misskeyParse([obj], 'notf', acct_id, tlid, -1, mute)
} else {
@ -90,12 +90,12 @@ function notfColumn(acct_id, tlid, sys) {
})
templete = templete + '<div class="hide notif-marker" data-maxid="' + max_id + '"></div>'
$('#timeline_' + tlid).html(templete)
// $('#landing_' + tlid).hide()
// $('#landing_' + tlid).hide()
jQuery('time.timeago').timeago()
}
$('#notf-box').addClass('fetched')
todc()
//Markers
//Markers
var markers = localStorage.getItem('markers')
if (markers == 'yes') {
markers = true
@ -155,10 +155,10 @@ function notfCommon(acct_id, tlid, sys, stream) {
return false
}
fetch(start, i)
.then(function(response) {
.then(function (response) {
console.log('header to get param:' + response.headers.get('link'))
if (!response.ok) {
response.text().then(function(text) {
response.text().then(function (text) {
console.log('notf error', 'div[data-notf=' + acct_id + '] .landing')
$('div[data-notf=' + acct_id + '] .landing').append(`<div>${response.status}</div><div>${escapeHTML(text)}`)
setLog(response.url, response.status, text)
@ -166,17 +166,17 @@ function notfCommon(acct_id, tlid, sys, stream) {
}
return response.json()
})
.catch(function(error) {
.catch(function (error) {
todo(error)
setLog(start, 'JSON', error)
console.error(error)
})
.then(function(json) {
.then(function (json) {
if (json[0]) {
var templete = ''
var lastnotf = localStorage.getItem('lastnotf_' + acct_id)
localStorage.setItem('lastnotf_' + acct_id, json[0].id)
Object.keys(json).forEach(function(key) {
Object.keys(json).forEach(function (key) {
var obj = json[key]
if (lastnotf == obj.id && key > 0 && native == 'yes') {
var ct = key
@ -191,8 +191,8 @@ function notfCommon(acct_id, tlid, sys, stream) {
var n = new Notification('TheDesk:' + domain, options)
}
var mute = getFilterTypeByAcct(acct_id, 'notif')
//Pleromaにはmoveというtypeがあるらしい。何が互換APIじゃ
if (obj.type != 'follow' && obj.type != 'move') {
//Pleromaにはmoveというtypeがあるらしい。何が互換APIじゃ
if (obj.type !== 'follow' && obj.type !== 'move' && obj.type !== 'request' && obj.type !== 'admin.sign_up') {
if (misskey) {
templete = templete + misskeyParse([obj], 'notf', acct_id, 'notf', -1, mute)
} else {
@ -207,7 +207,7 @@ function notfCommon(acct_id, tlid, sys, stream) {
}
})
$('div[data-notf=' + acct_id + ']').html(templete)
// $('#landing_' + tlid).hide()
// $('#landing_' + tlid).hide()
jQuery('time.timeago').timeago()
}
$('#notf-box').addClass('fetched')
@ -228,7 +228,7 @@ function notfWS(misskey, acct_id, tlid, domain, at) {
var wsid = websocketNotf.length
websocketNotf[acct_id] = new WebSocket(start)
websocketNotf[acct_id].onopen = function(mess) {
websocketNotf[acct_id].onopen = function (mess) {
console.table({
acct_id: acct_id,
type: 'Connect Streaming API(Notf)',
@ -237,9 +237,9 @@ function notfWS(misskey, acct_id, tlid, domain, at) {
})
$('i[data-notf=' + acct_id + ']').removeClass('red-text')
}
websocketNotf[acct_id].onmessage = function(mess) {
websocketNotf[acct_id].onmessage = function (mess) {
$('#landing_' + tlid).hide()
//console.log(["Receive Streaming API(Notf):" + acct_id + "(" + domain + ")", JSON.parse(JSON.parse(mess.data).payload)]);
//console.log(["Receive Streaming API(Notf):" + acct_id + "(" + domain + ")", JSON.parse(JSON.parse(mess.data).payload)]);
var popup = localStorage.getItem('popup')
if (!popup) {
popup = 0
@ -251,7 +251,7 @@ function notfWS(misskey, acct_id, tlid, domain, at) {
localStorage.setItem('lastnotf_' + acct_id, obj.id)
if (!$('#unread_' + tlid + ' .material-icons').hasClass('teal-text')) {
//markers show中はダメ
if (obj.type != 'follow' && obj.type != 'follow_request') {
if (obj.type !== 'follow' && obj.type !== 'move' && obj.type !== 'request' && obj.type !== 'admin.sign_up') {
templete = parse([obj], 'notf', acct_id, 'notf', popup)
} else if (obj.type == 'follow_request') {
templete = userparse([obj.account], 'request', acct_id, 'notf', -1)
@ -269,7 +269,7 @@ function notfWS(misskey, acct_id, tlid, domain, at) {
$('[toot-id=' + obj + ']').remove()
}
}
websocketNotf[acct_id].onerror = function(error) {
websocketNotf[acct_id].onerror = function (error) {
console.error('WebSocket Error ', error)
errorct++
console.log(errorct)
@ -277,7 +277,7 @@ function notfWS(misskey, acct_id, tlid, domain, at) {
notfWS(misskey, acct_id, tlid, domain, at)
}
}
websocketNotf[acct_id].onclose = function(error) {
websocketNotf[acct_id].onclose = function (error) {
console.error('WebSocket Close ', error)
errorct++
console.log(errorct)
@ -331,7 +331,7 @@ function notfmore(tlid) {
httpreq.responseType = 'json'
httpreq.send(body)
httpreq.onreadystatechange = function() {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response
if (this.status !== 200) {
@ -343,10 +343,10 @@ function notfmore(tlid) {
var templete = ''
var lastnotf = localStorage.getItem('lastnotf_' + acct_id)
localStorage.setItem('lastnotf_' + acct_id, json[0].id)
Object.keys(json).forEach(function(key) {
Object.keys(json).forEach(function (key) {
var obj = json[key]
var mute = getFilterTypeByAcct(acct_id, 'notif')
if (obj.type != 'follow') {
if (obj.type !== 'follow' && obj.type !== 'move' && obj.type !== 'request' && obj.type !== 'admin.sign_up') {
if (misskey) {
templete = templete + misskeyParse([obj], 'notf', acct_id, 'notf', -1, mute)
} else {
@ -363,7 +363,7 @@ function notfmore(tlid) {
moreloading = false
templete = templete + '<div class="hide notif-marker" data-maxid="' + max_id + '"></div>'
$('#timeline_' + tlid).append(templete)
// $('#landing_' + tlid).hide()
// $('#landing_' + tlid).hide()
jQuery('time.timeago').timeago()
}
$('#notf-box').addClass('fetched')
@ -381,7 +381,7 @@ function notfToggle(acct, tlid) {
height: '400px',
}, {
duration: 300,
complete: function() {
complete: function () {
$('#notf-box_' + tlid).css('overflow-y', 'scroll')
$('#notf-box_' + tlid).removeClass('column-hide')
},
@ -392,7 +392,7 @@ function notfToggle(acct, tlid) {
height: '0',
}, {
duration: 300,
complete: function() {
complete: function () {
$('#notf-box_' + tlid).addClass('column-hide')
$('#notf-box_' + tlid).css('display', 'none')
},
@ -429,7 +429,7 @@ function allNotfRead() {
var multi = localStorage.getItem('multi')
if (multi) {
var obj = JSON.parse(multi)
Object.keys(obj).forEach(function(key) {
Object.keys(obj).forEach(function (key) {
notfCanceler(key)
})
}

View File

@ -1217,6 +1217,8 @@ function userparse(obj, auth, acct_id, tlid, popup) {
var ftxt = lang.lang_parse_moved
} else if (auth == 'request') {
var ftxt = lang.lang_parse_request
} else if (auth == 'admin.sign_up') {
var ftxt = lang.lang_parse_signup
}
if (popup > 0 || popup == -1 || notf) {
var notftext = ftxt + '<br>'
@ -1585,7 +1587,7 @@ function mastodonBaseStreaming(acct_id) {
if (!popup) {
popup = 0
}
if (obj.type != 'follow' && obj.type != 'follow_request') {
if (obj.type !== 'follow' && obj.type !== 'move' && obj.type !== 'request' && obj.type !== 'admin.sign_up') {
template = parse([obj], 'notf', acct_id, 'notf', popup)
} else if (obj.type == 'follow_request') {
template = userparse([obj.account], 'request', acct_id, 'notf', -1)

View File

@ -176,6 +176,7 @@
"lang_showontl_botacct": "[bot]",
"lang_showontl_followed": "Following you",
"lang_parse_request": "Follow request",
"lang_parse_signup": "Newface",
"lang_showontl_notf": "Notification ",
"lang_showontl_domain": "Domain ",
"lang_showontl_listwarn": "Follow to add this user to lists.",

View File

@ -178,6 +178,8 @@
"lang_showontl_domain": "ドメイン",
"lang_showontl_listwarn": "リストに追加すんにはまずフォローしてな。",
"lang_showontl_verified": "このサイトはこの人のやつやってわかってる。",
"lang_parse_request": "フォローリクエスト",
"lang_parse_signup": "新規登録",
"lang_parse_mentioned": "が返信したで",
"lang_parse_faved": "がお気に入り登録したで",
"lang_parse_bted": "がブーストしたで",

View File

@ -177,6 +177,7 @@
"lang_showontl_botacct": "botアカウント",
"lang_showontl_followed": "フォローされています",
"lang_parse_request": "フォローリクエスト",
"lang_parse_signup": "新規登録",
"lang_showontl_notf": "通知",
"lang_showontl_domain": "ドメイン",
"lang_showontl_listwarn": "リストに追加するためにはフォローが必要です。",