diff --git a/src/renderer/components/TimelineSpace/Contents/Cards/Toot.vue b/src/renderer/components/TimelineSpace/Contents/Cards/Toot.vue index a95336df5c..8e7cf08b76 100644 --- a/src/renderer/components/TimelineSpace/Contents/Cards/Toot.vue +++ b/src/renderer/components/TimelineSpace/Contents/Cards/Toot.vue @@ -15,8 +15,8 @@
-
- +
+
@@ -181,13 +181,25 @@ export default { }) } }, - openImage (url) { - this.$store.dispatch('TimelineSpace/Modals/ImageViewer/openModal', url) + openImage (url, rawMediaList) { + const mediaList = rawMediaList.map((media) => { + return media.url + }) + const currentIndex = mediaList.indexOf(url) + this.$store.dispatch( + 'TimelineSpace/Modals/ImageViewer/openModal', + { + currentIndex: currentIndex, + mediaList: mediaList + }) }, openUser (account) { this.$store.dispatch('TimelineSpace/Contents/SideBar/openAccountComponent') this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/changeAccount', account) this.$store.commit('TimelineSpace/Contents/SideBar/changeOpenSideBar', true) + }, + mediaAttachements (message) { + return this.originalMessage(message).media_attachments } } } diff --git a/src/renderer/components/TimelineSpace/Modals/ImageViewer.vue b/src/renderer/components/TimelineSpace/Modals/ImageViewer.vue index 12066fe43c..0a331b0c94 100644 --- a/src/renderer/components/TimelineSpace/Modals/ImageViewer.vue +++ b/src/renderer/components/TimelineSpace/Modals/ImageViewer.vue @@ -6,7 +6,9 @@
+ +
@@ -20,9 +22,17 @@ export default { name: 'image-viewer', computed: { ...mapState({ - modalOpen: state => state.TimelineSpace.Modals.ImageViewer.modalOpen, - imageURL: state => state.TimelineSpace.Modals.ImageViewer.imageURL - }) + modalOpen: state => state.TimelineSpace.Modals.ImageViewer.modalOpen + }), + imageURL () { + return this.$store.getters['TimelineSpace/Modals/ImageViewer/imageURL'] + }, + isFirst () { + return this.$store.getters['TimelineSpace/Modals/ImageViewer/isFirst'] + }, + isLast () { + return this.$store.getters['TimelineSpace/Modals/ImageViewer/isLast'] + } }, updated () { if (this.modalOpen) { @@ -32,6 +42,12 @@ export default { methods: { close () { this.$store.dispatch('TimelineSpace/Modals/ImageViewer/closeModal') + }, + decrementIndex () { + this.$store.dispatch('TimelineSpace/Modals/ImageViewer/decrementIndex') + }, + incrementIndex () { + this.$store.dispatch('TimelineSpace/Modals/ImageViewer/incrementIndex') } } } @@ -80,4 +96,12 @@ export default { .image-viewer-enter, .image-viewer-leave-to { opacity: 0; } +.button-area { + display: inline-block; + width: 52px; + height: 77px; + i { + font-size: 50px; + } +} diff --git a/src/renderer/store/TimelineSpace/Modals/ImageViewer.js b/src/renderer/store/TimelineSpace/Modals/ImageViewer.js index 016d3d474a..7c6128002e 100644 --- a/src/renderer/store/TimelineSpace/Modals/ImageViewer.js +++ b/src/renderer/store/TimelineSpace/Modals/ImageViewer.js @@ -2,24 +2,53 @@ const ImageViewer = { namespaced: true, state: { modalOpen: false, - imageURL: '' + currentIndex: 0, + mediaList: [] }, mutations: { changeModal (state, value) { state.modalOpen = value }, - changeImageURL (state, url) { - state.imageURL = url + changeCurrentIndex (state, currentIndex) { + state.currentIndex = currentIndex + }, + changeMedliaList (state, mediaList) { + state.mediaList = mediaList + }, + incrementIndex (state) { + state.currentIndex++ + }, + decrementIndex (state) { + state.currentIndex-- } }, actions: { - openModal ({ commit }, url) { + openModal ({ commit }, { currentIndex, mediaList }) { commit('changeModal', true) - commit('changeImageURL', url) + commit('changeCurrentIndex', currentIndex) + commit('changeMedliaList', mediaList) }, closeModal ({ commit }) { commit('changeModal', false) - commit('changeImageURL', '') + commit('changeCurrentIndex', 0) + commit('changeMedliaList', []) + }, + incrementIndex ({ commit }) { + commit('incrementIndex') + }, + decrementIndex ({ commit }) { + commit('decrementIndex') + } + }, + getters: { + imageURL (state) { + return state.mediaList[state.currentIndex] + }, + isFirst (state) { + return state.currentIndex === 0 && state.mediaList.length > 1 + }, + isLast (state) { + return state.currentIndex === (state.mediaList.length - 1) && state.mediaList.length > 1 } } }