From fe32723ad57b3ebfb459add5a94b11f8bcc455a0 Mon Sep 17 00:00:00 2001 From: cutls Date: Sat, 16 Nov 2019 21:29:11 +0900 Subject: [PATCH] Fix: moreLoading --- app/js/tl/mix.js | 2 +- app/js/ui/scroll.js | 68 +++++++++++++++++++++++++-------------------- 2 files changed, 39 insertions(+), 31 deletions(-) diff --git a/app/js/tl/mix.js b/app/js/tl/mix.js index 419d2fb1..649f775a 100644 --- a/app/js/tl/mix.js +++ b/app/js/tl/mix.js @@ -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') diff --git a/app/js/ui/scroll.js b/app/js/ui/scroll.js index 910a46ea..9a309e86 100644 --- a/app/js/ui/scroll.js +++ b/app/js/ui/scroll.js @@ -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 + }) } -} \ No newline at end of file +}