Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Allow user view toot detail at sidebar #206

Merged
merged 12 commits into from
Apr 12, 2018
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"vue": "^2.3.3",
"vue-awesome": "^2.3.5",
"vue-electron": "^1.0.6",
"vue-js-popover": "^1.1.7",
"vue-router": "^2.5.3",
"vue-shortkey": "^3.1.0",
"vuex": "^2.3.1"
Expand Down
39 changes: 38 additions & 1 deletion src/renderer/components/TimelineSpace/Contents/Cards/Toot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="icon">
<img :src="originalMessage(message).account.avatar" @click="openUser(originalMessage(message).account)"/>
</div>
<div class="detail">
<div class="detail" @click="openDetail(message)">
<div class="toot-header">
<div class="user" @click="openUser(originalMessage(message).account)">
{{ username(originalMessage(message).account) }}
Expand Down Expand Up @@ -38,6 +38,16 @@
<el-button type="text" @click="changeFavourite(originalMessage(message))" :class="originalMessage(message).favourited ? 'favourited' : 'favourite'">
<icon name="star" scale="0.9"></icon>
</el-button>
<el-button type="text" v-popover="{ name: message.id }">
<icon name="ellipsis-h" scale="0.9"></icon>
</el-button>
<popover :name="message.id" :width="120">
<ul class="toot-menu">
<li role="button" @click="openDetail(message)">
View Toot Detail
</li>
</ul>
</popover>
</div>
</div>
<div class="clearfix"></div>
Expand Down Expand Up @@ -79,6 +89,11 @@ export default {
openReply (message) {
this.$store.dispatch('TimelineSpace/Modals/NewToot/openReply', message)
},
openDetail (message) {
this.$store.dispatch('TimelineSpace/Contents/SideBar/openTootComponent')
this.$store.dispatch('TimelineSpace/Contents/SideBar/TootDetail/changeToot', message)
this.$store.commit('TimelineSpace/Contents/SideBar/changeOpenSideBar', true)
},
changeReblog (message) {
if (message.reblogged) {
this.$store.dispatch('TimelineSpace/Contents/Cards/Toot/unreblog', message)
Expand Down Expand Up @@ -247,6 +262,28 @@ function findLink (target) {
.favourited {
color: #e6a23c;
}

.toot-menu{
padding: 0;
font-size: 0.8em;
margin-left: 0.5em;
list-style-type: none;
text-align: center;

li{
padding-bottom: 0.5em;
border-bottom: 1px solid #ddd;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want the cursor to be a pointer when a mouse points over this object. What do you think?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think so too. I added the toot menu but forgot to change the cursor to pointer, sorry : (

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New commit added &:hover{ cursor: pointer; } to toot menu item.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!


&:hover{
cursor: pointer;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😆

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see Σ(;゚д゚)
It's look like so interesting.

}

&:last-child{
border: 0;
padding: 0;
}
}
}
}

.reply:hover,
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/components/TimelineSpace/Contents/SideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
<i class="el-icon-close" @click="close"></i>
</div>
<account-profile v-if="component === 1"></account-profile>
<toot-detail v-if="component === 2"></toot-detail>
</div>
</template>

<script>
import { mapState } from 'vuex'
import TootDetail from './SideBar/TootDetail'
import AccountProfile from './SideBar/AccountProfile'

export default {
name: 'side-bar',
components: {
TootDetail,
AccountProfile
},
computed: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<template>
<div class="toot-detail" ref="detail">
<div class="toot-ancestors" v-for="(message, index) in ancestors" v-bind:key="'ancestors-' + index">
<toot :message="message"></toot>
</div>
<div class="original-toot" ref="original">
<toot :message="message"></toot>
</div>
<div class="toot-descendants" v-for="(message, index) in descendants" v-bind:key="'descendants' + index">
<toot :message="message"></toot>
</div>
</div>
</template>

<script>
import { mapState } from 'vuex'
import Toot from '../Cards/Toot'

export default {
name: 'toot-detail',
components: { Toot },
computed: {
...mapState({
message: state => state.TimelineSpace.Contents.SideBar.TootDetail.message,
ancestors: state => state.TimelineSpace.Contents.SideBar.TootDetail.ancestors,
descendants: state => state.TimelineSpace.Contents.SideBar.TootDetail.descendants
})
},
created () {
this.load()
},
watch: {
message: function () {
this.load()
}
},
methods: {
load () {
this.$store.dispatch('TimelineSpace/Contents/SideBar/TootDetail/fetchToot', this.message)
.then(() => {
const toot = this.$refs.original
toot.scrollIntoView()
})
.catch(() => {
this.$message({
message: 'Could not fetch toot detail',
type: 'error'
})
})
}
}
}
</script>

<style lang="scss" scoped>
.original-toot{
.toot{
background-color: #f2f6fc;
outline: 0;
}
}
</style>
2 changes: 2 additions & 0 deletions src/renderer/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Vue from 'vue'
import axios from 'axios'
import ElementUI from 'element-ui'
import Popover from 'vue-js-popover'
import 'element-ui/lib/theme-chalk/index.css'
import 'vue-awesome/icons'
import Icon from 'vue-awesome/components/Icon'
Expand All @@ -11,6 +12,7 @@ import router from './router'
import store from './store'

Vue.use(ElementUI)
Vue.use(Popover)
Vue.component('icon', Icon)

if (!process.env.IS_WEB) Vue.use(require('vue-electron'))
Expand Down
8 changes: 7 additions & 1 deletion src/renderer/store/TimelineSpace/Contents/SideBar.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import AccountProfile from './SideBar/AccountProfile'
import TootDetail from './SideBar/TootDetail'

const SideBar = {
namespaced: true,
modules: {
AccountProfile
AccountProfile,
TootDetail
},
state: {
openSideBar: false,
// 0: blank
// 1: account-profile
// 2: toot-detail
component: 0
},
mutations: {
Expand All @@ -26,6 +29,9 @@ const SideBar = {
},
openAccountComponent ({ commit }) {
commit('changeComponent', 1)
},
openTootComponent ({ commit }) {
commit('changeComponent', 2)
}
}
}
Expand Down
43 changes: 43 additions & 0 deletions src/renderer/store/TimelineSpace/Contents/SideBar/TootDetail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import Mastodon from 'mastodon-api'

const TootDetail = {
namespaced: true,
state: {
message: null,
ancestors: [],
descendants: []
},
mutations: {
changeToot (state, message) {
state.message = message
},
updateAncestors (state, ancestors) {
state.ancestors = ancestors
},
updateDescendants (state, descendants) {
state.descendants = descendants
}
},
actions: {
changeToot ({ commit, dispatch }, message) {
commit('changeToot', message)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

},
fetchToot ({ state, commit, rootState }, message) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'concise methods' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
'destructuring binding' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

return new Promise((resolve, reject) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').
'Promise' is not defined.

const client = new Mastodon(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

{
access_token: rootState.TimelineSpace.account.accessToken,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identifier 'access_token' is not in camel case.

api_url: rootState.TimelineSpace.account.baseURL + '/api/v1'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identifier 'api_url' is not in camel case.

})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

client.get(`/statuses/${message.id}/context`, { limit: 40 }, (err, data, res) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long.
'template literal syntax' is only available in ES6 (use 'esversion: 6').
'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').

if (err) return reject(err)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected '{' and instead saw 'return'.
Missing semicolon.

commit('updateAncestors', data.ancestors)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

commit('updateDescendants', data.descendants)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

resolve(res)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

}
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.


export default TootDetail

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'export' is only available in ES6 (use 'esversion: 6').
Missing semicolon.