aboutsummaryrefslogtreecommitdiff
path: root/src/hocs/with_subscription/with_subscription.js
diff options
context:
space:
mode:
authorHenry Jameson <me@hjkos.com>2019-04-07 20:33:11 +0300
committerHenry Jameson <me@hjkos.com>2019-04-07 20:33:11 +0300
commit9108737d55300d8a4f822ba94335d8b53f04854d (patch)
tree76c51864a8f84edf260f2cf2fcf7625799f2533f /src/hocs/with_subscription/with_subscription.js
parent8c7f765dff8b66ff27aeeab5bc09cd715ab328a9 (diff)
Webpack 4, ESLint with Vue, Node-sass, updated dependencies overall. New linting.
Diffstat (limited to 'src/hocs/with_subscription/with_subscription.js')
-rw-r--r--src/hocs/with_subscription/with_subscription.js68
1 files changed, 34 insertions, 34 deletions
diff --git a/src/hocs/with_subscription/with_subscription.js b/src/hocs/with_subscription/with_subscription.js
index 679409cf..91fc4cca 100644
--- a/src/hocs/with_subscription/with_subscription.js
+++ b/src/hocs/with_subscription/with_subscription.js
@@ -4,10 +4,10 @@ import { getComponentProps } from '../../services/component_utils/component_util
import './with_subscription.scss'
const withSubscription = ({
- fetch, // function to fetch entries and return a promise
- select, // function to select data from store
- childPropName = 'content', // name of the prop to be passed into the wrapped component
- additionalPropNames = [] // additional prop name list of the wrapper component
+ fetch, // function to fetch entries and return a promise
+ select, // function to select data from store
+ childPropName = 'content', // name of the prop to be passed into the wrapped component
+ additionalPropNames = [] // additional prop name list of the wrapper component
}) => (WrappedComponent) => {
const originalProps = Object.keys(getComponentProps(WrappedComponent))
const props = originalProps.filter(v => v !== childPropName).concat(additionalPropNames)
@@ -15,37 +15,8 @@ const withSubscription = ({
return Vue.component('withSubscription', {
props: [
...props,
- 'refresh' // boolean saying to force-fetch data whenever created
+ 'refresh' // boolean saying to force-fetch data whenever created
],
- render (createElement) {
- if (!this.error && !this.loading) {
- const props = {
- props: {
- ...this.$props,
- [childPropName]: this.fetchedData
- },
- on: this.$listeners,
- scopedSlots: this.$scopedSlots
- }
- const children = Object.entries(this.$slots).map(([key, value]) => createElement('template', { slot: key }, value))
- return (
- <div class="with-subscription">
- <WrappedComponent {...props}>
- {children}
- </WrappedComponent>
- </div>
- )
- } else {
- return (
- <div class="with-subscription-loading">
- {this.error
- ? <a onClick={this.fetchData} class="alert error">{this.$t('general.generic_error')}</a>
- : <i class="icon-spin3 animate-spin"/>
- }
- </div>
- )
- }
- },
data () {
return {
loading: false,
@@ -77,6 +48,35 @@ const withSubscription = ({
})
}
}
+ },
+ render (createElement) {
+ if (!this.error && !this.loading) {
+ const props = {
+ props: {
+ ...this.$props,
+ [childPropName]: this.fetchedData
+ },
+ on: this.$listeners,
+ scopedSlots: this.$scopedSlots
+ }
+ const children = Object.entries(this.$slots).map(([key, value]) => createElement('template', { slot: key }, value))
+ return (
+ <div class="with-subscription">
+ <WrappedComponent {...props}>
+ {children}
+ </WrappedComponent>
+ </div>
+ )
+ } else {
+ return (
+ <div class="with-subscription-loading">
+ {this.error
+ ? <a onClick={this.fetchData} class="alert error">{this.$t('general.generic_error')}</a>
+ : <i class="icon-spin3 animate-spin"/>
+ }
+ </div>
+ )
+ }
}
})
}