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

closes #358 Open tag timeline page when click tag in toot #364

Merged
merged 3 commits into from
Jun 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<script>
import moment from 'moment'
import { shell } from 'electron'
import { findLink, isTag } from '../../../../utils/link'

export default {
name: 'favourite',
Expand All @@ -52,9 +53,14 @@ export default {
return moment(datetime).format('YYYY-MM-DD HH:mm:ss')
},
tootClick (e) {
if (isTag(e.target)) {
const tag = `/${this.$route.params.id}/hashtag/${e.target.innerText}`
this.$router.push({ path: tag })
return tag
}
const link = findLink(e.target)
if (link !== null) {
shell.openExternal(link)
return shell.openExternal(link)
}
},
openUser (account) {
Expand All @@ -64,19 +70,6 @@ export default {
}
}
}

function findLink (target) {
if (target.localName === 'a') {
return target.href
}
if (target.parentNode === undefined || target.parentNode === null) {
return null
}
if (target.parentNode.getAttribute('class') === 'favourite') {
return null
}
return findLink(target.parentNode)
}
</script>

<style lang="scss" scoped>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<script>
import moment from 'moment'
import { shell } from 'electron'
import { findLink, isTag } from '../../../../utils/link'

export default {
name: 'reblog',
Expand All @@ -52,9 +53,14 @@ export default {
return moment(datetime).format('YYYY-MM-DD HH:mm:ss')
},
tootClick (e) {
if (isTag(e.target)) {
const tag = `/${this.$route.params.id}/hashtag/${e.target.innerText}`
this.$router.push({ path: tag })
return tag
}
const link = findLink(e.target)
if (link !== null) {
shell.openExternal(link)
return shell.openExternal(link)
}
},
openUser (account) {
Expand All @@ -64,19 +70,6 @@ export default {
}
}
}

function findLink (target) {
if (target.localName === 'a') {
return target.href
}
if (target.parentNode === undefined || target.parentNode === null) {
return null
}
if (target.parentNode.getAttribute('class') === 'reblog') {
return null
}
return findLink(target.parentNode)
}
</script>

<style lang="scss" scoped>
Expand Down
21 changes: 7 additions & 14 deletions src/renderer/components/TimelineSpace/Contents/Cards/Toot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
import moment from 'moment'
import { shell, clipboard } from 'electron'
import { mapState } from 'vuex'
import { findLink, isTag } from '../../../utils/link'

export default {
name: 'toot',
Expand Down Expand Up @@ -155,9 +156,14 @@ export default {
return moment(datetime).format('YYYY-MM-DD HH:mm:ss')
},
tootClick (e) {
if (isTag(e.target)) {
const tag = `/${this.$route.params.id}/hashtag/${e.target.innerText}`
this.$router.push({ path: tag })
return tag
}
const link = findLink(e.target)
if (link !== null) {
shell.openExternal(link)
return shell.openExternal(link)
}
},
openReply (message) {
Expand Down Expand Up @@ -293,19 +299,6 @@ export default {
}
}
}

function findLink (target) {
if (target.localName === 'a') {
return target.href
}
if (target.parentNode === undefined || target.parentNode === null) {
return null
}
if (target.parentNode.getAttribute('class') === 'toot') {
return null
}
return findLink(target.parentNode)
}
</script>

<style lang="scss" scoped>
Expand Down
5 changes: 5 additions & 0 deletions src/renderer/components/TimelineSpace/Contents/Hashtag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ export default {
tag: ''
}
},
mounted () {
if (this.$route.name === 'tag') {
this.tag = this.$route.params.tag
}
},
watch: {
'$route': function (route) {
if (route.name === 'tag') {
Expand Down
25 changes: 25 additions & 0 deletions src/renderer/components/utils/link.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export function findLink (target) {
if (target.localName === 'a') {
return target.href
}
if (target.parentNode === undefined || target.parentNode === null) {
return null
}
if (target.parentNode.getAttribute('class') === 'toot') {
return null
}
return findLink(target.parentNode)
}

export function isTag (target) {
if (target.getAttribute('class') && target.getAttribute('class').includes('hashtag')) {
return true
}
if (target.parentNode === undefined || target.parentNode === null) {
return false
}
if (target.parentNode.getAttribute('class') === 'toot') {
return false
}
return isTag(target.parentNode)
}