Fix: Improve: Integrated TL
This commit is contained in:
parent
083139efa7
commit
ef9b851309
|
@ -153,11 +153,7 @@ function replyTL(id, acct_id) {
|
|||
console.error(error)
|
||||
})
|
||||
.then(function(json) {
|
||||
if (localStorage.getItem('filter_' + acct_id) != 'undefined') {
|
||||
var mute = getFilterType(JSON.parse(localStorage.getItem('filter_' + acct_id)), 'thread')
|
||||
} else {
|
||||
var mute = []
|
||||
}
|
||||
var mute = getFilterTypeByAcct(acct_id, 'thread')
|
||||
if (localStorage.getItem('mode_' + domain) == 'misskey') {
|
||||
var templete = misskeyParse([json], '', acct_id, '', '', mute)
|
||||
$('#toot-after').prepend(templete)
|
||||
|
@ -222,11 +218,7 @@ function getContext(id, acct_id) {
|
|||
$('#toot-reply .by_filter').removeClass('hide')
|
||||
jQuery('time.timeago').timeago()
|
||||
} else {
|
||||
if (localStorage.getItem('filter_' + acct_id) != 'undefined') {
|
||||
var mute = getFilterType(JSON.parse(localStorage.getItem('filter_' + acct_id)), 'thread')
|
||||
} else {
|
||||
var mute = []
|
||||
}
|
||||
var mute = getFilterTypeByAcct(acct_id, 'thread')
|
||||
var templete = parse(json.descendants, '', acct_id, '', '', mute)
|
||||
if (templete != '') {
|
||||
$('#toot-after .no-data').hide()
|
||||
|
|
|
@ -369,12 +369,25 @@ function getFilterType(json, type) {
|
|||
Object.keys(json).forEach(function(key) {
|
||||
var filterword = json[key]
|
||||
var phrases = filterword.phrase
|
||||
if (filterword.context.join(',').indexOf(type) !== -1) {
|
||||
var arr = filterword.context
|
||||
if (arr.join(',').indexOf(type) !== -1) {
|
||||
mutedfilters.push(phrases)
|
||||
} else if (type == 'mix'){
|
||||
if (arr.indexOf('home') !== -1 || arr.indexOf('public') !== -1) {
|
||||
mutedfilters.push(phrases)
|
||||
}
|
||||
}
|
||||
})
|
||||
return mutedfilters
|
||||
}
|
||||
function getFilterTypeByAcct(acct_id, type) {
|
||||
if (localStorage.getItem('filter_' + acct_id) != 'undefined') {
|
||||
var mute = getFilterType(JSON.parse(localStorage.getItem('filter_' + acct_id)), type)
|
||||
} else {
|
||||
var mute = []
|
||||
}
|
||||
return mute
|
||||
}
|
||||
function filterUpdate(acct_id) {
|
||||
var domain = localStorage.getItem('domain_' + acct_id)
|
||||
var at = localStorage.getItem('acct_' + acct_id + '_at')
|
||||
|
|
362
app/js/tl/mix.js
362
app/js/tl/mix.js
|
@ -1,100 +1,48 @@
|
|||
//Integrated TL
|
||||
function mixtl(acct_id, tlid, type, delc, voice) {
|
||||
localStorage.removeItem('morelock')
|
||||
async function mixtl(acct_id, tlid, type, delc, voice) {
|
||||
localStorage.setItem('now', type)
|
||||
todo('Integrated TL Loading...(Local)')
|
||||
//まずLocal
|
||||
var domain = localStorage.getItem('domain_' + acct_id)
|
||||
var at = localStorage.getItem('acct_' + acct_id + '_at')
|
||||
var start = 'https://' + domain + '/api/v1/timelines/public?local=true'
|
||||
fetch(start, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
Authorization: 'Bearer ' + at
|
||||
}
|
||||
})
|
||||
.then(function(response) {
|
||||
if (!response.ok) {
|
||||
response.text().then(function(text) {
|
||||
setLog(response.url, response.status, text)
|
||||
})
|
||||
}
|
||||
return response.json()
|
||||
})
|
||||
.catch(function(error) {
|
||||
todo(error)
|
||||
setLog(start, 'JSON', error)
|
||||
console.error(error)
|
||||
})
|
||||
.then(function(jsonL) {
|
||||
var start = 'https://' + domain + '/api/v1/timelines/home'
|
||||
fetch(start, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
Authorization: 'Bearer ' + at
|
||||
}
|
||||
})
|
||||
.then(function(response) {
|
||||
if (!response.ok) {
|
||||
response.text().then(function(text) {
|
||||
setLog(response.url, response.status, text)
|
||||
})
|
||||
}
|
||||
return response.json()
|
||||
})
|
||||
.catch(function(error) {
|
||||
todo(error)
|
||||
setLog(start, 'JSON', error)
|
||||
console.error(error)
|
||||
})
|
||||
.then(function(jsonH) {
|
||||
var homearr = []
|
||||
var timeline = jsonL.concat(jsonH)
|
||||
timeline.sort(function(a, b) {
|
||||
if (date(a.created_at, 'unix') >= date(b.created_at, 'unix')) return -1
|
||||
if (date(a.created_at, 'unix') < date(b.created_at, 'unix')) return 1
|
||||
return 0
|
||||
})
|
||||
if (type == 'integrated') {
|
||||
timeline.splice(20)
|
||||
}
|
||||
var templete = ''
|
||||
if (localStorage.getItem('filter_' + acct_id) != 'undefined') {
|
||||
var mute = getFilterType(JSON.parse(localStorage.getItem('filter_' + acct_id)), 'mix')
|
||||
} else {
|
||||
var mute = []
|
||||
}
|
||||
Object.keys(timeline).forEach(function(key) {
|
||||
var pkey = key * 1 + 1
|
||||
if (pkey < timeline.length) {
|
||||
if (
|
||||
date(timeline[key].created_at, 'unix') != date(timeline[pkey].created_at, 'unix')
|
||||
) {
|
||||
if (type == 'integrated') {
|
||||
templete = templete + parse([timeline[key]], '', acct_id, tlid, '', mute, 'mix')
|
||||
} else if (type == 'plus') {
|
||||
if (timeline[key].account.acct == timeline[key].account.username) {
|
||||
templete =
|
||||
templete + parse([timeline[key]], '', acct_id, tlid, '', mute, 'plus')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
const domain = localStorage.getItem('domain_' + acct_id)
|
||||
let startLocal = 'https://' + domain + '/api/v1/timelines/public?local=true'
|
||||
let local = await getTL(startLocal, acct_id)
|
||||
let startHome = 'https://' + domain + '/api/v1/timelines/home'
|
||||
let home = await getTL(startHome, acct_id)
|
||||
let concated = _.concat(local, home)
|
||||
let uniqued = _.uniqBy(concated, 'id')
|
||||
let sorted = _.orderBy(uniqued, ['id'], ['desc'])
|
||||
let integrated = _.slice(sorted, 0, 19)
|
||||
$('#landing_' + tlid).hide()
|
||||
let mute = getFilterTypeByAcct(acct_id, 'mix')
|
||||
let templete = parse(integrated, type, acct_id, tlid, '', mute, type)
|
||||
localStorage.setItem('lastobj_' + tlid, integrated[0].id)
|
||||
$('#timeline_' + tlid).html(templete)
|
||||
mixre(acct_id, tlid, type, mute, delc, voice)
|
||||
additional(acct_id, tlid)
|
||||
jQuery('time.timeago').timeago()
|
||||
todc()
|
||||
mixre(acct_id, tlid, 'mix', mute, voice, '')
|
||||
$(window).scrollTop(0)
|
||||
lastId = integrated[0].id
|
||||
beforeLastId = integrated[1].id
|
||||
}
|
||||
async function getTL(start, acct_id) {
|
||||
const at = localStorage.getItem('acct_' + acct_id + '_at')
|
||||
let promise = await fetch(start, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
Authorization: 'Bearer ' + at
|
||||
}
|
||||
})
|
||||
if (!promise.ok) {
|
||||
promise.text().then(function(text) {
|
||||
setLog(promise.url, promise.status, text)
|
||||
})
|
||||
}
|
||||
return await promise.json()
|
||||
}
|
||||
|
||||
//Streamingに接続
|
||||
function mixre(acct_id, tlid, TLtype, mute, delc, voice, mode) {
|
||||
function mixre(acct_id, tlid, TLtype, mute, voice, mode) {
|
||||
var domain = localStorage.getItem('domain_' + acct_id)
|
||||
var at = localStorage.getItem('acct_' + acct_id + '_at')
|
||||
if (localStorage.getItem('streaming_' + acct_id)) {
|
||||
|
@ -104,11 +52,11 @@ function mixre(acct_id, tlid, TLtype, mute, delc, voice, mode) {
|
|||
}
|
||||
var startHome = wss + '/api/v1/streaming/?stream=user&access_token=' + at
|
||||
var startLocal = wss + '/api/v1/streaming/?stream=public:local&access_token=' + at
|
||||
var wshid = websocketHome.length
|
||||
var wslid = websocketLocal.length
|
||||
websocketHome[wshid] = new WebSocket(startHome)
|
||||
websocketLocal[wslid] = new WebSocket(startLocal)
|
||||
websocketHome[wshid].onopen = function(mess) {
|
||||
var wshid = wsHome.length
|
||||
var wslid = wsLocal.length
|
||||
wsHome[wshid] = new WebSocket(startHome)
|
||||
wsLocal[wslid] = new WebSocket(startLocal)
|
||||
wsHome[wshid].onopen = function(mess) {
|
||||
localStorage.setItem('wssH_' + tlid, wshid)
|
||||
console.table({
|
||||
tlid: tlid,
|
||||
|
@ -118,7 +66,7 @@ function mixre(acct_id, tlid, TLtype, mute, delc, voice, mode) {
|
|||
})
|
||||
$('#notice_icon_' + tlid).removeClass('red-text')
|
||||
}
|
||||
websocketLocal[wslid].onopen = function(mess) {
|
||||
wsLocal[wslid].onopen = function(mess) {
|
||||
localStorage.setItem('wssL_' + tlid, wslid)
|
||||
console.table({
|
||||
tlid: tlid,
|
||||
|
@ -128,98 +76,15 @@ function mixre(acct_id, tlid, TLtype, mute, delc, voice, mode) {
|
|||
})
|
||||
$('#notice_icon_' + tlid).removeClass('red-text')
|
||||
}
|
||||
websocketLocal[wslid].onmessage = function(mess) {
|
||||
console.log(['Receive Streaming API:(Integrated:Local)', obj])
|
||||
|
||||
var obj = JSON.parse(JSON.parse(mess.data).payload)
|
||||
var type = JSON.parse(mess.data).event
|
||||
if (type == 'delete') {
|
||||
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()
|
||||
wsLocal[wslid].onmessage = function(mess) {
|
||||
console.log('Receive Streaming API:(Integrated:Local)', mess)
|
||||
integratedMessage(mess, acct_id, tlid, mute, voice)
|
||||
}
|
||||
} else if (type == 'update') {
|
||||
var templete = parse([obj], '', acct_id, tlid, '', mute)
|
||||
if ($('#timeline_' + tlid + ' [toot-id=' + obj.id + ']').length < 1) {
|
||||
if (voice) {
|
||||
say(obj.content)
|
||||
wsHome[wshid].onmessage = function(mess) {
|
||||
console.log(['Receive Streaming API:(Integrated:Home)', mess])
|
||||
integratedMessage(mess, acct_id, tlid, mute, voice)
|
||||
}
|
||||
var templete = parse([obj], type, acct_id, tlid, '', mute, 'mix')
|
||||
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('二重取得発生中')
|
||||
}
|
||||
}
|
||||
}
|
||||
websocketHome[wshid].onmessage = function(mess) {
|
||||
console.log(['Receive Streaming API:(Integrated:Home)', obj])
|
||||
var obj = JSON.parse(JSON.parse(mess.data).payload)
|
||||
var type = JSON.parse(mess.data).event
|
||||
if (type == 'delete') {
|
||||
if (del > 10) {
|
||||
reconnector(tlid, type, acct_id, data)
|
||||
} else {
|
||||
localStorage.setItem('delete', del * 1 + 1)
|
||||
}
|
||||
if (delc == 'true') {
|
||||
$('[toot-id=' + JSON.parse(mess.data).payload + ']').addClass('emphasized')
|
||||
$('[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 (type == 'update') {
|
||||
localStorage.removeItem('delete')
|
||||
if (TLtype == 'integrated') {
|
||||
var templete = parse([obj], '', acct_id, tlid)
|
||||
} else if (TLtype == 'plus') {
|
||||
if (obj.account.acct == obj.account.username) {
|
||||
var templete = parse([obj], '', acct_id, tlid, '', mute, 'mix')
|
||||
} else {
|
||||
var templete = ''
|
||||
}
|
||||
}
|
||||
if ($('#timeline_' + tlid + ' [toot-id=' + obj.id + ']').length < 1) {
|
||||
if (voice) {
|
||||
say(obj.content)
|
||||
}
|
||||
var templete = parse([obj], type, acct_id, tlid, '', mute, 'mix')
|
||||
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('二重取得発生中')
|
||||
}
|
||||
}
|
||||
}
|
||||
websocketLocal[wslid].onerror = function(error) {
|
||||
wsLocal[wslid].onerror = function(error) {
|
||||
console.error('WebSocketLocal Error')
|
||||
console.error(error)
|
||||
if (mode == 'error') {
|
||||
|
@ -233,7 +98,7 @@ function mixre(acct_id, tlid, TLtype, mute, delc, voice, mode) {
|
|||
}
|
||||
}
|
||||
}
|
||||
websocketLocal[wslid].onclose = function() {
|
||||
wsLocal[wslid].onclose = function() {
|
||||
console.warn('WebSocketLocal Closing:' + tlid)
|
||||
if (mode == 'error') {
|
||||
$('#notice_icon_' + tlid).addClass('red-text')
|
||||
|
@ -246,7 +111,7 @@ function mixre(acct_id, tlid, TLtype, mute, delc, voice, mode) {
|
|||
}
|
||||
}
|
||||
}
|
||||
websocketHome[wshid].onerror = function(error) {
|
||||
wsHome[wshid].onerror = function(error) {
|
||||
console.error(['WebSocketHome Error', error])
|
||||
if (mode == 'error') {
|
||||
$('#notice_icon_' + tlid).addClass('red-text')
|
||||
|
@ -259,7 +124,7 @@ function mixre(acct_id, tlid, TLtype, mute, delc, voice, mode) {
|
|||
}
|
||||
}
|
||||
}
|
||||
websocketHome[wshid].onclose = function() {
|
||||
wsHome[wshid].onclose = function() {
|
||||
console.warn('WebSocketHome Closing:' + tlid)
|
||||
if (mode == 'error') {
|
||||
$('#notice_icon_' + tlid).addClass('red-text')
|
||||
|
@ -273,103 +138,64 @@ function mixre(acct_id, tlid, TLtype, mute, delc, voice, mode) {
|
|||
}
|
||||
}
|
||||
}
|
||||
function integratedMessage(mess, acct_id, tlid, mute, voice) {
|
||||
let data = JSON.parse(mess.data)
|
||||
let type = data.event
|
||||
let payload = data.payload
|
||||
if (type == 'delete') {
|
||||
$('[unique-id=' + payload + ']').hide()
|
||||
$('[unique-id=' + payload + ']').remove()
|
||||
} else if (type == 'update') {
|
||||
let obj = JSON.parse(payload)
|
||||
|
||||
if (obj.id != lastId && obj.id != beforeLastId) {
|
||||
lastId = obj.id
|
||||
beforeLastId = obj.id
|
||||
let dom = parse([obj], '', acct_id, tlid, '', mute)
|
||||
if (voice) say(obj.content)
|
||||
if ($('timeline_box_' + tlid + '_box .tl-box').scrollTop() === 0) {
|
||||
$('#timeline_' + tlid).prepend(dom)
|
||||
} else {
|
||||
let pool = localStorage.getItem('pool_' + tlid)
|
||||
if (pool) {
|
||||
pool = dom + pool
|
||||
} else {
|
||||
pool = dom
|
||||
}
|
||||
localStorage.setItem('pool_' + tlid, pool)
|
||||
}
|
||||
scrollck()
|
||||
additional(acct_id, tlid)
|
||||
jQuery('time.timeago').timeago()
|
||||
}
|
||||
}
|
||||
}
|
||||
//ある程度のスクロールで発火
|
||||
function mixmore(tlid, type) {
|
||||
async function mixmore(tlid, type) {
|
||||
var multi = localStorage.getItem('column')
|
||||
var obj = JSON.parse(multi)
|
||||
var acct_id = obj[tlid].domain
|
||||
moreloading = true
|
||||
todo('Integrated TL MoreLoading...(Local)')
|
||||
var domain = localStorage.getItem('domain_' + acct_id)
|
||||
var at = localStorage.getItem('acct_' + acct_id + '_at')
|
||||
var sid = $('#timeline_' + tlid + ' .cvo')
|
||||
const domain = localStorage.getItem('domain_' + acct_id)
|
||||
const sid = $('#timeline_' + tlid + ' .cvo')
|
||||
.last()
|
||||
.attr('unique-id')
|
||||
|
||||
var start = 'https://' + domain + '/api/v1/timelines/public?local=true&max_id=' + sid
|
||||
fetch(start, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
Authorization: 'Bearer ' + at
|
||||
}
|
||||
})
|
||||
.then(function(response) {
|
||||
if (!response.ok) {
|
||||
response.text().then(function(text) {
|
||||
setLog(response.url, response.status, text)
|
||||
})
|
||||
}
|
||||
return response.json()
|
||||
})
|
||||
.catch(function(error) {
|
||||
todo(error)
|
||||
setLog(start, 'JSON', error)
|
||||
console.error(error)
|
||||
})
|
||||
.then(function(jsonL) {
|
||||
var start = 'https://' + domain + '/api/v1/timelines/home?max_id=' + sid
|
||||
fetch(start, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
Authorization: 'Bearer ' + at
|
||||
}
|
||||
})
|
||||
.then(function(response) {
|
||||
if (!response.ok) {
|
||||
response.text().then(function(text) {
|
||||
setLog(response.url, response.status, text)
|
||||
})
|
||||
}
|
||||
return response.json()
|
||||
})
|
||||
.catch(function(error) {
|
||||
todo(error)
|
||||
setLog(start, 'JSON', error)
|
||||
console.error(error)
|
||||
})
|
||||
.then(function(jsonH) {
|
||||
var homearr = []
|
||||
var timeline = jsonL.concat(jsonH)
|
||||
timeline.sort(function(a, b) {
|
||||
if (date(a.created_at, 'unix') > date(b.created_at, 'unix')) return -1
|
||||
if (date(a.created_at, 'unix') < date(b.created_at, 'unix')) return 1
|
||||
return 0
|
||||
})
|
||||
timeline.splice(20)
|
||||
var templete = ''
|
||||
Object.keys(timeline).forEach(function(key) {
|
||||
var pkey = key * 1 + 1
|
||||
if (pkey < 20) {
|
||||
if (
|
||||
date(timeline[key].created_at, 'unix') != date(timeline[pkey].created_at, 'unix')
|
||||
) {
|
||||
if (localStorage.getItem('filter_' + acct_id) != 'undefined') {
|
||||
var mute = getFilterType(
|
||||
JSON.parse(localStorage.getItem('filter_' + acct_id)),
|
||||
'mix'
|
||||
)
|
||||
} else {
|
||||
var mute = []
|
||||
}
|
||||
if (type == 'integrated') {
|
||||
templete = templete + parse([timeline[key]], '', acct_id, tlid, '', mute, 'mix')
|
||||
} else if (type == 'plus') {
|
||||
if (timeline[key].account.acct == timeline[key].account.username) {
|
||||
templete = templete + parse([timeline[key]], '', acct_id, tlid, '', mute, 'mix')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
let startLocal = 'https://' + domain + '/api/v1/timelines/public?local=true&max_id=' + sid
|
||||
let local = await getTL(startLocal, acct_id)
|
||||
let startHome = 'https://' + domain + '/api/v1/timelines/home&max_id=' + sid
|
||||
let home = await getTL(startHome, acct_id)
|
||||
let concated = _.concat(local, home)
|
||||
let uniqued = _.uniqBy(concated, 'id')
|
||||
let sorted = _.orderBy(uniqued, ['id'], ['desc'])
|
||||
let integrated = _.slice(sorted, 0, 19)
|
||||
$('#landing_' + tlid).hide()
|
||||
let mute = getFilterTypeByAcct(acct_id, 'mix')
|
||||
let templete = parse(integrated, type, acct_id, tlid, '', mute, type)
|
||||
localStorage.setItem('lastobj_' + tlid, integrated[0].id)
|
||||
$('#timeline_' + tlid).append(templete)
|
||||
additional(acct_id, tlid)
|
||||
jQuery('time.timeago').timeago()
|
||||
moreloading = false
|
||||
todc()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -68,11 +68,7 @@ function notfColumn(acct_id, tlid, sys) {
|
|||
}
|
||||
var n = new Notification('TheDesk:' + domain, options)
|
||||
}
|
||||
if (localStorage.getItem('filter_' + acct_id) != 'undefined') {
|
||||
var mute = getFilterType(JSON.parse(localStorage.getItem('filter_' + acct_id)), 'notif')
|
||||
} else {
|
||||
var mute = []
|
||||
}
|
||||
var mute = getFilterTypeByAcct(acct_id, 'notif')
|
||||
if (obj.type != 'follow') {
|
||||
if (misskey) {
|
||||
templete = templete + misskeyParse([obj], 'notf', acct_id, tlid, -1, mute)
|
||||
|
@ -182,11 +178,7 @@ function notfCommon(acct_id, tlid, sys) {
|
|||
}
|
||||
var n = new Notification('TheDesk:' + domain, options)
|
||||
}
|
||||
if (localStorage.getItem('filter_' + acct_id) != 'undefined') {
|
||||
var mute = getFilterType(JSON.parse(localStorage.getItem('filter_' + acct_id)), 'notif')
|
||||
} else {
|
||||
var mute = []
|
||||
}
|
||||
var mute = getFilterTypeByAcct(acct_id, 'notif')
|
||||
if (obj.type != 'follow') {
|
||||
if (misskey) {
|
||||
templete = templete + misskeyParse([obj], 'notf', acct_id, 'notf', -1, mute)
|
||||
|
@ -335,14 +327,7 @@ function notfmore(tlid) {
|
|||
localStorage.setItem('lastnotf_' + acct_id, json[0].id)
|
||||
Object.keys(json).forEach(function(key) {
|
||||
var obj = json[key]
|
||||
if (localStorage.getItem('filter_' + acct_id) != 'undefined') {
|
||||
var mute = getFilterType(
|
||||
JSON.parse(localStorage.getItem('filter_' + acct_id)),
|
||||
'notif'
|
||||
)
|
||||
} else {
|
||||
var mute = []
|
||||
}
|
||||
var mute = getFilterTypeByAcct(acct_id, 'notif')
|
||||
if (obj.type != 'follow') {
|
||||
if (misskey) {
|
||||
templete = templete + misskeyParse([obj], 'notf', acct_id, 'notf', -1, mute)
|
||||
|
|
|
@ -1,280 +1,375 @@
|
|||
//Integrated TL
|
||||
function mixtl(acct_id, tlid) {
|
||||
var type = "mix";
|
||||
localStorage.removeItem("morelock");
|
||||
localStorage.setItem("now", type);
|
||||
todo("Integrated TL Loading...(Local)");
|
||||
var domain = localStorage.getItem("domain_" + acct_id);
|
||||
var at = localStorage.getItem("acct_" + acct_id + "_at");
|
||||
function mixtl(acct_id, tlid, type, delc, voice) {
|
||||
localStorage.removeItem('morelock')
|
||||
localStorage.setItem('now', type)
|
||||
todo('Integrated TL Loading...(Local)')
|
||||
//まずLocal
|
||||
var start = "https://" + domain + "/api/v1/timelines/public?local=true";
|
||||
var domain = localStorage.getItem('domain_' + acct_id)
|
||||
var at = localStorage.getItem('acct_' + acct_id + '_at')
|
||||
var start = 'https://' + domain + '/api/v1/timelines/public?local=true'
|
||||
fetch(start, {
|
||||
method: "GET",
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
Authorization: "Bearer " + at
|
||||
'content-type': 'application/json',
|
||||
Authorization: 'Bearer ' + at
|
||||
}
|
||||
})
|
||||
.then(function(response) {
|
||||
if (!response.ok) {
|
||||
response.text().then(function(text) {
|
||||
setLog(response.url, response.status, text);
|
||||
});
|
||||
setLog(response.url, response.status, text)
|
||||
})
|
||||
}
|
||||
return response.json();
|
||||
return response.json()
|
||||
})
|
||||
.catch(function(error) {
|
||||
todo(error);
|
||||
setLog(start, "JSON", error);
|
||||
console.error(error);
|
||||
todo(error)
|
||||
setLog(start, 'JSON', error)
|
||||
console.error(error)
|
||||
})
|
||||
.then(function(json) {
|
||||
//パースして描画
|
||||
var templete = parse(json, "mix", acct_id, tlid);
|
||||
$("#timeline_" + tlid).html(templete[0]);
|
||||
|
||||
jQuery("time.timeago").timeago();
|
||||
$(window).scrollTop(0);
|
||||
var locals = templete[1];
|
||||
var times = templete[2];
|
||||
todo("Integrated TL Loading...(Home)");
|
||||
//Home
|
||||
var start = "https://" + domain + "/api/v1/timelines/home";
|
||||
.then(function(jsonL) {
|
||||
var start = 'https://' + domain + '/api/v1/timelines/home'
|
||||
fetch(start, {
|
||||
method: "GET",
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
Authorization: "Bearer " + at
|
||||
'content-type': 'application/json',
|
||||
Authorization: 'Bearer ' + at
|
||||
}
|
||||
})
|
||||
.then(function(response) {
|
||||
if (!response.ok) {
|
||||
response.text().then(function(text) {
|
||||
setLog(response.url, response.status, text);
|
||||
});
|
||||
setLog(response.url, response.status, text)
|
||||
})
|
||||
}
|
||||
return response.json();
|
||||
return response.json()
|
||||
})
|
||||
.catch(function(error) {
|
||||
todo(error);
|
||||
setLog(start, "JSON", error);
|
||||
console.error(error);
|
||||
todo(error)
|
||||
setLog(start, 'JSON', error)
|
||||
console.error(error)
|
||||
})
|
||||
.then(function(obj) {
|
||||
//ホームのオブジェクトをUnix時間で走査
|
||||
if (!$("[toot-id=" + obj[0].id + "]").length) {
|
||||
$("#timeline_" + tlid + " .cvo")
|
||||
.first()
|
||||
.before(parse([obj[0]], "home", acct_id));
|
||||
//delete obj[0];
|
||||
.then(function(jsonH) {
|
||||
var homearr = []
|
||||
var timeline = jsonL.concat(jsonH)
|
||||
timeline.sort(function(a, b) {
|
||||
if (date(a.created_at, 'unix') >= date(b.created_at, 'unix')) return -1
|
||||
if (date(a.created_at, 'unix') < date(b.created_at, 'unix')) return 1
|
||||
return 0
|
||||
})
|
||||
if (type == 'integrated') {
|
||||
timeline.splice(20)
|
||||
}
|
||||
//Localが遅すぎてHomeの全てより過去の場合
|
||||
var unixL = date(json[0].created_at, "unix");
|
||||
var unixH = date(obj[obj.length - 1].created_at, "unix");
|
||||
//console.log(unixH+"vs"+unixL)
|
||||
if (unixH < unixL) {
|
||||
Object.keys(obj).forEach(function(key) {
|
||||
var skey = obj.length - key - 1;
|
||||
var toot = obj[key];
|
||||
console.log(toot);
|
||||
var id = toot.id;
|
||||
if ($("#timeline_" + tlid + " [toot-id=" + toot.id + "]").length < 1) {
|
||||
//console.log(toot.id);
|
||||
var tarunix = date(toot.created_at, "unix");
|
||||
var beforekey2;
|
||||
var key2;
|
||||
//console.log(locals)
|
||||
//ホームのオブジェクトに対してLocalのオブジェクトを時間走査
|
||||
Object.keys(times).forEach(function(key2) {
|
||||
if (times[key2] < tarunix) {
|
||||
var local = json[key2].id;
|
||||
//console.log($.strip_tags(toot.content));
|
||||
html = parse([toot], "home", acct_id, tlid);
|
||||
$("#timeline_" + tlid + " [toot-id=" + local + "]").before(html);
|
||||
//console.log("#timeline_" + tlid + " [toot-id=" + local + "]");
|
||||
tarunix = 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
var templete = ''
|
||||
if (localStorage.getItem('filter_' + acct_id) != 'undefined') {
|
||||
var mute = getFilterType(JSON.parse(localStorage.getItem('filter_' + acct_id)), 'mix')
|
||||
} else {
|
||||
html = parse(obj, "home", acct_id, tlid);
|
||||
$("#timeline_" + tlid).html(html);
|
||||
var mute = []
|
||||
}
|
||||
todc();
|
||||
mixre(acct_id, tlid);
|
||||
additional(acct_id, tlid);
|
||||
jQuery("time.timeago").timeago();
|
||||
});
|
||||
});
|
||||
Object.keys(timeline).forEach(function(key) {
|
||||
var pkey = key * 1 + 1
|
||||
if (pkey < timeline.length) {
|
||||
if (
|
||||
date(timeline[key].created_at, 'unix') != date(timeline[pkey].created_at, 'unix')
|
||||
) {
|
||||
if (type == 'integrated') {
|
||||
templete = templete + parse([timeline[key]], '', acct_id, tlid, '', mute, 'mix')
|
||||
} else if (type == 'plus') {
|
||||
if (timeline[key].account.acct == timeline[key].account.username) {
|
||||
templete =
|
||||
templete + parse([timeline[key]], '', acct_id, tlid, '', mute, 'plus')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
$('#landing_' + tlid).hide()
|
||||
$('#timeline_' + tlid).html(templete)
|
||||
mixre(acct_id, tlid, type, mute, delc, voice)
|
||||
additional(acct_id, tlid)
|
||||
jQuery('time.timeago').timeago()
|
||||
todc()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
//Streamingに接続
|
||||
function mixre(acct_id, tlid) {
|
||||
var domain = localStorage.getItem("domain_" + acct_id);
|
||||
var at = localStorage.getItem("acct_" + acct_id + "_at");
|
||||
var type = "mix";
|
||||
localStorage.setItem("now", type);
|
||||
var startHome = "wss://" + domain + "/api/v1/streaming/?stream=user&access_token=" + at;
|
||||
|
||||
var startLocal = "wss://" + domain + "/api/v1/streaming/?stream=public:local&access_token=" + at;
|
||||
var wshid = websocketHome.length;
|
||||
var wslid = websocketLocal.length;
|
||||
websocketHome[wshid] = new WebSocket(startHome);
|
||||
websocketLocal[wslid] = new WebSocket(startLocal);
|
||||
function mixre(acct_id, tlid, TLtype, mute, delc, voice, mode) {
|
||||
var domain = localStorage.getItem('domain_' + acct_id)
|
||||
var at = localStorage.getItem('acct_' + acct_id + '_at')
|
||||
if (localStorage.getItem('streaming_' + acct_id)) {
|
||||
var wss = localStorage.getItem('streaming_' + acct_id)
|
||||
} else {
|
||||
var wss = 'wss://' + domain
|
||||
}
|
||||
var startHome = wss + '/api/v1/streaming/?stream=user&access_token=' + at
|
||||
var startLocal = wss + '/api/v1/streaming/?stream=public:local&access_token=' + at
|
||||
var wshid = websocketHome.length
|
||||
var wslid = websocketLocal.length
|
||||
websocketHome[wshid] = new WebSocket(startHome)
|
||||
websocketLocal[wslid] = new WebSocket(startLocal)
|
||||
websocketHome[wshid].onopen = function(mess) {
|
||||
console.log("Connect Streaming API(Home)");
|
||||
$("#notice_icon_" + tlid).removeClass("red-text");
|
||||
};
|
||||
localStorage.setItem('wssH_' + tlid, wshid)
|
||||
console.table({
|
||||
tlid: tlid,
|
||||
type: 'Connect Streaming API(Integrated:Home)',
|
||||
domain: domain,
|
||||
message: mess
|
||||
})
|
||||
$('#notice_icon_' + tlid).removeClass('red-text')
|
||||
}
|
||||
websocketLocal[wslid].onopen = function(mess) {
|
||||
console.log("Connect Streaming API(Local)");
|
||||
$("#notice_icon_" + tlid).removeClass("red-text");
|
||||
};
|
||||
localStorage.setItem('wssL_' + tlid, wslid)
|
||||
console.table({
|
||||
tlid: tlid,
|
||||
type: 'Connect Streaming API(Integrated:Local)',
|
||||
domain: domain,
|
||||
message: mess
|
||||
})
|
||||
$('#notice_icon_' + tlid).removeClass('red-text')
|
||||
}
|
||||
websocketLocal[wslid].onmessage = function(mess) {
|
||||
console.log("Receive Streaming API:");
|
||||
console.log(['Receive Streaming API:(Integrated:Local)', obj])
|
||||
|
||||
var obj = JSON.parse(JSON.parse(mess.data).payload);
|
||||
console.log(obj);
|
||||
var type = JSON.parse(mess.data).event;
|
||||
if (type == "delete") {
|
||||
$("[toot-id=" + JSON.parse(mess.data).payload + "]").hide();
|
||||
$("[toot-id=" + JSON.parse(mess.data).payload + "]").remove();
|
||||
} else if (type == "update") {
|
||||
var templete = parse([obj], "", acct_id, tlid);
|
||||
var pool = localStorage.getItem("pool_" + tlid);
|
||||
if (pool) {
|
||||
pool = templete + pool;
|
||||
var obj = JSON.parse(JSON.parse(mess.data).payload)
|
||||
var type = JSON.parse(mess.data).event
|
||||
if (type == 'delete') {
|
||||
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 {
|
||||
pool = templete;
|
||||
$('[toot-id=' + JSON.parse(mess.data).payload + ']').hide()
|
||||
$('[toot-id=' + JSON.parse(mess.data).payload + ']').remove()
|
||||
}
|
||||
} else if (type == 'update') {
|
||||
var templete = parse([obj], '', acct_id, tlid, '', mute)
|
||||
if ($('#timeline_' + tlid + ' [toot-id=' + obj.id + ']').length < 1) {
|
||||
if (voice) {
|
||||
say(obj.content)
|
||||
}
|
||||
var templete = parse([obj], type, acct_id, tlid, '', mute, 'mix')
|
||||
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('二重取得発生中')
|
||||
}
|
||||
}
|
||||
localStorage.setItem("pool_" + tlid, pool);
|
||||
scrollck();
|
||||
additional(acct_id, tlid);
|
||||
jQuery("time.timeago").timeago();
|
||||
todc();
|
||||
}
|
||||
};
|
||||
websocketHome[wshid].onmessage = function(mess) {
|
||||
console.log("Receive Streaming API:(Home)");
|
||||
|
||||
var obj = JSON.parse(JSON.parse(mess.data).payload);
|
||||
console.log(obj);
|
||||
var type = JSON.parse(mess.data).event;
|
||||
if (type == "delete") {
|
||||
$("[toot-id=" + JSON.parse(mess.data).payload + "]").hide();
|
||||
$("[toot-id=" + JSON.parse(mess.data).payload + "]").remove();
|
||||
} else if (type == "update") {
|
||||
var templete = parse([obj], "", acct_id, tlid);
|
||||
if (obj.visibility != "public" || obj.account.acct != obj.account.username) {
|
||||
var pool = localStorage.getItem("pool_" + tlid);
|
||||
if (pool) {
|
||||
pool = templete + pool;
|
||||
console.log(['Receive Streaming API:(Integrated:Home)', obj])
|
||||
var obj = JSON.parse(JSON.parse(mess.data).payload)
|
||||
var type = JSON.parse(mess.data).event
|
||||
if (type == 'delete') {
|
||||
if (del > 10) {
|
||||
reconnector(tlid, type, acct_id, data)
|
||||
} else {
|
||||
pool = templete;
|
||||
localStorage.setItem('delete', del * 1 + 1)
|
||||
}
|
||||
if (delc == 'true') {
|
||||
$('[toot-id=' + JSON.parse(mess.data).payload + ']').addClass('emphasized')
|
||||
$('[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 (type == 'update') {
|
||||
localStorage.removeItem('delete')
|
||||
if (TLtype == 'integrated') {
|
||||
var templete = parse([obj], '', acct_id, tlid)
|
||||
} else if (TLtype == 'plus') {
|
||||
if (obj.account.acct == obj.account.username) {
|
||||
var templete = parse([obj], '', acct_id, tlid, '', mute, 'mix')
|
||||
} else {
|
||||
var templete = ''
|
||||
}
|
||||
}
|
||||
if ($('#timeline_' + tlid + ' [toot-id=' + obj.id + ']').length < 1) {
|
||||
if (voice) {
|
||||
say(obj.content)
|
||||
}
|
||||
var templete = parse([obj], type, acct_id, tlid, '', mute, 'mix')
|
||||
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('二重取得発生中')
|
||||
}
|
||||
localStorage.setItem("pool_" + tlid, pool);
|
||||
scrollck();
|
||||
additional(acct_id, tlid);
|
||||
jQuery("time.timeago").timeago();
|
||||
}
|
||||
}
|
||||
};
|
||||
websocketLocal[wslid].onerror = function(error) {
|
||||
console.error("WebSocket Error " + error);
|
||||
};
|
||||
console.error('WebSocketLocal Error')
|
||||
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, TLtype, acct_id, '', 'error')
|
||||
}
|
||||
}
|
||||
}
|
||||
websocketLocal[wslid].onclose = function() {
|
||||
console.warn('WebSocketLocal Closing:' + 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, TLtype, acct_id, '', 'error')
|
||||
}
|
||||
}
|
||||
}
|
||||
websocketHome[wshid].onerror = function(error) {
|
||||
console.error("WebSocket Error " + error);
|
||||
};
|
||||
console.error(['WebSocketHome 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, TLtype, acct_id, '', 'error')
|
||||
}
|
||||
}
|
||||
}
|
||||
websocketHome[wshid].onclose = function() {
|
||||
console.warn('WebSocketHome Closing:' + 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, TLtype, acct_id, '', 'error')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//ある程度のスクロールで発火
|
||||
function mixmore(tlid) {
|
||||
var multi = localStorage.getItem("column");
|
||||
var obj = JSON.parse(multi);
|
||||
var acct_id = obj[tlid].domain;
|
||||
todo("Integrated TL MoreLoading...(Local)");
|
||||
var domain = localStorage.getItem("domain_" + acct_id);
|
||||
var at = localStorage.getItem("acct_" + acct_id + "_at");
|
||||
var sid = $("#timeline_" + tlid + " .cvo")
|
||||
function mixmore(tlid, type) {
|
||||
var multi = localStorage.getItem('column')
|
||||
var obj = JSON.parse(multi)
|
||||
var acct_id = obj[tlid].domain
|
||||
moreloading = true
|
||||
todo('Integrated TL MoreLoading...(Local)')
|
||||
var domain = localStorage.getItem('domain_' + acct_id)
|
||||
var at = localStorage.getItem('acct_' + acct_id + '_at')
|
||||
var sid = $('#timeline_' + tlid + ' .cvo')
|
||||
.last()
|
||||
.attr("toot-id");
|
||||
var len = $("#timeline_" + tlid + " .cvo").length;
|
||||
var start = "https://" + domain + "/api/v1/timelines/public?local=true&max_id=" + sid;
|
||||
console.log(start);
|
||||
.attr('unique-id')
|
||||
|
||||
var start = 'https://' + domain + '/api/v1/timelines/public?local=true&max_id=' + sid
|
||||
fetch(start, {
|
||||
method: "GET",
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
Authorization: "Bearer " + at
|
||||
'content-type': 'application/json',
|
||||
Authorization: 'Bearer ' + at
|
||||
}
|
||||
})
|
||||
.then(function(response) {
|
||||
if (!response.ok) {
|
||||
response.text().then(function(text) {
|
||||
setLog(response.url, response.status, text);
|
||||
});
|
||||
setLog(response.url, response.status, text)
|
||||
})
|
||||
}
|
||||
return response.json();
|
||||
return response.json()
|
||||
})
|
||||
.catch(function(error) {
|
||||
todo(error);
|
||||
setLog(start, "JSON", error);
|
||||
console.error(error);
|
||||
todo(error)
|
||||
setLog(start, 'JSON', error)
|
||||
console.error(error)
|
||||
})
|
||||
.then(function(json) {
|
||||
var templete = parse(json, "mix", acct_id, tlid);
|
||||
$("#timeline_" + tlid).append(templete[0]);
|
||||
var locals = templete[1];
|
||||
todo("Integrated TL MoreLoading...(Home)");
|
||||
console.log(sid);
|
||||
var start = "https://" + domain + "/api/v1/timelines/home?max_id=" + sid;
|
||||
.then(function(jsonL) {
|
||||
var start = 'https://' + domain + '/api/v1/timelines/home?max_id=' + sid
|
||||
fetch(start, {
|
||||
method: "GET",
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
Authorization: "Bearer " + at
|
||||
'content-type': 'application/json',
|
||||
Authorization: 'Bearer ' + at
|
||||
}
|
||||
})
|
||||
.then(function(response) {
|
||||
if (!response.ok) {
|
||||
response.text().then(function(text) {
|
||||
setLog(response.url, response.status, text);
|
||||
});
|
||||
setLog(response.url, response.status, text)
|
||||
})
|
||||
}
|
||||
return response.json();
|
||||
return response.json()
|
||||
})
|
||||
.catch(function(error) {
|
||||
todo(error);
|
||||
setLog(start, "JSON", error);
|
||||
console.error(error);
|
||||
todo(error)
|
||||
setLog(start, 'JSON', error)
|
||||
console.error(error)
|
||||
})
|
||||
.then(function(obj) {
|
||||
if ($("[toot-id=" + obj[0].id + "]").length < 1) {
|
||||
$("#timeline_" + tlid + " .cvo")
|
||||
.eq(len)
|
||||
.before(parse([obj[0]], "home", acct_id) + '<div class="divider"></div>');
|
||||
//delete obj[0];
|
||||
.then(function(jsonH) {
|
||||
var homearr = []
|
||||
var timeline = jsonL.concat(jsonH)
|
||||
timeline.sort(function(a, b) {
|
||||
if (date(a.created_at, 'unix') > date(b.created_at, 'unix')) return -1
|
||||
if (date(a.created_at, 'unix') < date(b.created_at, 'unix')) return 1
|
||||
return 0
|
||||
})
|
||||
timeline.splice(20)
|
||||
var templete = ''
|
||||
Object.keys(timeline).forEach(function(key) {
|
||||
var pkey = key * 1 + 1
|
||||
if (pkey < 20) {
|
||||
if (
|
||||
date(timeline[key].created_at, 'unix') != date(timeline[pkey].created_at, 'unix')
|
||||
) {
|
||||
if (localStorage.getItem('filter_' + acct_id) != 'undefined') {
|
||||
var mute = getFilterType(
|
||||
JSON.parse(localStorage.getItem('filter_' + acct_id)),
|
||||
'mix'
|
||||
)
|
||||
} else {
|
||||
var mute = []
|
||||
}
|
||||
Object.keys(obj).forEach(function(key) {
|
||||
var skey = obj.length - key - 1;
|
||||
var toot = obj[skey];
|
||||
var id = toot.id;
|
||||
var tarunix = date(toot.created_at, "unix");
|
||||
var beforekey2;
|
||||
var key2;
|
||||
Object.keys(locals).forEach(function(key2) {
|
||||
if ($("[toot-id=" + toot.id + "]").length < 1) {
|
||||
if (key2 > tarunix) {
|
||||
var local = locals[key2];
|
||||
$("#timeline_" + tlid + " [toot-id=" + local + "]").after(parse([toot], "home", acct_id, tlid));
|
||||
tarunix = 2147483647;
|
||||
if (type == 'integrated') {
|
||||
templete = templete + parse([timeline[key]], '', acct_id, tlid, '', mute, 'mix')
|
||||
} else if (type == 'plus') {
|
||||
if (timeline[key].account.acct == timeline[key].account.username) {
|
||||
templete = templete + parse([timeline[key]], '', acct_id, tlid, '', mute, 'mix')
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
additional(acct_id, tlid);
|
||||
jQuery("time.timeago").timeago();
|
||||
todc();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
$('#timeline_' + tlid).append(templete)
|
||||
additional(acct_id, tlid)
|
||||
jQuery('time.timeago').timeago()
|
||||
moreloading = false
|
||||
todc()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ var errorct = 0
|
|||
function tl(type, data, acct_id, tlid, delc, voice, mode) {
|
||||
scrollevent()
|
||||
$('#unread_' + tlid + ' .material-icons').removeClass('teal-text')
|
||||
localStorage.removeItem('morelock')
|
||||
localStorage.removeItem('pool')
|
||||
var domain = localStorage.getItem('domain_' + acct_id)
|
||||
//タグとかの場合はカラム追加して描画
|
||||
|
@ -148,11 +147,7 @@ function tl(type, data, acct_id, tlid, delc, voice, mode) {
|
|||
.then(function(json) {
|
||||
console.log(['Result of getting timeline of ' + tlid, 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 = []
|
||||
}
|
||||
var mute = getFilterTypeByAcct(acct_id, type)
|
||||
if (misskey) {
|
||||
var templete = misskeyParse(json, type, acct_id, tlid, '', mute)
|
||||
} else {
|
||||
|
@ -471,11 +466,7 @@ function moreload(type, tlid) {
|
|||
console.error(error)
|
||||
})
|
||||
.then(function(json) {
|
||||
if (localStorage.getItem('filter_' + acct_id) != 'undefined') {
|
||||
var mute = getFilterType(JSON.parse(localStorage.getItem('filter_' + acct_id)), type)
|
||||
} else {
|
||||
var mute = []
|
||||
}
|
||||
var mute = getFilterTypeByAcct(acct_id, type)
|
||||
if (misskey) {
|
||||
var templete = misskeyParse(json, '', acct_id, tlid, '', mute)
|
||||
} else {
|
||||
|
@ -631,20 +622,20 @@ function tlCloser() {
|
|||
}
|
||||
})
|
||||
websocket = []
|
||||
Object.keys(websocketHome).forEach(function(tlid) {
|
||||
if (websocketHome[tlid]) {
|
||||
websocketHome[tlid].close()
|
||||
Object.keys(wsHome).forEach(function(tlid) {
|
||||
if (wsHome[tlid]) {
|
||||
wsHome[tlid].close()
|
||||
console.log('%c Close Streaming API:Integrated Home' + tlid, 'color:blue')
|
||||
}
|
||||
})
|
||||
websocketHome = []
|
||||
Object.keys(websocketLocal).forEach(function(tlid) {
|
||||
if (websocketLocal[tlid]) {
|
||||
websocketLocal[tlid].close()
|
||||
wsHome = []
|
||||
Object.keys(wsLocal).forEach(function(tlid) {
|
||||
if (wsLocal[tlid]) {
|
||||
wsLocal[tlid].close()
|
||||
console.log('%c Close Streaming API:Integrated Local' + tlid, 'color:blue')
|
||||
}
|
||||
})
|
||||
websocketLocal = []
|
||||
wsLocal = []
|
||||
Object.keys(websocketNotf).forEach(function(tlid) {
|
||||
if (websocketNotf[tlid]) {
|
||||
websocketNotf[tlid].close()
|
||||
|
@ -849,15 +840,11 @@ function reconnector(tlid, type, acct_id, data, mode) {
|
|||
} 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 = []
|
||||
}
|
||||
var mute = getFilterTypeByAcct(acct_id, type)
|
||||
var wssh = localStorage.getItem('wssH_' + tlid)
|
||||
websocketHome[wssh].close()
|
||||
wsHome[wssh].close()
|
||||
var wssl = localStorage.getItem('wssL_' + tlid)
|
||||
websocketLocal[wssl].close()
|
||||
wsLocal[wssl].close()
|
||||
mixre(acct_id, tlid, type, mute, '', voice, mode)
|
||||
} else if (type == 'notf') {
|
||||
notfColumn(acct_id, tlid, '')
|
||||
|
@ -869,11 +856,7 @@ function reconnector(tlid, type, acct_id, data, mode) {
|
|||
} 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 = []
|
||||
}
|
||||
var mute = getFilterTypeByAcct(acct_id, type)
|
||||
reload(type, '', acct_id, tlid, data, mute, '', voice, mode)
|
||||
}
|
||||
M.toast({ html: lang.lang_tl_reconnect, displayLength: 2000 })
|
||||
|
@ -887,11 +870,7 @@ function columnReload(tlid, type) {
|
|||
} 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 = []
|
||||
}
|
||||
var mute = getFilterTypeByAcct(acct_id, type)
|
||||
var wssh = localStorage.getItem('wssH_' + tlid)
|
||||
websocketHome[wssh].close()
|
||||
var wssl = localStorage.getItem('wssL_' + tlid)
|
||||
|
@ -908,11 +887,7 @@ function columnReload(tlid, type) {
|
|||
} 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 = []
|
||||
}
|
||||
var mute = getFilterTypeByAcct(acct_id, type)
|
||||
parseColumn(tlid)
|
||||
}
|
||||
}
|
||||
|
@ -1005,11 +980,7 @@ function showUnread(tlid, type, acct_id) {
|
|||
if (!json || !json.length) {
|
||||
columnReload(tlid, type)
|
||||
}
|
||||
if (localStorage.getItem('filter_' + acct_id) != 'undefined') {
|
||||
var mute = getFilterType(JSON.parse(localStorage.getItem('filter_' + acct_id)), type)
|
||||
} else {
|
||||
var mute = []
|
||||
}
|
||||
var mute = getFilterTypeByAcct(acct_id, type)
|
||||
var templete = parse(json, type, acct_id, tlid, '', mute, type)
|
||||
var len = json.length - 1
|
||||
$('#timeline_' + tlid).html(templete)
|
||||
|
@ -1065,11 +1036,7 @@ function ueload(tlid) {
|
|||
if (!json) {
|
||||
columnReload(tlid, type)
|
||||
}
|
||||
if (localStorage.getItem('filter_' + acct_id) != 'undefined') {
|
||||
var mute = getFilterType(JSON.parse(localStorage.getItem('filter_' + acct_id)), type)
|
||||
} else {
|
||||
var mute = []
|
||||
}
|
||||
var mute = getFilterTypeByAcct(acct_id, type)
|
||||
var templete = parse(json, '', acct_id, tlid, '', mute, type)
|
||||
var len = json.length - 1
|
||||
$('#timeline_' + tlid).prepend(templete)
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
var websocketOld = []
|
||||
var websocket = []
|
||||
var websocketHome = []
|
||||
var websocketLocal = []
|
||||
var wsHome = []
|
||||
var wsLocal = []
|
||||
var websocketNotf = []
|
||||
|
||||
//カラム追加ボックストグル
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
"jquery": "^3.4.1",
|
||||
"jquery-ui-dist": "^1.12.1",
|
||||
"json5": "^2.1.1",
|
||||
"lodash": "^4.17.15",
|
||||
"materialize-css": "^1.0.0",
|
||||
"sumchecker": "^3.0.0",
|
||||
"sweetalert2": "^8.18.6",
|
||||
|
|
|
@ -1189,6 +1189,7 @@
|
|||
<script type="text/javascript" src="../../node_modules/jquery/dist/jquery.js"></script>
|
||||
<script type="text/javascript" src="../../js/platform/first.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/materialize-css/dist/js/materialize.js"></script>
|
||||
<script type="text/javascript" src="../../node_modules/lodash/lodash.min.js"></script>
|
||||
<script type="text/javascript" src="main.js"></script>
|
||||
<script type="text/javascript" src="../../js/common/time.js"></script>
|
||||
<script type="text/javascript" src="../../js/common/blurhash.js"></script>
|
||||
|
|
|
@ -1730,6 +1730,11 @@ lodash.assign@^4.2.0:
|
|||
resolved "https://registry.yarnpkg.com/lodash.assign/-/lodash.assign-4.2.0.tgz#0d99f3ccd7a6d261d19bdaeb9245005d285808e7"
|
||||
integrity sha1-DZnzzNem0mHRm9rrkkUAXShYCOc=
|
||||
|
||||
lodash@^4.17.15:
|
||||
version "4.17.15"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
|
||||
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
|
||||
|
||||
log-symbols@^2.2.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-2.2.0.tgz#5740e1c5d6f0dfda4ad9323b5332107ef6b4c40a"
|
||||
|
|
Loading…
Reference in New Issue
Block a user