From b24d9371526de772f855efbdd58d777ef3995593 Mon Sep 17 00:00:00 2001 From: cutls Date: Wed, 29 Jan 2020 23:22:53 +0900 Subject: [PATCH] Add: anouncement read counter --- app/js/tl/announParse.js | 2 +- app/js/tl/notification.js | 5 +++++ app/js/tl/tl.js | 11 ++++++++++- app/js/ui/layout.js | 5 +++-- app/view/make/language/en/main.json | 1 + app/view/make/language/ja-KS/main.json | 1 + app/view/make/language/ja/main.json | 1 + 7 files changed, 22 insertions(+), 4 deletions(-) diff --git a/app/js/tl/announParse.js b/app/js/tl/announParse.js index 64dd78ff..8443b9ee 100644 --- a/app/js/tl/announParse.js +++ b/app/js/tl/announParse.js @@ -79,7 +79,7 @@ function announParse(obj, acct_id, tlid) { template = template + - `
+ `
${content}
${reactions} diff --git a/app/js/tl/notification.js b/app/js/tl/notification.js index ec07b58a..a3deaa13 100644 --- a/app/js/tl/notification.js +++ b/app/js/tl/notification.js @@ -406,6 +406,11 @@ function notfCanceler(acct) { localStorage.removeItem('notf-follow_' + acct) $('.notf-follow_' + acct).addClass('hide') $('.notf-icon_' + acct).removeClass('red-text') + var id = $('#announce_' + acct + ' .announcement').first().attr('data-id') + $('.notf-announ_' + acct + '_ct').text("") + if(id) { + localStorage.setItem('announ_' + acct, id) + } } function allNotfRead() { var multi = localStorage.getItem('multi') diff --git a/app/js/tl/tl.js b/app/js/tl/tl.js index 64ae6e4b..9751aa60 100644 --- a/app/js/tl/tl.js +++ b/app/js/tl/tl.js @@ -1191,7 +1191,16 @@ function announ(acct_id, tlid) { } if (json.length > 0) { $('.notf-announ_' + acct_id).removeClass('hide') - $('.notf-announ_' + acct_id + '_ct').text(json.length) + var ct = 0 + for (var i = 0; i < json.length; i++) { + if (localStorage.getItem('announ_' + acct_id) == json[i].id) { + break + } + ct++ + } + if(ct > 0) { + $('.notf-announ_' + acct_id + '_ct').text(ct) + } } else { $('.notf-announ_' + acct_id).addClass('hide') } diff --git a/app/js/ui/layout.js b/app/js/ui/layout.js index f59f1d93..3fe7581e 100644 --- a/app/js/ui/layout.js +++ b/app/js/ui/layout.js @@ -368,9 +368,10 @@ function parseColumn(target, dontclose) { title="${unique_notf}" ${icnsert}> notifications - + - 0 + ${if_tag_btn}
diff --git a/app/view/make/language/en/main.json b/app/view/make/language/en/main.json index 50370b0a..53a91e1a 100644 --- a/app/view/make/language/en/main.json +++ b/app/view/make/language/en/main.json @@ -139,6 +139,7 @@ "lang_layout_deleteColumnDesc": "Delete this column", "lang_layout_unread": "Unread", "lang_layout_tagManager": "Tag timeline manager", + "lang_layout_announ": "Announcement: the counter is the number of your unread announcements. If not shown, it means announcements are all marked as read.", "lang_sort_gothis": "Go to this column", "lang_sort_remthis": "Delete this column", "lang_spotify_img": "Attach an album artwork", diff --git a/app/view/make/language/ja-KS/main.json b/app/view/make/language/ja-KS/main.json index ae1a6e5a..d3302875 100644 --- a/app/view/make/language/ja-KS/main.json +++ b/app/view/make/language/ja-KS/main.json @@ -138,6 +138,7 @@ "lang_layout_deleteColumnDesc": "カラムを削除してええ?", "lang_layout_unread": "未読", "lang_layout_tagManager": "タグタイムラインをいじる", + "lang_layout_announ": "お知らせ: 数字は未読数や。表示されてんときはもう読んでしもたいうことやな。", "lang_sort_gothis": "このカラムへ", "lang_sort_remthis": "このカラムを消す", "lang_spotify_img": "アルバムアートワークを付けるで。", diff --git a/app/view/make/language/ja/main.json b/app/view/make/language/ja/main.json index 89adf3a3..91148713 100644 --- a/app/view/make/language/ja/main.json +++ b/app/view/make/language/ja/main.json @@ -139,6 +139,7 @@ "lang_layout_deleteColumnDesc": "カラムを削除しますか?", "lang_layout_unread": "未読", "lang_layout_tagManager": "タグタイムラインの編集", + "lang_layout_announ": "お知らせ: 数字は未読数を表します。表示されていない場合は全て既読です。", "lang_sort_gothis": "このカラムへ", "lang_sort_remthis": "このカラムを削除", "lang_spotify_img": "アルバムアートワークを添付します。",