streaming disconnect warrior
This commit is contained in:
parent
3020adbe9d
commit
38c77fb39e
|
@ -1572,12 +1572,15 @@ function mastodonBaseStreaming(acct_id) {
|
||||||
const start = `wss://${domain}/api/v1/streaming/?access_token=${at}`
|
const start = `wss://${domain}/api/v1/streaming/?access_token=${at}`
|
||||||
mastodonBaseWs[domain] = new WebSocket(start)
|
mastodonBaseWs[domain] = new WebSocket(start)
|
||||||
mastodonBaseWs[domain].onopen = function () {
|
mastodonBaseWs[domain].onopen = function () {
|
||||||
mastodonBaseWsStatus[domain] = 'available'
|
setTimeout(function () {
|
||||||
|
mastodonBaseWsStatus[domain] = 'available'
|
||||||
|
}, 1000)
|
||||||
mastodonBaseWs[domain].send(`{"type":"subscribe","stream":"user"}`)
|
mastodonBaseWs[domain].send(`{"type":"subscribe","stream":"user"}`)
|
||||||
$('.notice_icon_acct_' + acct_id).removeClass('red-text')
|
$('.notice_icon_acct_' + acct_id).removeClass('red-text')
|
||||||
}
|
}
|
||||||
mastodonBaseWs[domain].onmessage = function (mess) {
|
mastodonBaseWs[domain].onmessage = function (mess) {
|
||||||
const typeA = JSON.parse(mess.data).event
|
const typeA = JSON.parse(mess.data).event
|
||||||
|
console.log(domain + ':' + typeA)
|
||||||
if (typeA == 'delete') {
|
if (typeA == 'delete') {
|
||||||
$(`[unique-id=${JSON.parse(mess.data).payload}]`).hide()
|
$(`[unique-id=${JSON.parse(mess.data).payload}]`).hide()
|
||||||
$(`[unique-id=${JSON.parse(mess.data).payload}]`).remove()
|
$(`[unique-id=${JSON.parse(mess.data).payload}]`).remove()
|
||||||
|
@ -1586,6 +1589,7 @@ function mastodonBaseStreaming(acct_id) {
|
||||||
const tl = JSON.parse(mess.data).stream
|
const tl = JSON.parse(mess.data).stream
|
||||||
const obj = JSON.parse(JSON.parse(mess.data).payload)
|
const obj = JSON.parse(JSON.parse(mess.data).payload)
|
||||||
const tls = getTlMeta(tl[0], tl, acct_id, obj)
|
const tls = getTlMeta(tl[0], tl, acct_id, obj)
|
||||||
|
console.log(domain + ':' + tls)
|
||||||
insertTl(obj, tls)
|
insertTl(obj, tls)
|
||||||
} else if (typeA == 'filters_changed') {
|
} else if (typeA == 'filters_changed') {
|
||||||
filterUpdate(acct_id)
|
filterUpdate(acct_id)
|
||||||
|
@ -1619,13 +1623,17 @@ function mastodonBaseStreaming(acct_id) {
|
||||||
notf(acct_id, 0) //fallback
|
notf(acct_id, 0) //fallback
|
||||||
console.error("Error closing " + domain)
|
console.error("Error closing " + domain)
|
||||||
console.error(error)
|
console.error(error)
|
||||||
mastodonBaseWsStatus[domain] = 'cannotuse'
|
if (mastodonBaseWsStatus[domain] == 'available') location.reload()
|
||||||
|
setTimeout(function () {
|
||||||
|
mastodonBaseWsStatus[domain] = 'cannotuse'
|
||||||
|
}, 2000)
|
||||||
mastodonBaseWs[domain] = false
|
mastodonBaseWs[domain] = false
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
mastodonBaseWs[domain].onclose = function () {
|
mastodonBaseWs[domain].onclose = function () {
|
||||||
notf(acct_id, 0) //fallback
|
notf(acct_id, 0) //fallback
|
||||||
console.warn("Closing " + domain)
|
console.warn("Closing " + domain)
|
||||||
|
if (mastodonBaseWsStatus[domain] == 'available') location.reload()
|
||||||
mastodonBaseWs[domain] = false
|
mastodonBaseWs[domain] = false
|
||||||
mastodonBaseWsStatus[domain] = 'cannotuse'
|
mastodonBaseWsStatus[domain] = 'cannotuse'
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -248,11 +248,11 @@ function reload(type, cc, acct_id, tlid, data, mute, delc, voice, mode) {
|
||||||
}, 100)
|
}, 100)
|
||||||
} else {
|
} else {
|
||||||
var domain = localStorage.getItem('domain_' + acct_id)
|
var domain = localStorage.getItem('domain_' + acct_id)
|
||||||
if(mastodonBaseWsStatus[domain] == 'cannnotopen') {
|
if(mastodonBaseWsStatus[domain] == 'cannotuse') {
|
||||||
oldStreaming(type, cc, acct_id, tlid, data, mute, delc, voice, mode)
|
oldStreaming(type, cc, acct_id, tlid, data, mute, delc, voice, mode)
|
||||||
} else if(mastodonBaseWs[domain] == 'undetected') {
|
} else if(mastodonBaseWs[domain] == 'undetected') {
|
||||||
const mbws = setInterval(function () {
|
const mbws = setInterval(function () {
|
||||||
if(mastodonBaseWsStatus[domain] == 'cannnotopen') {
|
if(mastodonBaseWsStatus[domain] == 'cannotuse') {
|
||||||
oldStreaming(type, cc, acct_id, tlid, data, mute, delc, voice, mode)
|
oldStreaming(type, cc, acct_id, tlid, data, mute, delc, voice, mode)
|
||||||
clearInterval(mbws)
|
clearInterval(mbws)
|
||||||
} else if(mastodonBaseWsStatus[domain] == 'available') {
|
} else if(mastodonBaseWsStatus[domain] == 'available') {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user