Skip to content

Commit

Permalink
Fix unfollowed message count (fix #1985)
Browse files Browse the repository at this point in the history
  • Loading branch information
the1812 committed Jul 1, 2021
1 parent baa2788 commit 4bfb14b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion min/custom-navbar-messages.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 15 additions & 2 deletions src/style/custom-navbar/simple/custom-navbar-messages.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { NavbarComponent } from '../custom-navbar-component'
export class Messages extends NavbarComponent {
totalCount: number
settings: {
notify: boolean
hideNotFollowedCount: boolean
json: any
}
constructor() {
super()
this.href = 'https://message.bilibili.com/'
Expand Down Expand Up @@ -28,11 +33,16 @@ export class Messages extends NavbarComponent {
return 'messages'
}
async fetchSettings() {
const json = await Ajax.getJsonWithCredentials(`https://api.vc.bilibili.com/link_setting/v1/link_setting/get?msg_notify=1`)
const json = await Ajax.getJsonWithCredentials(`https://api.vc.bilibili.com/link_setting/v1/link_setting/get?msg_notify=1&show_unfollowed_msg=1`)
if (json.code !== 0) {
return
}
await this.setNotifyStyle(json.data.msg_notify)
this.settings = {
notify: json.data.msg_notify !== 3,
hideNotFollowedCount: json.data.show_unfollowed_msg === 1,
json: json.data,
}
return json.data.msg_notify !== 3
}
async setupEvents() {
Expand Down Expand Up @@ -64,7 +74,10 @@ export class Messages extends NavbarComponent {
if (mainJson.code !== 0 || messageJson.code !== 0) {
return
}
mainJson.data['user_msg'] = messageJson.data.unfollow_unread + messageJson.data.follow_unread
mainJson.data['user_msg'] = messageJson.data.follow_unread
if (!this.settings.hideNotFollowedCount) {
mainJson.data['user_msg'] += messageJson.data.unfollow_unread
}
this.totalCount = names.reduce((acc, it) => acc + mainJson.data[it], 0)
if (!this.totalCount) {
return
Expand Down

0 comments on commit 4bfb14b

Please sign in to comment.