fixed tests, review fixes, now storing local users with downcase screen name for
better compatibility
This commit is contained in:
parent
489f840d84
commit
06d39b62a8
@ -68,7 +68,7 @@ const UserProfile = {
|
|||||||
},
|
},
|
||||||
userInStore () {
|
userInStore () {
|
||||||
const routeParams = this.$route.params
|
const routeParams = this.$route.params
|
||||||
return this.$store.getters.findUser(routeParams.name || routeParams.iid)
|
return this.$store.getters.findUser(routeParams.name || routeParams.id)
|
||||||
},
|
},
|
||||||
user () {
|
user () {
|
||||||
if (this.timeline.statuses[0]) {
|
if (this.timeline.statuses[0]) {
|
||||||
@ -135,13 +135,14 @@ const UserProfile = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
userId (newVal, oldVal) {
|
// userId can be undefined if we don't know it yet
|
||||||
|
userId (newVal) {
|
||||||
if (newVal) {
|
if (newVal) {
|
||||||
this.cleanUp()
|
this.cleanUp()
|
||||||
this.startUp()
|
this.startUp()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
userName (newVal, oldVal) {
|
userName () {
|
||||||
if (this.$route.params.name) {
|
if (this.$route.params.name) {
|
||||||
this.fetchUserId()
|
this.fetchUserId()
|
||||||
this.cleanUp()
|
this.cleanUp()
|
||||||
|
@ -73,7 +73,7 @@ const mergeOrAdd = (arr, obj, item) => {
|
|||||||
if (oldItem) {
|
if (oldItem) {
|
||||||
// We already have this, so only merge the new info.
|
// We already have this, so only merge the new info.
|
||||||
// We ignore null values to avoid overwriting existing properties with missing data
|
// We ignore null values to avoid overwriting existing properties with missing data
|
||||||
// we also skip 'used' because that is handled by users module
|
// we also skip 'user' because that is handled by users module
|
||||||
merge(oldItem, omitBy(item, (v, k) => v === null || k === 'user'))
|
merge(oldItem, omitBy(item, (v, k) => v === null || k === 'user'))
|
||||||
// Reactivity fix.
|
// Reactivity fix.
|
||||||
oldItem.attachments.splice(oldItem.attachments.length)
|
oldItem.attachments.splice(oldItem.attachments.length)
|
||||||
|
@ -18,7 +18,7 @@ export const mergeOrAdd = (arr, obj, item) => {
|
|||||||
arr.push(item)
|
arr.push(item)
|
||||||
obj[item.id] = item
|
obj[item.id] = item
|
||||||
if (item.screen_name && !item.screen_name.includes('@')) {
|
if (item.screen_name && !item.screen_name.includes('@')) {
|
||||||
obj[item.screen_name] = item
|
obj[item.screen_name.toLowerCase()] = item
|
||||||
}
|
}
|
||||||
return { item, new: true }
|
return { item, new: true }
|
||||||
}
|
}
|
||||||
@ -132,7 +132,7 @@ export const mutations = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const getters = {
|
export const getters = {
|
||||||
findUser: state => query => state.usersObject[query]
|
findUser: state => query => state.usersObject[typeof query === 'string' ? query.toLowerCase() : query]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const defaultState = {
|
export const defaultState = {
|
||||||
|
@ -12,6 +12,11 @@ const mutations = {
|
|||||||
setError: () => {}
|
setError: () => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const actions = {
|
||||||
|
fetchUser: () => {},
|
||||||
|
fetchUserByScreenName: () => {}
|
||||||
|
}
|
||||||
|
|
||||||
const testGetters = {
|
const testGetters = {
|
||||||
findUser: state => getters.findUser(state.users)
|
findUser: state => getters.findUser(state.users)
|
||||||
}
|
}
|
||||||
@ -30,6 +35,7 @@ const extUser = {
|
|||||||
|
|
||||||
const externalProfileStore = new Vuex.Store({
|
const externalProfileStore = new Vuex.Store({
|
||||||
mutations,
|
mutations,
|
||||||
|
actions,
|
||||||
getters: testGetters,
|
getters: testGetters,
|
||||||
state: {
|
state: {
|
||||||
api: {
|
api: {
|
||||||
@ -88,7 +94,7 @@ const externalProfileStore = new Vuex.Store({
|
|||||||
currentUser: {
|
currentUser: {
|
||||||
credentials: ''
|
credentials: ''
|
||||||
},
|
},
|
||||||
usersObject: [extUser],
|
usersObject: { 100: extUser },
|
||||||
users: [extUser]
|
users: [extUser]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -96,6 +102,7 @@ const externalProfileStore = new Vuex.Store({
|
|||||||
|
|
||||||
const localProfileStore = new Vuex.Store({
|
const localProfileStore = new Vuex.Store({
|
||||||
mutations,
|
mutations,
|
||||||
|
actions,
|
||||||
getters: testGetters,
|
getters: testGetters,
|
||||||
state: {
|
state: {
|
||||||
api: {
|
api: {
|
||||||
@ -154,14 +161,13 @@ const localProfileStore = new Vuex.Store({
|
|||||||
currentUser: {
|
currentUser: {
|
||||||
credentials: ''
|
credentials: ''
|
||||||
},
|
},
|
||||||
usersObject: [localUser],
|
usersObject: { 100: localUser, 'testuser': localUser },
|
||||||
users: [localUser]
|
users: [localUser]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// It's a little bit more complicated now
|
describe('UserProfile', () => {
|
||||||
describe.skip('UserProfile', () => {
|
|
||||||
it('renders external profile', () => {
|
it('renders external profile', () => {
|
||||||
const wrapper = mount(UserProfile, {
|
const wrapper = mount(UserProfile, {
|
||||||
localVue,
|
localVue,
|
||||||
|
@ -40,7 +40,7 @@ describe('The users module', () => {
|
|||||||
const state = {
|
const state = {
|
||||||
usersObject: {
|
usersObject: {
|
||||||
1: user,
|
1: user,
|
||||||
Guy: user
|
guy: user
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const name = 'Guy'
|
const name = 'Guy'
|
||||||
@ -53,7 +53,7 @@ describe('The users module', () => {
|
|||||||
const state = {
|
const state = {
|
||||||
usersObject: {
|
usersObject: {
|
||||||
1: user,
|
1: user,
|
||||||
Guy: user
|
guy: user
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const id = '1'
|
const id = '1'
|
||||||
|
Loading…
Reference in New Issue
Block a user