-
+ {!this.error && !this.loading &&
}
)
},
- props,
+ props: [...props, 'refresh'],
data () {
return {
loading: false,
@@ -39,7 +40,7 @@ const withSubscription = (Component, fetch, select, contentPropName = 'content')
}
},
created () {
- if (isEmpty(this.fetchedData)) {
+ if (this.refresh || isEmpty(this.fetchedData)) {
this.fetchData()
}
},
--
cgit v1.2.3-70-g09d2
From e91a94ff9c4b9559f53a4b001f8972ceca843771 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Wed, 13 Feb 2019 22:04:28 -0500
Subject: Add mutes tab
---
src/components/mute_card/mute_card.js | 37 ++++++++++++++++++++++
src/components/mute_card/mute_card.vue | 24 ++++++++++++++
src/components/user_settings/user_settings.js | 13 ++++++--
src/components/user_settings/user_settings.vue | 4 +++
src/i18n/en.json | 1 +
src/modules/users.js | 25 ++++++++++++---
.../entity_normalizer/entity_normalizer.service.js | 1 +
7 files changed, 99 insertions(+), 6 deletions(-)
create mode 100644 src/components/mute_card/mute_card.js
create mode 100644 src/components/mute_card/mute_card.vue
(limited to 'src/components/user_settings')
diff --git a/src/components/mute_card/mute_card.js b/src/components/mute_card/mute_card.js
new file mode 100644
index 00000000..5dd0a9e5
--- /dev/null
+++ b/src/components/mute_card/mute_card.js
@@ -0,0 +1,37 @@
+import BasicUserCard from '../basic_user_card/basic_user_card.vue'
+
+const MuteCard = {
+ props: ['userId'],
+ data () {
+ return {
+ progress: false
+ }
+ },
+ computed: {
+ user () {
+ return this.$store.getters.userById(this.userId)
+ },
+ muted () {
+ return this.user.muted
+ }
+ },
+ components: {
+ BasicUserCard
+ },
+ methods: {
+ unmuteUser () {
+ this.progress = true
+ this.$store.dispatch('unmuteUser', this.user.id).then(() => {
+ this.progress = false
+ })
+ },
+ muteUser () {
+ this.progress = true
+ this.$store.dispatch('muteUser', this.user.id).then(() => {
+ this.progress = false
+ })
+ }
+ }
+}
+
+export default MuteCard
diff --git a/src/components/mute_card/mute_card.vue b/src/components/mute_card/mute_card.vue
new file mode 100644
index 00000000..e1bfe20b
--- /dev/null
+++ b/src/components/mute_card/mute_card.vue
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js
index 8eade382..8114d5e2 100644
--- a/src/components/user_settings/user_settings.js
+++ b/src/components/user_settings/user_settings.js
@@ -6,7 +6,7 @@ import ImageCropper from '../image_cropper/image_cropper.vue'
import StyleSwitcher from '../style_switcher/style_switcher.vue'
import fileSizeFormatService from '../../services/file_size_format/file_size_format.js'
import BlockCard from '../block_card/block_card.vue'
-import withLoadMore from '../../hocs/with_load_more/with_load_more'
+import MuteCard from '../mute_card/mute_card.vue'
import withSubscription from '../../hocs/with_subscription/with_subscription'
import withList from '../../hocs/with_list/with_list'
@@ -18,6 +18,14 @@ const BlockListWithSubscription = withSubscription(
'entries'
)
+const MuteList = withList(MuteCard, userId => ({ userId }))
+const MuteListWithSubscription = withSubscription(
+ MuteList,
+ (props, $store) => $store.dispatch('fetchMutes'),
+ (props, $store) => get($store.state.users.currentUser, 'muteIds', []),
+ 'entries'
+)
+
const UserSettings = {
data () {
return {
@@ -55,7 +63,8 @@ const UserSettings = {
StyleSwitcher,
TabSwitcher,
ImageCropper,
- 'block-list': BlockListWithSubscription
+ 'block-list': BlockListWithSubscription,
+ 'mute-list': MuteListWithSubscription
},
computed: {
user () {
diff --git a/src/components/user_settings/user_settings.vue b/src/components/user_settings/user_settings.vue
index 5bae583c..27f3e7cb 100644
--- a/src/components/user_settings/user_settings.vue
+++ b/src/components/user_settings/user_settings.vue
@@ -166,6 +166,10 @@
+
+
+
+
diff --git a/src/i18n/en.json b/src/i18n/en.json
index eeb95f9c..b41b6db9 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -165,6 +165,7 @@
"lock_account_description": "Restrict your account to approved followers only",
"loop_video": "Loop videos",
"loop_video_silent_only": "Loop only videos without sound (i.e. Mastodon's \"gifs\")",
+ "mutes_tab": "Mutes",
"play_videos_in_modal": "Play videos directly in the media viewer",
"use_contain_fit": "Don't crop the attachment in thumbnails",
"name": "Name",
diff --git a/src/modules/users.js b/src/modules/users.js
index 1f03b47e..71201a77 100644
--- a/src/modules/users.js
+++ b/src/modules/users.js
@@ -89,6 +89,10 @@ export const mutations = {
const user = state.currentUser
user.blockIds = union(user.blockIds, blockIds)
},
+ saveMutes (state, ids) {
+ const user = state.currentUser
+ user.muteIds = union(user.muteIds, ids)
+ },
setUserForStatus (state, status) {
status.user = state.usersObject[status.user.id]
},
@@ -157,6 +161,22 @@ const users = {
return store.rootState.api.backendInteractor.unblockUser(id)
.then((user) => store.commit('addNewUsers', [user]))
},
+ fetchMutes (store) {
+ return store.rootState.api.backendInteractor.fetchMutes()
+ .then((mutedUsers) => {
+ each(mutedUsers, (user) => { user.muted = true })
+ store.commit('addNewUsers', mutedUsers)
+ store.commit('saveMutes', map(mutedUsers, 'id'))
+ })
+ },
+ muteUser (store, id) {
+ return store.state.api.backendInteractor.setUserMute({ id, muted: true })
+ .then((user) => store.commit('addNewUsers', [user]))
+ },
+ unmuteUser (store, id) {
+ return store.state.api.backendInteractor.setUserMute({ id, muted: false })
+ .then((user) => store.commit('addNewUsers', [user]))
+ },
addFriends ({ rootState, commit }, fetchBy) {
return new Promise((resolve, reject) => {
const user = rootState.users.usersObject[fetchBy]
@@ -300,10 +320,7 @@ const users = {
store.dispatch('startFetching', { timeline: 'friends' })
// Get user mutes and follower info
- store.rootState.api.backendInteractor.fetchMutes().then((mutedUsers) => {
- each(mutedUsers, (user) => { user.muted = true })
- store.commit('addNewUsers', mutedUsers)
- })
+ store.dispatch('fetchMutes')
// Fetch our friends
store.rootState.api.backendInteractor.fetchFriends({ id: user.id })
diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js
index 0e1be61e..49c83811 100644
--- a/src/services/entity_normalizer/entity_normalizer.service.js
+++ b/src/services/entity_normalizer/entity_normalizer.service.js
@@ -121,6 +121,7 @@ export const parseUser = (data) => {
output.follow_request_count = data.pleroma.follow_request_count
}
output.blockIds = []
+ output.muteIds = []
return output
}
--
cgit v1.2.3-70-g09d2
From f81b82b4714643ba396b69ca54b97259a36a6b9f Mon Sep 17 00:00:00 2001
From: taehoon
Date: Wed, 13 Feb 2019 22:52:57 -0500
Subject: Use hoc definitions to be factor of factory
---
src/components/user_settings/user_settings.js | 26 ++++++++++++-------------
src/hocs/with_list/with_list.js | 8 ++++----
src/hocs/with_load_more/with_load_more.js | 6 +++---
src/hocs/with_subscription/with_subscription.js | 6 +++---
4 files changed, 22 insertions(+), 24 deletions(-)
(limited to 'src/components/user_settings')
diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js
index 8114d5e2..21023841 100644
--- a/src/components/user_settings/user_settings.js
+++ b/src/components/user_settings/user_settings.js
@@ -10,21 +10,19 @@ import MuteCard from '../mute_card/mute_card.vue'
import withSubscription from '../../hocs/with_subscription/with_subscription'
import withList from '../../hocs/with_list/with_list'
-const BlockList = withList(BlockCard, userId => ({ userId }))
-const BlockListWithSubscription = withSubscription(
- BlockList,
- (props, $store) => $store.dispatch('fetchBlocks'),
- (props, $store) => get($store.state.users.currentUser, 'blockIds', []),
- 'entries'
-)
+const BlockList = withList({ getEntryProps: userId => ({ userId }) })(BlockCard)
+const BlockListWithSubscription = withSubscription({
+ fetch: (props, $store) => $store.dispatch('fetchBlocks'),
+ select: (props, $store) => get($store.state.users.currentUser, 'blockIds', []),
+ contentPropName: 'entries'
+})(BlockList)
-const MuteList = withList(MuteCard, userId => ({ userId }))
-const MuteListWithSubscription = withSubscription(
- MuteList,
- (props, $store) => $store.dispatch('fetchMutes'),
- (props, $store) => get($store.state.users.currentUser, 'muteIds', []),
- 'entries'
-)
+const MuteList = withList({ getEntryProps: userId => ({ userId }) })(MuteCard)
+const MuteListWithSubscription = withSubscription({
+ fetch: (props, $store) => $store.dispatch('fetchMutes'),
+ select: (props, $store) => get($store.state.users.currentUser, 'muteIds', []),
+ contentPropName: 'entries'
+})(MuteList)
const UserSettings = {
data () {
diff --git a/src/hocs/with_list/with_list.js b/src/hocs/with_list/with_list.js
index 5ec37a2b..c31cdcb1 100644
--- a/src/hocs/with_list/with_list.js
+++ b/src/hocs/with_list/with_list.js
@@ -4,8 +4,8 @@ import map from 'lodash/map'
const defaultEntryPropsGetter = entry => ({ entry })
const defaultKeyGetter = entry => entry.id
-const withList = (Component, getEntryProps = defaultEntryPropsGetter, getKey = defaultKeyGetter) => {
- return Vue.component('withList', {
+const withList = ({ getEntryProps = defaultEntryPropsGetter, getKey = defaultKeyGetter }) => (ItemComponent) => (
+ Vue.component('withList', {
render (createElement) {
return (
@@ -18,13 +18,13 @@ const withList = (Component, getEntryProps = defaultEntryPropsGetter, getKey = d
},
on: this.$props.entryListeners
}
- return
+ return
})}
)
},
props: ['entries', 'entryProps', 'entryListeners']
})
-}
+)
export default withList
diff --git a/src/hocs/with_load_more/with_load_more.js b/src/hocs/with_load_more/with_load_more.js
index 8877f8d3..28c741e3 100644
--- a/src/hocs/with_load_more/with_load_more.js
+++ b/src/hocs/with_load_more/with_load_more.js
@@ -3,8 +3,8 @@ import filter from 'lodash/filter'
import isEmpty from 'lodash/isEmpty'
import './with_load_more.scss'
-const withLoadMore = (Component, fetch, select, entriesPropName = 'entries') => {
- const originalProps = Component.props || []
+const withLoadMore = ({ fetch, select, entriesPropName = 'entries' }) => (WrappedComponent) => {
+ const originalProps = WrappedComponent.props || []
const props = filter(originalProps, v => v !== 'entries')
return Vue.component('withLoadMore', {
@@ -18,7 +18,7 @@ const withLoadMore = (Component, fetch, select, entriesPropName = 'entries') =>
}
return (
-
+
--
cgit v1.2.3-70-g09d2
From 22851a3a967cc5364a95c71bda48eccc3808bf41 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Thu, 21 Feb 2019 20:15:51 -0500
Subject: Remove needless code
---
src/components/user_settings/user_settings.vue | 6 ------
1 file changed, 6 deletions(-)
(limited to 'src/components/user_settings')
diff --git a/src/components/user_settings/user_settings.vue b/src/components/user_settings/user_settings.vue
index 5c272114..983cbda0 100644
--- a/src/components/user_settings/user_settings.vue
+++ b/src/components/user_settings/user_settings.vue
@@ -168,12 +168,6 @@
{{$t('settings.no_blocks')}}
-
-
--
cgit v1.2.3-70-g09d2