Skip to content

Commit

Permalink
Fix eslint, remove old-style test case
Browse files Browse the repository at this point in the history
  • Loading branch information
roschaefer committed Aug 23, 2018
1 parent 7755bb4 commit dc7f59c
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 113 deletions.
10 changes: 5 additions & 5 deletions components/mixins/blacklistable.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ export default {
currentUserSettings: 'feathers-vuex-usersettings/current',
blacklistPending: 'feathers-vuex-usersettings/isPending'
}),
isBlacklisted(){
isBlacklisted () {
return this.currentUserSettings.blacklist.includes(this.author()._id)
},
}
},
methods: {
async toggleBlacklist(){
let message;
async toggleBlacklist () {
let message
try {
await this.$store.dispatch('feathers-vuex-usersettings/toggleBlacklist', this.author())
const translationKey = `component.blacklist.${this.isBlacklisted ? 'blockSuccess' : 'unblockSuccess'}`
message = this.$t(translationKey, {
name: this.author().name || this.$t('component.contribution.creatorUnknown')
})
} catch(error) {
} catch (error) {
console.log(error)
message = String(error)
}
Expand Down
9 changes: 3 additions & 6 deletions helpers/createApiClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import socketio from '@feathersjs/socketio-client'
import io from 'socket.io-client'
import authentication from '@feathersjs/authentication-client'
import urlHelper from '~/helpers/urls'
import Cookie from 'cookie-universal';

import Cookie from 'cookie-universal'

const authKey = 'feathers-jwt'
const endpoint = urlHelper.buildEndpointURL(process.env.API_HOST, { port: process.env.API_PORT })
Expand All @@ -25,10 +24,8 @@ if (process.env.ENV === 'production') {
socket = socketio(io(endpoint))
}



let createApiClient = ({req, res}) => {
const cookies = Cookie(req, res);
const cookies = Cookie(req, res)
const storageMapping = {
getItem: (key) => {
const res = cookies.get(key)
Expand Down Expand Up @@ -62,7 +59,7 @@ let createApiClient = ({req, res}) => {
cookie: authKey
}))

return api;
return api
}

export default createApiClient
7 changes: 2 additions & 5 deletions plugins/api.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import feathers from '@feathersjs/feathers'
import feathersVuex from 'feathers-vuex'
import authentication from '@feathersjs/authentication-client'
import Vue from 'vue'
import Vuex from 'vuex'
import createApiClient from '../helpers/createApiClient'

export default ({app, store, env, redirect, router, req, res}) => {
const api = createApiClient({req, res});
const { service, auth: feathersVuexAuthentication, FeathersVuex } = feathersVuex(api, { idField: '_id' })
const api = createApiClient({req, res})
const { FeathersVuex } = feathersVuex(api, { idField: '_id' })

Vue.use(FeathersVuex)
Vue.use(Vuex)
Expand Down Expand Up @@ -76,7 +74,6 @@ export default ({app, store, env, redirect, router, req, res}) => {
api.channel('authenticated').join(connection)
})


// make the api accessible inside vue components
Vue.use({
install (Vue) {
Expand Down
6 changes: 3 additions & 3 deletions store/auth.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isEmpty } from 'lodash'

export default {
export default {
namespaced: true,
state: {
user: null,
Expand Down Expand Up @@ -89,7 +89,7 @@ export default {
}
commit('SET_USER', user)
}
dispatch('feathers-vuex-usersettings/loadCurrent', user, { root: true});
dispatch('feathers-vuex-usersettings/loadCurrent', user, { root: true })
return user
},
async checkAuth ({state, getters, commit, dispatch}) {
Expand Down Expand Up @@ -127,7 +127,7 @@ export default {
commit('SET_TOKEN', null)
const user = await this.app.$api.auth({strategy: 'local', email, password})

dispatch('feathers-vuex-usersettings/loadCurrent', user, { root: true});
dispatch('feathers-vuex-usersettings/loadCurrent', user, { root: true })

commit('SET_USER', user)

Expand Down
7 changes: 3 additions & 4 deletions store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ const requireModule = require.context(
/.js$/
)


const createStore = (ssrContext) => {
const feathersClient = createApiClient(ssrContext || {});
const { service, auth: feathersVuexAuthentication } = feathersVuex(feathersClient, { idField: '_id' })
const feathersClient = createApiClient(ssrContext || {})
const { auth: feathersVuexAuthentication } = feathersVuex(feathersClient, { idField: '_id' })
const servicePlugins = requireModule.keys().map(modulePath => requireModule(modulePath).default(feathersClient))

return new Vuex.Store({
Expand Down Expand Up @@ -58,7 +57,7 @@ const createStore = (ssrContext) => {
'auth-reset-token',
'pages-slug',
'test'
],
]
}
})
]
Expand Down
38 changes: 19 additions & 19 deletions store/services/usersettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,37 @@ let servicePlugin = (feathersClient) => {
getters: {
isPending: (state) => {
return (
state.current
|| state.isFindPending
|| state.isGetPending
|| state.isCreatePending
|| state.isUpdatePending
|| state.isPatchPending
|| state.isRemovePending
state.current ||
state.isFindPending ||
state.isGetPending ||
state.isCreatePending ||
state.isUpdatePending ||
state.isPatchPending ||
state.isRemovePending
)
}
},
actions: {
async loadCurrent({commit, dispatch}, user){
let userId = user._id;
async loadCurrent ({commit, dispatch}, user) {
let userId = user._id
let res = await dispatch('find', {
query: { userId }
})
if (res.data.length > 0){
if (res.data.length > 0) {
commit('setCurrent', res.data[0])
}
},
async toggleBlacklist({commit, dispatch, state}, author){
let current = state.copy;
let userId = author._id;
if (current.blacklist.includes(userId)){
current.blacklist = current.blacklist.filter(id => id !== userId);
async toggleBlacklist ({commit, dispatch, state}, author) {
let current = state.copy
let userId = author._id
if (current.blacklist.includes(userId)) {
current.blacklist = current.blacklist.filter(id => id !== userId)
} else {
current.blacklist.push(userId);
current.blacklist.push(userId)
}
await commit('commitCopy');
return dispatch('patch', [current._id, current, {}]);
},
await commit('commitCopy')
return dispatch('patch', [current._id, current, {}])
}
}
})
return servicePlugin
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/testAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ const testAction = async (action, payload, state, expectedMutations, testrunner)
testrunner.deepEqual(count, 0)
}
}
module.exports = { testAction };
module.exports = { testAction }
70 changes: 0 additions & 70 deletions test/store/blacklist.test.js

This file was deleted.

0 comments on commit dc7f59c

Please sign in to comment.