refs #202 Add lists channels in jump modal

This commit is contained in:
AkiraFukushima 2018-04-15 12:12:15 +09:00
parent 9bae1d3bd5
commit 3adbdcb3d4
2 changed files with 29 additions and 12 deletions

View File

@ -25,7 +25,9 @@ export default {
name: 'jump', name: 'jump',
computed: { computed: {
...mapState({ ...mapState({
channelList: state => state.TimelineSpace.Modals.Jump.channelList, channelList: (state) => {
return state.TimelineSpace.Modals.Jump.defaultChannelList.concat(state.TimelineSpace.Modals.Jump.listChannelList)
},
selectedChannel: state => state.TimelineSpace.Modals.Jump.selectedChannel selectedChannel: state => state.TimelineSpace.Modals.Jump.selectedChannel
}), }),
channel: { channel: {
@ -49,15 +51,18 @@ export default {
} }
}, },
watch: { watch: {
channel (newChannel, oldChannel) { channel: function (newChannel, oldChannel) {
this.$store.commit('TimelineSpace/Modals/Jump/changeSelected', this.filterChannelForm()[0]) this.$store.commit('TimelineSpace/Modals/Jump/changeSelected', this.filterChannelForm()[0])
} },
}, jumpModal: function (newModal, oldModal) {
updated () { if (!oldModal && newModal) {
if (this.jumpModal) { this.$nextTick(function () {
this.$refs.channel.focus() this.$store.dispatch('TimelineSpace/Modals/Jump/syncListChannel')
} else { this.$refs.channel.focus()
this.channel = '' })
} else {
this.channel = ''
}
} }
}, },
methods: { methods: {

View File

@ -5,7 +5,7 @@ const Jump = {
state: { state: {
modalOpen: false, modalOpen: false,
channel: '', channel: '',
channelList: [ defaultChannelList: [
{ {
name: 'Home', name: 'Home',
path: 'home' path: 'home'
@ -19,14 +19,15 @@ const Jump = {
path: 'favourites' path: 'favourites'
}, },
{ {
name: 'LocalTimeline', name: 'Local timeline',
path: 'local' path: 'local'
}, },
{ {
name: 'PublicTimeline', name: 'Public timeline',
path: 'public' path: 'public'
} }
], ],
listChannelList: [],
selectedChannel: { selectedChannel: {
name: 'Home', name: 'Home',
path: 'home' path: 'home'
@ -41,6 +42,14 @@ const Jump = {
}, },
changeSelected (state, value) { changeSelected (state, value) {
state.selectedChannel = value state.selectedChannel = value
},
updateListChannel (state, list) {
state.listChannelList = list.map((l) => {
return {
name: `#${l.title}`,
path: `lists/${l.id}`
}
})
} }
}, },
actions: { actions: {
@ -51,6 +60,9 @@ const Jump = {
jump ({ state, commit, rootState }, channel) { jump ({ state, commit, rootState }, channel) {
commit('changeModal', false) commit('changeModal', false)
router.push({ path: `/${rootState.TimelineSpace.account._id}/${channel.path}` }) router.push({ path: `/${rootState.TimelineSpace.account._id}/${channel.path}` })
},
syncListChannel ({ state, commit, rootState }) {
commit('updateListChannel', rootState.TimelineSpace.SideMenu.lists)
} }
} }
} }