From a03c97f5fec8a599bb87a39d236366cca10a278a Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Thu, 13 Sep 2018 00:14:40 +0900 Subject: [PATCH 1/5] refs #577 Add mute menu to mute an account --- src/config/locales/en/translation.json | 10 +++ .../Contents/SideBar/AccountProfile.vue | 33 +++++++++- .../components/TimelineSpace/Modals.vue | 3 + .../TimelineSpace/Modals/MuteConfirm.vue | 66 +++++++++++++++++++ src/renderer/store/TimelineSpace/Modals.js | 7 +- .../store/TimelineSpace/Modals/MuteConfirm.js | 39 +++++++++++ 6 files changed, 153 insertions(+), 5 deletions(-) create mode 100644 src/renderer/components/TimelineSpace/Modals/MuteConfirm.vue create mode 100644 src/renderer/store/TimelineSpace/Modals/MuteConfirm.js diff --git a/src/config/locales/en/translation.json b/src/config/locales/en/translation.json index e96410ed..8c8b97c5 100644 --- a/src/config/locales/en/translation.json +++ b/src/config/locales/en/translation.json @@ -164,6 +164,12 @@ "list_membership": { "title": "List Memberships" }, + "mute_confirm": { + "title": "Are you sure to block?", + "body": "Hide notification from this user?", + "cancel": "Cancel", + "ok": "Ok" + }, "shortcut": { "title": "Keyboard shortcuts", "ctrl_number": "Switch accounts", @@ -208,6 +214,10 @@ "follow_requested": "Follow requested", "open_in_browser": "Open in Browser", "manage_list_memberships": "Manage List Memberships", + "mute": "Mute", + "unmute": "Unmute", + "unblock": "Unblock", + "block": "Block", "toots": "Toots", "follows": "Follows", "followers": "Followers" diff --git a/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue b/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue index f823a8d9..8605c3b8 100644 --- a/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue +++ b/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue @@ -23,6 +23,18 @@
  • {{ $t('side_bar.account_profile.manage_list_memberships') }}
  • +
  • + {{ $t('side_bar.account_profile.unmute') }} +
  • +
  • + {{ $t('side_bar.account_profile.mute') }} +
  • +
  • + {{ $t('side_bar.account_profile.unblock') }} +
  • +
  • + {{ $t('side_bar.account_profile.block') }} +
  • @@ -104,10 +116,7 @@ export default { }, computed: { ...mapState({ - account: state => state.TimelineSpace.Contents.SideBar.AccountProfile.account, user: state => state.TimelineSpace.account, - relationship: state => state.TimelineSpace.Contents.SideBar.AccountProfile.relationship, - loading: state => state.TimelineSpace.Contents.SideBar.AccountProfile.loading, theme: (state) => { return { '--theme-mask-color': state.App.theme.wrapper_mask_color, @@ -115,6 +124,13 @@ export default { '--theme-primary-color': state.App.theme.primary_color } } + }), + ...mapState('TimelineSpace/Contents/SideBar/AccountProfile', { + account: state => state.account, + relationship: state => state.relationship, + loading: state => state.loading, + muting: state => state.relationship && state.relationship.muting, + blocking: state => state.relationship && state.relationship.blocking }) }, watch: { @@ -168,6 +184,17 @@ export default { this.$store.dispatch('TimelineSpace/Modals/ListMembership/setAccount', account) this.$store.dispatch('TimelineSpace/Modals/ListMembership/changeModal', true) this.$refs.popper.doClose() + }, + confirmMute (account) { + this.$store.dispatch('TimelineSpace/Modals/MuteConfirm/changeAccount', account) + this.$store.dispatch('TimelineSpace/Modals/MuteConfirm/changeModal', true) + this.$refs.popper.doClose() + }, + unmute () { + }, + confirmBlock () { + }, + unblock () { } } } diff --git a/src/renderer/components/TimelineSpace/Modals.vue b/src/renderer/components/TimelineSpace/Modals.vue index 30f4b719..c30c75b5 100644 --- a/src/renderer/components/TimelineSpace/Modals.vue +++ b/src/renderer/components/TimelineSpace/Modals.vue @@ -5,6 +5,7 @@ + @@ -15,6 +16,7 @@ import Jump from './Modals/Jump' import ImageViewer from './Modals/ImageViewer' import ListMembership from './Modals/ListMembership' import AddListMember from './Modals/AddListMember' +import MuteConfirm from './Modals/MuteConfirm' import Shortcut from './Modals/Shortcut' export default { @@ -25,6 +27,7 @@ export default { ImageViewer, ListMembership, AddListMember, + MuteConfirm, Shortcut } } diff --git a/src/renderer/components/TimelineSpace/Modals/MuteConfirm.vue b/src/renderer/components/TimelineSpace/Modals/MuteConfirm.vue new file mode 100644 index 00000000..17228aaf --- /dev/null +++ b/src/renderer/components/TimelineSpace/Modals/MuteConfirm.vue @@ -0,0 +1,66 @@ + + + + + diff --git a/src/renderer/store/TimelineSpace/Modals.js b/src/renderer/store/TimelineSpace/Modals.js index dee242c3..07041f52 100644 --- a/src/renderer/store/TimelineSpace/Modals.js +++ b/src/renderer/store/TimelineSpace/Modals.js @@ -3,6 +3,7 @@ import ImageViewer from './Modals/ImageViewer' import Jump from './Modals/Jump' import ListMembership from './Modals/ListMembership' import AddListMember from './Modals/AddListMember' +import MuteConfirm from './Modals/MuteConfirm' import Shortcut from './Modals/Shortcut' const Modals = { @@ -13,6 +14,7 @@ const Modals = { Jump, ListMembership, AddListMember, + MuteConfirm, Shortcut }, getters: { @@ -22,8 +24,9 @@ const Modals = { const jump = rootState.TimelineSpace.Modals.Jump.modalOpen const listMembership = rootState.TimelineSpace.Modals.ListMembership.modalOpen const addListMember = rootState.TimelineSpace.Modals.AddListMember.modalOpen - const shortcut = rootState.TimelineSpace.Modals.Jump.modalOpen - return imageViewer || newToot || jump || listMembership || addListMember || shortcut + const shortcut = rootState.TimelineSpace.Modals.Shortcut.modalOpen + const muteConfirm = rootState.TimelineSpace.Modals.MuteConfirm.modalOpen + return imageViewer || newToot || jump || listMembership || addListMember || shortcut || muteConfirm } } } diff --git a/src/renderer/store/TimelineSpace/Modals/MuteConfirm.js b/src/renderer/store/TimelineSpace/Modals/MuteConfirm.js new file mode 100644 index 00000000..c3934245 --- /dev/null +++ b/src/renderer/store/TimelineSpace/Modals/MuteConfirm.js @@ -0,0 +1,39 @@ +import Mastodon from 'megalodon' + +export default { + namespaced: true, + state: { + modalOpen: false, + account: {} + }, + mutations: { + changeModal (state, value) { + state.modalOpen = value + }, + changeAccount (state, account) { + state.account = account + } + }, + actions: { + changeModal ({ commit }, value) { + commit('changeModal', value) + }, + changeAccount ({ commit }, account) { + commit('changeAccount', account) + }, + async submit ({ state, rootState, dispatch }, notify) { + const client = new Mastodon( + rootState.TimelineSpace.account.accessToken, + rootState.TimelineSpace.account.baseURL + '/api/v1' + ) + return client.post(`/accounts/${state.account.id}/mute`, { + notifications: notify + }) + .then(res => { + // Reload relationship + dispatch('TimelineSpace/Contents/SideBar/AccountProfile/fetchRelationship', state.account, { root: true }) + return res.data + }) + } + } +} From 96654119f5f49d0c7f95b4998764a9f9de76ac3a Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Thu, 13 Sep 2018 00:30:54 +0900 Subject: [PATCH 2/5] refs #577 Add unmute menu to unmute an account --- .../Contents/SideBar/AccountProfile.vue | 4 +++- .../Contents/SideBar/AccountProfile.js | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue b/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue index 8605c3b8..1d958496 100644 --- a/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue +++ b/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue @@ -190,7 +190,9 @@ export default { this.$store.dispatch('TimelineSpace/Modals/MuteConfirm/changeModal', true) this.$refs.popper.doClose() }, - unmute () { + unmute (account) { + this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/unmute', account) + this.$refs.popper.doClose() }, confirmBlock () { }, diff --git a/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.js b/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.js index 7970a383..2b0a6c1a 100644 --- a/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.js +++ b/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.js @@ -71,7 +71,7 @@ const AccountProfile = { throw err }) }, - unfollow ({ state, commit, rootState }, account) { + unfollow ({ commit, rootState }, account) { commit('changeLoading', true) const client = new Mastodon( rootState.TimelineSpace.account.accessToken, @@ -79,17 +79,26 @@ const AccountProfile = { ) return client.post(`/accounts/${account.id}/unfollow`) .then(res => { - commit('changeLoading', false) commit('changeRelationship', res.data) return res.data }) - .catch(err => { + .finally(() => { commit('changeLoading', false) - throw err }) }, close ({ commit }) { commit('changeAccount', null) + }, + async unmute ({ rootState, commit }, account) { + const client = new Mastodon( + rootState.TimelineSpace.account.accessToken, + rootState.TimelineSpace.account.baseURL + '/api/v1' + ) + return client.post(`/accounts/${account.id}/unmute`) + .then(res => { + commit('changeRelationship', res.data) + return res.data + }) } } } From b1d496993a2d2c8698990fd9fd4577b5080cc017 Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Thu, 13 Sep 2018 00:40:14 +0900 Subject: [PATCH 3/5] refs #577 Add block menu to block an account --- .../Contents/SideBar/AccountProfile.vue | 6 ++++-- .../Contents/SideBar/AccountProfile.js | 13 ++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue b/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue index 1d958496..8546b06b 100644 --- a/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue +++ b/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue @@ -32,7 +32,7 @@
  • {{ $t('side_bar.account_profile.unblock') }}
  • -
  • +
  • {{ $t('side_bar.account_profile.block') }}
  • @@ -194,7 +194,9 @@ export default { this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/unmute', account) this.$refs.popper.doClose() }, - confirmBlock () { + block (account) { + this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/block', account) + this.$refs.popper.doClose() }, unblock () { } diff --git a/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.js b/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.js index 2b0a6c1a..79ea5621 100644 --- a/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.js +++ b/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.js @@ -89,7 +89,7 @@ const AccountProfile = { close ({ commit }) { commit('changeAccount', null) }, - async unmute ({ rootState, commit }, account) { + unmute ({ rootState, commit }, account) { const client = new Mastodon( rootState.TimelineSpace.account.accessToken, rootState.TimelineSpace.account.baseURL + '/api/v1' @@ -99,6 +99,17 @@ const AccountProfile = { commit('changeRelationship', res.data) return res.data }) + }, + block ({ rootState, commit }, account) { + const client = new Mastodon( + rootState.TimelineSpace.account.accessToken, + rootState.TimelineSpace.account.baseURL + '/api/v1' + ) + return client.post(`/accounts/${account.id}/block`) + .then(res => { + commit('changeRelationship', res.data) + return res.data + }) } } } From a4abb6312d01187716097bfb5361dd7337b5f9a8 Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Thu, 13 Sep 2018 00:43:28 +0900 Subject: [PATCH 4/5] refs #577 Add unblock menu to unblock an account --- .../TimelineSpace/Contents/SideBar/AccountProfile.vue | 4 +++- .../TimelineSpace/Contents/SideBar/AccountProfile.js | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue b/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue index 8546b06b..2723a7e4 100644 --- a/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue +++ b/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue @@ -198,7 +198,9 @@ export default { this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/block', account) this.$refs.popper.doClose() }, - unblock () { + unblock (account) { + this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/unblock', account) + this.$refs.popper.doClose() } } } diff --git a/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.js b/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.js index 79ea5621..be1b6626 100644 --- a/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.js +++ b/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.js @@ -110,6 +110,17 @@ const AccountProfile = { commit('changeRelationship', res.data) return res.data }) + }, + unblock ({ rootState, commit }, account) { + const client = new Mastodon( + rootState.TimelineSpace.account.accessToken, + rootState.TimelineSpace.account.baseURL + '/api/v1' + ) + return client.post(`/accounts/${account.id}/unblock`) + .then(res => { + commit('changeRelationship', res.data) + return res.data + }) } } } From 7140eadc61634afda0f8cae6a2daba86278a15a8 Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Thu, 13 Sep 2018 08:04:54 +0900 Subject: [PATCH 5/5] refs #577 Update translation for mute/block menu --- src/config/locales/de/translation.json | 10 ++++++++++ src/config/locales/en/translation.json | 4 ++-- src/config/locales/fr/translation.json | 10 ++++++++++ src/config/locales/ja/translation.json | 10 ++++++++++ src/config/locales/ko/translation.json | 10 ++++++++++ src/config/locales/pl/translation.json | 10 ++++++++++ 6 files changed, 52 insertions(+), 2 deletions(-) diff --git a/src/config/locales/de/translation.json b/src/config/locales/de/translation.json index e833ba50..898ecd1b 100644 --- a/src/config/locales/de/translation.json +++ b/src/config/locales/de/translation.json @@ -159,6 +159,12 @@ "list_membership": { "title": "Listen-Mitgliedschaften" }, + "mute_confirm": { + "title": "Are you sure to mute?", + "body": "Hide notification from this user?", + "cancel": "Cancel", + "ok": "Mute" + }, "shortcut": { "title": "Keyboard shortcuts", "ctrl_number": "Switch accounts", @@ -203,6 +209,10 @@ "follow_requested": "Folgen Sie angefordert", "open_in_browser": "Im Browser öffnen", "manage_list_memberships": "Listen-Mitgliedschaften verwalten", + "mute": "Mute", + "unmute": "Unmute", + "unblock": "Unblock", + "block": "Block", "toots": "Toots", "follows": "Follows", "followers": "Follower" diff --git a/src/config/locales/en/translation.json b/src/config/locales/en/translation.json index 8c8b97c5..bcd5c961 100644 --- a/src/config/locales/en/translation.json +++ b/src/config/locales/en/translation.json @@ -165,10 +165,10 @@ "title": "List Memberships" }, "mute_confirm": { - "title": "Are you sure to block?", + "title": "Are you sure to mute?", "body": "Hide notification from this user?", "cancel": "Cancel", - "ok": "Ok" + "ok": "Mute" }, "shortcut": { "title": "Keyboard shortcuts", diff --git a/src/config/locales/fr/translation.json b/src/config/locales/fr/translation.json index d78fd8f3..bbc2d8d7 100644 --- a/src/config/locales/fr/translation.json +++ b/src/config/locales/fr/translation.json @@ -159,6 +159,12 @@ "list_membership": { "title": "Éditer la liste" }, + "mute_confirm": { + "title": "Are you sure to mute?", + "body": "Hide notification from this user?", + "cancel": "Cancel", + "ok": "Mute" + }, "shortcut": { "title": "Keyboard shortcuts", "ctrl_number": "Switch accounts", @@ -203,6 +209,10 @@ "follow_requested": "Suivre demande", "open_in_browser": "Ouvrir dans un navigateur", "manage_list_memberships": "Inscriptions aux listes", + "mute": "Mute", + "unmute": "Unmute", + "unblock": "Unblock", + "block": "Block", "toots": "Pouets", "follows": "Abonnements", "followers": "Abonné⋅e⋅s" diff --git a/src/config/locales/ja/translation.json b/src/config/locales/ja/translation.json index 59d86a31..4fa6134b 100644 --- a/src/config/locales/ja/translation.json +++ b/src/config/locales/ja/translation.json @@ -159,6 +159,12 @@ "list_membership": { "title": "リストメンバー管理" }, + "mute_confirm": { + "title": "本当にミュートしますか?", + "body": "このユーザからの通知もミュートしますか?", + "cancel": "キャンセル", + "ok": "ミュートする" + }, "shortcut": { "title": "キーボードショートカット", "ctrl_number": "アカウントの切り替え", @@ -203,6 +209,10 @@ "follow_requested": "フォロー承認待ち", "open_in_browser": "ブラウザで開く", "manage_list_memberships": "リストの管理", + "mute": "ミュート", + "unmute": "ミュートを解除", + "unblock": "ブロックを解除", + "block": "ブロック", "toots": "トゥート", "follows": "フォロー", "followers": "フォロワー" diff --git a/src/config/locales/ko/translation.json b/src/config/locales/ko/translation.json index d0b8a40f..04fe5b1f 100644 --- a/src/config/locales/ko/translation.json +++ b/src/config/locales/ko/translation.json @@ -164,6 +164,12 @@ "list_membership": { "title": "리스트 멤버" }, + "mute_confirm": { + "title": "Are you sure to mute?", + "body": "Hide notification from this user?", + "cancel": "Cancel", + "ok": "Mute" + }, "shortcut": { "title": "키보드 단축키", "ctrl_number": "계정 변경", @@ -208,6 +214,10 @@ "follow_requested": "팔로우 요청중", "open_in_browser": "브라우저에서 열기", "manage_list_memberships": "리스트 멤버 관리", + "mute": "Mute", + "unmute": "Unmute", + "unblock": "Unblock", + "block": "Block", "toots": "툿", "follows": "팔로잉", "followers": "팔로워" diff --git a/src/config/locales/pl/translation.json b/src/config/locales/pl/translation.json index 6270e46a..716eba65 100644 --- a/src/config/locales/pl/translation.json +++ b/src/config/locales/pl/translation.json @@ -159,6 +159,12 @@ "list_membership": { "title": "Należy do grup" }, + "mute_confirm": { + "title": "Are you sure to mute?", + "body": "Hide notification from this user?", + "cancel": "Cancel", + "ok": "Mute" + }, "shortcut": { "title": "Keyboard shortcuts", "ctrl_number": "Switch accounts", @@ -203,6 +209,10 @@ "follow_requested": "Śledź prośbę", "open_in_browser": "Otwórz w przeglądarce", "manage_list_memberships": "Zarządzaj przynależnością do grup", + "mute": "Mute", + "unmute": "Unmute", + "unblock": "Unblock", + "block": "Block", "toots": "Wpisy", "follows": "Śledzeni", "followers": "Śledzący"