Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(frontend): プラグインを用いて疑似的にミュートできるようにする #12135

Merged
merged 3 commits into from
Oct 28, 2023

Conversation

tai-cha
Copy link
Contributor

@tai-cha tai-cha commented Oct 24, 2023

What

Plugin:register_note_view_interruptorを使ってプラグインを使ってノートの表示を消せるようにした
isDeleteをtrueにするようにした

Why

resolve #12134

Additional info (optional)

この変更を行うと正常にnoteが返却されない場合に返り値にnullが返るとノートが表示されなくなるので他の方法を取るほうが分かりやすさはあるかもしれない(けどnoteに対してnull返すっていう意味では正しそうにも思える)

例えばこのようなプラグインが動く

プラグイン
/// @ 0.13.1
### {
  name: "フォロ限ミュート"
  version: "0.0.1a1"
  author: "taichan"
  description: "フォロワー限定のみのミュートを実現します"
  permissions: []
  config: {}
}

let USERIDS_KEY = "kimikesu-notes-f"

@init() {
  let user_ids = Mk:load(USERIDS_KEY)
  if (user_ids == null || user_ids == '') {
    Mk:save(USERIDS_KEY "[]")
  }
}

@get_user_ids() {
  return Json:parse(Mk:load(USERIDS_KEY))
}

@set_user_ids(value) {
  return Mk:save(USERIDS_KEY, Json:stringify(value))
}

@add_user_id(value) {
  let userIds = get_user_ids()
  userIds.push(value)
  set_user_ids(userIds)
  <: 'added'
  <: get_user_ids()
}

@remove_user_id(value) {
  let userIds = get_user_ids().filter(@(v) { v != value })
  set_user_ids(userIds)
}

@list_incl(user) {
  return get_user_ids().incl(user.id)
}

@register(user) {
  if (!list_incl(user)) {
    add_user_id(user.id)
  }
}

@un_register(user) {
  remove_user_id(user.id)
}

@reset() {
  set_user_ids([])
}

@kimikesu(user) {
  let muted = list_incl(user)
  let statusText = if (muted) {'有効'} else {'無効'}
  if (!muted) {
    let res = Mk:confirm("フォロワー限定ノートをミュート" `このユーザーのフォロワー限定ノートを非表示にしますか?{Str:lf}現在の設定(**{statusText}**)`)
    if (res) {
      register(user)
      Mk:dialog("フォロワー限定ノートをミュートしました" "既に表示されているノートはリロード後にミュートされます")
    }
  } else {
    let res = Mk:confirm("フォロワー限定ノートをミュート解除" `このユーザーのフォロワー限定ノート非表示を解除しますか?{Str:lf}現在の設定(**{statusText}**)`)
    if (res) {
      un_register(user)
      Mk:dialog("フォロワー限定ノートをミュート解除しました" "既に読み込まれているノートはリロード後にミュート解除されます")
    }
  }
}

init()

Plugin:register_note_view_interruptor(@(note) {
  if (list_incl(note.user) && note.visibility == 'followers') {
    return null
  }
  return note
})

Plugin:register_user_action("フォロワー限定ノートのミュート設定を変更" kimikesu)

Checklist

  • Read the contribution guide
  • Test working in a local environment
  • (If needed) Add story of storybook
  • (If needed) Update CHANGELOG.md
  • (If possible) Add tests

@github-actions github-actions bot added the packages/frontend Client side specific issue/PR label Oct 24, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Oct 24, 2023

このPRによるapi.jsonの差分

差分はこちら

Get diff files from Workflow Page

@codecov
Copy link

codecov bot commented Oct 24, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (481db8a) 79.15% compared to head (59f7486) 79.24%.
Report is 1 commits behind head on develop.

❗ Current head 59f7486 differs from pull request most recent head c762957. Consider uploading reports for the commit c762957 to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #12135      +/-   ##
===========================================
+ Coverage    79.15%   79.24%   +0.09%     
===========================================
  Files          940      764     -176     
  Lines       100831    77833   -22998     
  Branches      8208     7698     -510     
===========================================
- Hits         79808    61679   -18129     
+ Misses       21023    16154    -4869     

see 185 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tai-cha tai-cha marked this pull request as ready for review October 24, 2023 14:48
@tai-cha tai-cha changed the title feat: プラグインを用いて疑似的にミュートできるようにする feat(frontend): プラグインを用いて疑似的にミュートできるようにする Oct 24, 2023
@syuilo syuilo merged commit e73e218 into misskey-dev:develop Oct 28, 2023
7 of 8 checks passed
@syuilo
Copy link
Member

syuilo commented Oct 28, 2023

👍🏻

@tai-cha tai-cha deleted the feat/plugin-mute branch October 28, 2023 08:52
kanarikanaru pushed a commit to kanarikanaru/misskey that referenced this pull request Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages/frontend Client side specific issue/PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

プラグインでノートの表示自体を消したい
2 participants