Fix: moreLoading

This commit is contained in:
cutls 2019-11-16 21:29:11 +09:00
parent b9d562d8f0
commit fe32723ad5
2 changed files with 39 additions and 31 deletions

View File

@ -183,7 +183,7 @@ async function mixmore(tlid, type) {
.attr('unique-id')
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 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')

View File

@ -1,62 +1,70 @@
//スクロールで続きを読む
function scrollevent() {
$(".tl-box").scroll(function () {
scrollck();
});
$('.tl-box').scroll(function() {
scrollck()
})
}
scrollevent();
scrollevent()
function scrollck() {
$(".tl-box").each(function (i, elem) {
var tlid = $(this).attr('tlid');
$('.tl-box').each(function(i, elem) {
var tlid = $(this).attr('tlid')
var len = $('#timeline_' + tlid + ' .cvo').length
//一番上ならためていた新しいトゥートを表示ないしtealなら未読管理モード
if ($(this).scrollTop() === 0) {
if (!$("#unread_" + tlid + " .material-icons").hasClass("teal-text")) {
var pool = localStorage.getItem("pool_" + tlid);
if (!$('#unread_' + tlid + ' .material-icons').hasClass('teal-text')) {
var pool = localStorage.getItem('pool_' + tlid)
if (pool) {
$("#timeline_" + tlid).prepend(pool);
jQuery("time.timeago").timeago();
localStorage.removeItem("pool_" + tlid);
$('#timeline_' + tlid).prepend(pool)
jQuery('time.timeago').timeago()
localStorage.removeItem('pool_' + tlid)
}
} else {
ueload(tlid)
}
//自動リフレッシュ
if ($("#timeline_" + tlid + " .cvo").length > 30) {
for (var i = 30; i < $("#timeline_" + tlid + " .cvo").length; i++) {
$("#timeline_" + tlid + " .cvo").eq(i).remove();
if (len > 30) {
for (var i = 30; i < $('#timeline_' + tlid + ' .cvo').length; i++) {
$('#timeline_' + tlid + ' .cvo')
.eq(i)
.remove()
}
}
}
//続きを読むトリガー
var scrt = $(this).find(".tl").height() - $(window).height();
var scr = $(this).scrollTop();
if (scr > scrt) {
console.log("kicked more loading:" + tlid);
moreload('', tlid);
var scrt =
$(this)
.find('.tl')
.height() - $(window).height()
var scr = $(this).scrollTop()
if (scr > scrt && scrt > 0) {
console.log('kicked more loading:' + tlid)
moreload('', tlid)
}
});
})
}
function goTop(id) {
if ($("#unread_" + id + " .material-icons").hasClass("teal-text")) {
$("#unread_" + id + " .material-icons").removeClass("teal-text")
var multi = localStorage.getItem("column")
if ($('#unread_' + id + ' .material-icons').hasClass('teal-text')) {
$('#unread_' + id + ' .material-icons').removeClass('teal-text')
var multi = localStorage.getItem('column')
var obj = JSON.parse(multi)
var acct_id = obj[id * 1].domain
var type = obj[id * 1].type
console.log(id, type)
columnReload(id, type)
}
if ($("#timeline_box_" + id + "_box .tl-box").scrollTop() > 500) {
$("#timeline_box_" + id + "_box .tl-box").scrollTop(500)
if ($('#timeline_box_' + id + '_box .tl-box').scrollTop() > 500) {
$('#timeline_box_' + id + '_box .tl-box').scrollTop(500)
}
$("#timeline_box_" + id + "_box .tl-box").animate({ scrollTop: 0 });
$('#timeline_box_' + id + '_box .tl-box').animate({ scrollTop: 0 })
}
function goColumn(key) {
$("#sort-box").addClass("hide");
$("#sort-box").removeClass("show");
$('#sort-box').addClass('hide')
$('#sort-box').removeClass('show')
if ($('[tlid=' + key + ']').length) {
$("#timeline-container").animate({ scrollLeft: $("#timeline-container").scrollLeft() + $('[tlid=' + key + ']').offset().left });
$('#timeline-container').animate({
scrollLeft: $('#timeline-container').scrollLeft() + $('[tlid=' + key + ']').offset().left
})
}
}
}