diff --git a/app/css/tl.css b/app/css/tl.css index 736db6a4..b7841626 100644 --- a/app/css/tl.css +++ b/app/css/tl.css @@ -446,6 +446,7 @@ iframe, } .contextMenu .btn-flat { text-transform: none !important; + width: 100%; } .gray { diff --git a/app/js/post/status.js b/app/js/post/status.js index fb63d9fb..fa0b45ab 100644 --- a/app/js/post/status.js +++ b/app/js/post/status.js @@ -116,7 +116,7 @@ function boostWith(vis) { rt(id, acct_id, false, vis) } //ブックマーク -function bkm(id, acct_id, remote) { +function bkm(id, acct_id, tlid) { if ($('#pub_' + id).hasClass('bkmed')) { var flag = 'unbookmark' } else { @@ -140,8 +140,7 @@ function bkm(id, acct_id, remote) { if (json.reblog) { json = json.reblog } - if (remote != 'remote') { - var fav = json.favourites_count + var fav = json.favourites_count $('[toot-id=' + id + '] .fav_ct').text(fav) $('[toot-id=' + id + '] .rt_ct').text(json.reblogs_count) if (flag == 'unbookmark') { @@ -153,9 +152,8 @@ function bkm(id, acct_id, remote) { $('.bkm_' + id).addClass('red-text') $('[toot-id=' + id + ']').addClass('bkmed') } - } else { - M.toast({ html: lang.lang_status_favWarn, displayLength: 1000 }) - } + var tlidTar = $(`.bookmark-timeline[data-acct=${acct_id}]`).attr('tlid') + columnReload(tlidTar,'bookmark') } } } diff --git a/app/js/tl/parse.js b/app/js/tl/parse.js index f5932ac1..35b06b5e 100644 --- a/app/js/tl/parse.js +++ b/app/js/tl/parse.js @@ -948,7 +948,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) { ` } //menuは何個? - var menuct = 1 + var menuct = 2 if (viashow != 'hide') { menuct++ } @@ -1106,6 +1106,13 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) { ${trans} +
` diff --git a/app/js/tl/tl.js b/app/js/tl/tl.js index 642c5530..563ef182 100644 --- a/app/js/tl/tl.js +++ b/app/js/tl/tl.js @@ -56,14 +56,15 @@ function tl(type, data, acct_id, tlid, delc, voice, mode) { ) $('#notice_icon_' + tlid).text('notifications') return - } /*else if (type == "dm") { - //DMなら飛ばす - dm(acct_id, tlid, "plus",delc,voice); - $("#notice_" + tlid).text(cap(type, data, acct_id) + "(" + localStorage.getItem( - "user_" + acct_id) + "@" + domain + ")"); - $("#notice_icon_" + tlid).text("mail_outline"); - return; - }*/ + } else if (type == 'bookmark') { + //ブックマークなら飛ばす + getBookmark(acct_id, tlid) + $('#notice_' + tlid).text( + cap(type, data, acct_id) + '(' + localStorage.getItem('user_' + acct_id) + '@' + domain + ')' + ) + $('#notice_icon_' + tlid).text('bookmark') + return + } localStorage.setItem('now', type) todo(cap(type) + ' TL Loading...') var at = localStorage.getItem('acct_' + acct_id + '_at') @@ -387,6 +388,9 @@ function moreload(type, tlid) { var data = obj[tlid].data moreTs(tlid, data) return + } else if (type == 'bookmark') { + getBookmark(acct_id, tlid, true) + return } moreloading = true localStorage.setItem('now', type) @@ -708,6 +712,8 @@ function cap(type, data, acct_id) { var response = 'Twitter' } else if (type == 'tootsearch') { var response = 'tootsearch(' + escapeHTML(data) + ')' + } else if (type == 'bookmark') { + var response = 'Bookmarks' } return response } @@ -730,6 +736,8 @@ function com(type, data) { return 'list/' + data + '?' } else if (type == 'dm') { return 'direct?' + } else if (type == 'bookmark') { + return 'bookmarks?' } } //Misskey @@ -800,6 +808,8 @@ function icon(type) { var response = 'language' } else if (type == 'tootsearch') { var response = 'search' + } else if (type == 'bookmark') { + var response = 'bookmark' } return response } @@ -835,6 +845,9 @@ function reconnector(tlid, type, acct_id, data, mode) { function columnReload(tlid, type) { $('#notice_icon_' + tlid).addClass('red-text') $('#unread_' + tlid + ' .material-icons').removeClass('teal-text') + var multi = localStorage.getItem('column') + var obj = JSON.parse(multi) + var acct_id = obj[tlid].domain if (type == 'mix' || type == 'integrated' || type == 'plus') { if (localStorage.getItem('voice_' + tlid)) { var voice = true @@ -850,6 +863,9 @@ function columnReload(tlid, type) { } else if (type == 'notf') { $('#notice_icon_' + tlid).removeClass('red-text') notfColumn(acct_id, tlid, '') + } else if (type == 'bookmark') { + $('#notice_icon_' + tlid).removeClass('red-text') + getBookmark(acct_id, tlid, false) } else { var wss = localStorage.getItem('wss_' + tlid) websocket[wss].close() @@ -1102,3 +1118,52 @@ function asReadEnd() { postMessage(['asReadComp', ''], '*') } } +//ブックマーク +function getBookmark(acct_id, tlid, more) { + moreloading = true + console.log(acct_id, tlid, more) + if (more) { + var sid = $('#timeline_' + tlid + ' .notif-marker') + .last() + .attr('data-maxid') + var ad = '?max_id=' + sid + } else { + var ad = '' + } + var at = localStorage.getItem('acct_' + acct_id + '_at') + var domain = localStorage.getItem('domain_' + acct_id) + var start = 'https://' + domain + '/api/v1/bookmarks' + ad + var httpreq = new XMLHttpRequest() + httpreq.open('GET', start, true) + httpreq.setRequestHeader('Content-Type', 'application/json') + httpreq.setRequestHeader('Authorization', 'Bearer ' + at) + httpreq.responseType = 'json' + httpreq.send() + httpreq.onreadystatechange = function() { + if (httpreq.readyState === 4) { + var json = httpreq.response + if (this.status !== 200) { + setLog(start, this.status, this.response) + } + var max_ids = httpreq.getResponseHeader('link') + var max_id = 0 + if (max_ids) { + max_ids = max_ids.match(/[?&]{1}max_id=([0-9]+)/) + if (max_ids) { + max_id = max_ids[1] + } + } + var templete = parse(json, 'bookmark', acct_id, tlid, -1, null) + templete = templete + '' + if (more) { + $('#timeline_' + tlid).append(templete) + } else { + $('#timeline_' + tlid).html(templete) + } + $('#landing_' + tlid).hide() + jQuery('time.timeago').timeago() + moreloading = false + todc() + } + } +} diff --git a/app/js/ui/layout.js b/app/js/ui/layout.js index 0bab310f..4af4020d 100644 --- a/app/js/ui/layout.js +++ b/app/js/ui/layout.js @@ -202,7 +202,29 @@ function parseColumn(target, dontclose) { animecss, acct.data ) - } else { + } else if (acct.type == 'bookmark') { + if (!acct.left_fold) { + basekey = key + } + + var anime = localStorage.getItem('animation') + if (anime == 'yes' || !anime) { + var animecss = 'box-anime' + } else { + var animecss = '' + } + unstreamingTL( + acct.type, + key, + basekey, + insert, + icnsert, + acct.left_fold, + css, + animecss, + acct.domain + ) + }else { var anime = localStorage.getItem('animation') if (anime == 'yes' || !anime) { var animecss = 'box-anime' @@ -728,105 +750,73 @@ function webviewParse(url, key, insert, icnsert, css) { ` return html } -function unstreamingTL(type, key, basekey, insert, icnsert, left_fold, css, animecss, q) { +function unstreamingTL(type, key, basekey, insert, icnsert, left_fold, css, animecss, data) { + //type名が関数名 if (!left_fold) { var basehtml = - '' + `` $('#timeline-container').append(basehtml) var left_hold = - 'view_agenda' + - lang.lang_layout_leftFold + - '