-
-
-
{{ user.name }}
+
+
+
+
+ {{ user.name }}
+
+
+
+ @{{user.screen_name}}
+
+
-
-
- @{{user.screen_name}}
-
+
+
@@ -25,35 +30,7 @@
From 0220d3d304cbcb82b8531ff373dce1b35e93fb4f Mon Sep 17 00:00:00 2001
From: taehoon
Date: Wed, 13 Feb 2019 14:55:02 -0500
Subject: [PATCH 07/29] Finally, added BlockCard
---
src/components/block_card/block_card.js | 21 +++++++++++++++++++
src/components/block_card/block_card.vue | 16 ++++++++++++++
src/components/user_settings/user_settings.js | 6 +++---
src/i18n/en.json | 4 +++-
4 files changed, 43 insertions(+), 4 deletions(-)
create mode 100644 src/components/block_card/block_card.js
create mode 100644 src/components/block_card/block_card.vue
diff --git a/src/components/block_card/block_card.js b/src/components/block_card/block_card.js
new file mode 100644
index 00000000..8788fb62
--- /dev/null
+++ b/src/components/block_card/block_card.js
@@ -0,0 +1,21 @@
+import BasicUserCard from '../basic_user_card/basic_user_card.vue'
+
+const BlockCard = {
+ props: ['user'],
+ data () {
+ return {
+ progress: false,
+ updated: false
+ }
+ },
+ components: {
+ BasicUserCard
+ },
+ methods: {
+ unblockUser () {
+ this.progress = true
+ }
+ }
+}
+
+export default BlockCard
diff --git a/src/components/block_card/block_card.vue b/src/components/block_card/block_card.vue
new file mode 100644
index 00000000..06fc67fc
--- /dev/null
+++ b/src/components/block_card/block_card.vue
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
\ 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 a46afda6..3bcecdf4 100644
--- a/src/components/user_settings/user_settings.js
+++ b/src/components/user_settings/user_settings.js
@@ -5,13 +5,13 @@ import TabSwitcher from '../tab_switcher/tab_switcher.js'
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 BasicUserCard from '../basic_user_card/basic_user_card.vue'
+import BlockCard from '../block_card/block_card.vue'
import withLoadMore from '../../hocs/with_load_more/with_load_more'
import withList from '../../hocs/with_list/with_list'
-const UserList = withList(BasicUserCard, entry => ({ user: entry }))
+const BlockList = withList(BlockCard, entry => ({ user: entry }))
const BlockListWithLoadMore = withLoadMore(
- UserList,
+ BlockList,
(props, $store) => $store.dispatch('fetchBlocks'),
(props, $store) => get($store.state.users.currentUser, 'blocks', [])
)
diff --git a/src/i18n/en.json b/src/i18n/en.json
index ddde1de2..9027803d 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -366,7 +366,9 @@
"muted": "Muted",
"per_day": "per day",
"remote_follow": "Remote follow",
- "statuses": "Statuses"
+ "statuses": "Statuses",
+ "unblock": "Unblock",
+ "unblock_progress": "Unblocking..."
},
"user_profile": {
"timeline_title": "User Timeline"
From 52913d8f873dd6994988d6a928cca007a0effeaf Mon Sep 17 00:00:00 2001
From: taehoon
Date: Wed, 13 Feb 2019 15:31:20 -0500
Subject: [PATCH 08/29] Complete functionality of BlockCard
---
src/components/block_card/block_card.js | 22 ++++++++++++++++---
src/components/block_card/block_card.vue | 10 ++++++++-
src/components/user_settings/user_settings.js | 2 +-
src/i18n/en.json | 3 ++-
src/modules/users.js | 8 +++++++
5 files changed, 39 insertions(+), 6 deletions(-)
diff --git a/src/components/block_card/block_card.js b/src/components/block_card/block_card.js
index 8788fb62..11fa27b4 100644
--- a/src/components/block_card/block_card.js
+++ b/src/components/block_card/block_card.js
@@ -1,11 +1,18 @@
import BasicUserCard from '../basic_user_card/basic_user_card.vue'
const BlockCard = {
- props: ['user'],
+ props: ['userId'],
data () {
return {
- progress: false,
- updated: false
+ progress: false
+ }
+ },
+ computed: {
+ user () {
+ return this.$store.getters.userById(this.userId)
+ },
+ blocked () {
+ return this.user.statusnet_blocking
}
},
components: {
@@ -14,6 +21,15 @@ const BlockCard = {
methods: {
unblockUser () {
this.progress = true
+ this.$store.dispatch('unblockUser', this.user.id).then(() => {
+ this.progress = false
+ })
+ },
+ blockUser () {
+ this.progress = true
+ this.$store.dispatch('blockUser', this.user.id).then(() => {
+ this.progress = false
+ })
}
}
}
diff --git a/src/components/block_card/block_card.vue b/src/components/block_card/block_card.vue
index 06fc67fc..ed7fe30b 100644
--- a/src/components/block_card/block_card.vue
+++ b/src/components/block_card/block_card.vue
@@ -1,7 +1,7 @@
-
+
+
+ {{ $t('user_card.block_progress') }}
+
+
+ {{ $t('user_card.block') }}
+
+
diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js
index 3bcecdf4..621dcd4b 100644
--- a/src/components/user_settings/user_settings.js
+++ b/src/components/user_settings/user_settings.js
@@ -9,7 +9,7 @@ import BlockCard from '../block_card/block_card.vue'
import withLoadMore from '../../hocs/with_load_more/with_load_more'
import withList from '../../hocs/with_list/with_list'
-const BlockList = withList(BlockCard, entry => ({ user: entry }))
+const BlockList = withList(BlockCard, entry => ({ userId: entry.id }))
const BlockListWithLoadMore = withLoadMore(
BlockList,
(props, $store) => $store.dispatch('fetchBlocks'),
diff --git a/src/i18n/en.json b/src/i18n/en.json
index 9027803d..eeb95f9c 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -368,7 +368,8 @@
"remote_follow": "Remote follow",
"statuses": "Statuses",
"unblock": "Unblock",
- "unblock_progress": "Unblocking..."
+ "unblock_progress": "Unblocking...",
+ "block_progress": "Blocking..."
},
"user_profile": {
"timeline_title": "User Timeline"
diff --git a/src/modules/users.js b/src/modules/users.js
index 6ea4e0c9..ce8af68c 100644
--- a/src/modules/users.js
+++ b/src/modules/users.js
@@ -154,6 +154,14 @@ const users = {
return blocks
})
},
+ blockUser (store, id) {
+ return store.rootState.api.backendInteractor.blockUser(id)
+ .then((user) => store.commit('addNewUsers', [user]))
+ },
+ unblockUser (store, id) {
+ return store.rootState.api.backendInteractor.unblockUser(id)
+ .then((user) => store.commit('addNewUsers', [user]))
+ },
addFriends ({ rootState, commit }, fetchBy) {
return new Promise((resolve, reject) => {
const user = rootState.users.usersObject[fetchBy]
From 82702748653c7630e4f337433d47863f52c57ee4 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Wed, 13 Feb 2019 20:59:26 -0500
Subject: [PATCH 09/29] Update hocs to pass parent-scope bindings to the
wrapped component
---
src/hocs/with_list/with_list.js | 11 +++---
src/hocs/with_load_more/with_load_more.js | 42 ++++++++++++++---------
2 files changed, 33 insertions(+), 20 deletions(-)
diff --git a/src/hocs/with_list/with_list.js b/src/hocs/with_list/with_list.js
index 21aa288b..5ec37a2b 100644
--- a/src/hocs/with_list/with_list.js
+++ b/src/hocs/with_list/with_list.js
@@ -12,15 +12,18 @@ const withList = (Component, getEntryProps = defaultEntryPropsGetter, getKey = d
{map(this.entries, (entry, index) => {
const props = {
key: getKey(entry, index),
- ...this.$props.entryProps,
- ...getEntryProps(entry, index)
+ props: {
+ ...this.$props.entryProps,
+ ...getEntryProps(entry, index)
+ },
+ on: this.$props.entryListeners
}
- return
+ return
})}
)
},
- props: ['entries', 'entryProps']
+ props: ['entries', 'entryProps', 'entryListeners']
})
}
diff --git a/src/hocs/with_load_more/with_load_more.js b/src/hocs/with_load_more/with_load_more.js
index 14d4303d..8877f8d3 100644
--- a/src/hocs/with_load_more/with_load_more.js
+++ b/src/hocs/with_load_more/with_load_more.js
@@ -1,20 +1,28 @@
import Vue from 'vue'
import filter from 'lodash/filter'
+import isEmpty from 'lodash/isEmpty'
import './with_load_more.scss'
-const withLoadMore = (Component, fetchEntries, getEntries) => {
+const withLoadMore = (Component, fetch, select, entriesPropName = 'entries') => {
const originalProps = Component.props || []
const props = filter(originalProps, v => v !== 'entries')
return Vue.component('withLoadMore', {
render (createElement) {
+ const props = {
+ props: {
+ ...this.$props,
+ [entriesPropName]: this.entries
+ },
+ on: this.$listeners
+ }
return (
-
+
)
@@ -29,30 +37,32 @@ const withLoadMore = (Component, fetchEntries, getEntries) => {
},
computed: {
entries () {
- return getEntries(this.$props, this.$store) || []
+ return select(this.$props, this.$store) || []
}
},
created () {
window.addEventListener('scroll', this.scrollLoad)
if (this.entries.length === 0) {
- this.fetch()
+ this.fetchEntries()
}
},
destroyed () {
window.removeEventListener('scroll', this.scrollLoad)
},
methods: {
- fetch () {
+ fetchEntries () {
if (!this.loading) {
this.loading = true
- fetchEntries(this.$props, this.$store).then((newEntries) => {
- this.error = false
- this.loading = false
- this.bottomedOut = !newEntries || newEntries.length === 0
- }).catch(() => {
- this.error = true
- this.loading = false
- })
+ this.error = false
+ fetch(this.$props, this.$store)
+ .then((newEntries) => {
+ this.loading = false
+ this.bottomedOut = isEmpty(newEntries)
+ })
+ .catch(() => {
+ this.loading = false
+ this.error = true
+ })
}
},
scrollLoad (e) {
@@ -63,7 +73,7 @@ const withLoadMore = (Component, fetchEntries, getEntries) => {
this.$el.offsetHeight > 0 &&
(window.innerHeight + window.pageYOffset) >= (height - 750)
) {
- this.fetch()
+ this.fetchEntries()
}
}
}
From 159e84532ebdae038e1263efe8832015597a5e20 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Wed, 13 Feb 2019 21:07:28 -0500
Subject: [PATCH 10/29] Add withSubscription hoc
---
.../with_subscription/with_subscription.js | 65 +++++++++++++++++++
.../with_subscription/with_subscription.scss | 10 +++
2 files changed, 75 insertions(+)
create mode 100644 src/hocs/with_subscription/with_subscription.js
create mode 100644 src/hocs/with_subscription/with_subscription.scss
diff --git a/src/hocs/with_subscription/with_subscription.js b/src/hocs/with_subscription/with_subscription.js
new file mode 100644
index 00000000..31fc106f
--- /dev/null
+++ b/src/hocs/with_subscription/with_subscription.js
@@ -0,0 +1,65 @@
+import Vue from 'vue'
+import filter from 'lodash/filter'
+import isEmpty from 'lodash/isEmpty'
+import './with_subscription.scss'
+
+const withSubscription = (Component, fetch, select, contentPropName = 'content') => {
+ const originalProps = Component.props || []
+ const props = filter(originalProps, v => v !== 'content')
+
+ return Vue.component('withSubscription', {
+ render (createElement) {
+ const props = {
+ props: {
+ ...this.$props,
+ [contentPropName]: this.fetchedData
+ },
+ on: this.$listeners
+ }
+ return (
+
+
+
+
+ )
+ },
+ props,
+ data () {
+ return {
+ loading: false,
+ error: false
+ }
+ },
+ computed: {
+ fetchedData () {
+ return select(this.$props, this.$store)
+ }
+ },
+ created () {
+ if (isEmpty(this.fetchedData)) {
+ this.fetchData()
+ }
+ },
+ methods: {
+ fetchData () {
+ if (!this.loading) {
+ this.loading = true
+ this.error = false
+ fetch(this.$props, this.$store)
+ .then(() => {
+ this.loading = false
+ })
+ .catch(() => {
+ this.error = true
+ this.loading = false
+ })
+ }
+ }
+ }
+ })
+}
+
+export default withSubscription
diff --git a/src/hocs/with_subscription/with_subscription.scss b/src/hocs/with_subscription/with_subscription.scss
new file mode 100644
index 00000000..5114029d
--- /dev/null
+++ b/src/hocs/with_subscription/with_subscription.scss
@@ -0,0 +1,10 @@
+.with-subscription {
+ &-footer {
+ padding: 10px;
+ text-align: center;
+ }
+
+ .error {
+ font-size: 14px;
+ }
+}
\ No newline at end of file
From 8c8a6edc7800bac854ef23f29aa87f5b932cb415 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Wed, 13 Feb 2019 21:08:14 -0500
Subject: [PATCH 11/29] Remove pagination support from block-list
---
src/components/user_settings/user_settings.js | 10 ++++++----
src/components/user_settings/user_settings.vue | 2 +-
src/modules/users.js | 17 ++++++-----------
.../entity_normalizer.service.js | 2 +-
4 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js
index 621dcd4b..8eade382 100644
--- a/src/components/user_settings/user_settings.js
+++ b/src/components/user_settings/user_settings.js
@@ -7,13 +7,15 @@ 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 withSubscription from '../../hocs/with_subscription/with_subscription'
import withList from '../../hocs/with_list/with_list'
-const BlockList = withList(BlockCard, entry => ({ userId: entry.id }))
-const BlockListWithLoadMore = withLoadMore(
+const BlockList = withList(BlockCard, userId => ({ userId }))
+const BlockListWithSubscription = withSubscription(
BlockList,
(props, $store) => $store.dispatch('fetchBlocks'),
- (props, $store) => get($store.state.users.currentUser, 'blocks', [])
+ (props, $store) => get($store.state.users.currentUser, 'blockIds', []),
+ 'entries'
)
const UserSettings = {
@@ -53,7 +55,7 @@ const UserSettings = {
StyleSwitcher,
TabSwitcher,
ImageCropper,
- 'block-list': BlockListWithLoadMore
+ 'block-list': BlockListWithSubscription
},
computed: {
user () {
diff --git a/src/components/user_settings/user_settings.vue b/src/components/user_settings/user_settings.vue
index be9f27e7..5cf21815 100644
--- a/src/components/user_settings/user_settings.vue
+++ b/src/components/user_settings/user_settings.vue
@@ -164,7 +164,7 @@