Make DebugModal available in search and timeline

This commit is contained in:
Peter Stuifzand 2021-05-31 22:51:35 +02:00
parent d0423c2dab
commit 8e739e841f
5 changed files with 31 additions and 14 deletions

View File

@ -25,7 +25,7 @@
}, },
methods: { methods: {
close() { close() {
this.$emit('close') this.$store.dispatch('closeDebug')
} }
} }
} }
@ -33,4 +33,4 @@
<style scoped> <style scoped>
</style> </style>

View File

@ -17,7 +17,7 @@
</div> </div>
<div class="timeline--item" v-for="item in searchItems" :key="item.id"> <div class="timeline--item" v-for="item in searchItems" :key="item.id">
<TimelineEntry :item="item" :is-main-entry="true" /> <TimelineEntry :item="item" :is-main-entry="true" @debug="debug" />
</div> </div>
</div> </div>
</div> </div>
@ -65,6 +65,9 @@ export default {
close () { close () {
this.$store.dispatch('closeSearch') this.$store.dispatch('closeSearch')
this.query = '' this.query = ''
},
debug (item) {
this.$store.dispatch('openDebug', item)
} }
} }
} }

View File

@ -12,23 +12,19 @@
<button class="button" @click="nextPage" v-if="timeline.paging.after">Next Page</button> <button class="button" @click="nextPage" v-if="timeline.paging.after">Next Page</button>
</div> </div>
</div> </div>
<DebugModal :active="showDebug" :item="debugItem" @close="showDebug = false"></DebugModal>
</div> </div>
</template> </template>
<script> <script>
import TimelineEntry from '../components/Entry' import TimelineEntry from '../components/Entry'
import DebugModal from '../components/DebugModal'
export default { export default {
name: "Timeline", name: "Timeline",
props: ['className', 'channel', 'timeline'], props: ['className', 'channel', 'timeline'],
components: {TimelineEntry, DebugModal}, components: {TimelineEntry},
data() { data() {
return { return {
showDebug: false,
debugItem: null,
state: 'new' state: 'new'
} }
}, },
@ -43,8 +39,7 @@
methods: { methods: {
debug(item) { debug(item) {
this.debugItem = item this.$store.dispatch('openDebug', item)
this.showDebug = true
}, },
nextPage() { nextPage() {
if (this.timeline.paging.after) { if (this.timeline.paging.after) {

View File

@ -12,7 +12,6 @@ export default new Vuex.Store({
channels: [], channels: [],
timeline: {items: [], paging: {}}, timeline: {items: [], paging: {}},
channel: {}, channel: {},
debug: false,
logged_in: false, logged_in: false,
micropubEndpoint: '', micropubEndpoint: '',
microsubEndpoint: '/microsub', microsubEndpoint: '/microsub',
@ -20,7 +19,10 @@ export default new Vuex.Store({
searchPopupIsOpen: false, searchPopupIsOpen: false,
searchItems: [], searchItems: [],
eventSource: null, eventSource: null,
globalTimeline: {items: [{name: 'Testing the global timeline'}]} globalTimeline: {items: [{name: 'Testing the global timeline'}]},
debug: false,
debugItem: {},
debugVisible: false
}; };
let loginData = JSON.parse(window.localStorage.getItem('login_data')) let loginData = JSON.parse(window.localStorage.getItem('login_data'))
if (loginData) { if (loginData) {
@ -147,6 +149,13 @@ export default new Vuex.Store({
}, },
newSearchResults(state, items) { newSearchResults(state, items) {
state.searchItems = items state.searchItems = items
},
openDebugPopup(state, item) {
state.debugItem = item
state.debugVisible = true
},
closeDebugPopup(state) {
state.debugVisible = false
} }
}, },
@ -295,6 +304,12 @@ export default new Vuex.Store({
}, },
startEventListening({commit}, url) { startEventListening({commit}, url) {
commit('createEventSource', url) commit('createEventSource', url)
} },
openDebug({commit}, item) {
return commit('openDebugPopup', item)
},
closeDebug({commit}) {
return commit('closeDebugPopup')
},
} }
}) })

View File

@ -34,6 +34,8 @@
<channel-creator :is-open="this.$store.state.channelCreatorIsOpen"></channel-creator> <channel-creator :is-open="this.$store.state.channelCreatorIsOpen"></channel-creator>
<feed-follower :is-open="feedFollowerIsOpen" @close="closeFeedFollower" :initial-channel="channel" :initial-query="feedFollowerQuery"></feed-follower> <feed-follower :is-open="feedFollowerIsOpen" @close="closeFeedFollower" :initial-channel="channel" :initial-query="feedFollowerQuery"></feed-follower>
<search-popup :is-open="searchPopupIsOpen"></search-popup> <search-popup :is-open="searchPopupIsOpen"></search-popup>
<DebugModal :active="this.$store.state.debugVisible"
:item="this.$store.state.debugItem"></DebugModal>
</div> </div>
</template> </template>
@ -46,6 +48,7 @@
import NewPost from "../components/NewPost" import NewPost from "../components/NewPost"
import ShortTimeline from "../components/ShortTimeline"; import ShortTimeline from "../components/ShortTimeline";
import SearchPopup from "../components/SearchPopup"; import SearchPopup from "../components/SearchPopup";
import DebugModal from "../components/DebugModal";
export default { export default {
name: 'home', name: 'home',
@ -57,7 +60,8 @@
ChannelCreator, ChannelCreator,
NewPost, NewPost,
ShortTimeline, ShortTimeline,
SearchPopup SearchPopup,
DebugModal
}, },
data() { data() {