From a03c97f5fec8a599bb87a39d236366cca10a278a Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Thu, 13 Sep 2018 00:14:40 +0900
Subject: [PATCH] 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 @@
+
+
+
+
+ {{ $t('modals.mute_confirm.body') }}
+
+
+
+
+
+
+
+
+
+
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
+ })
+ }
+ }
+}