Merge pull request #410 from h3poteto/iss-409
closes #409 Fix findLink method to detect link, tag, and account
This commit is contained in:
commit
f229144f25
|
@ -36,7 +36,7 @@
|
|||
<script>
|
||||
import moment from 'moment'
|
||||
import { shell } from 'electron'
|
||||
import { findLink, isTag } from '../../../../utils/link'
|
||||
import { findAccount, findLink, isTag } from '../../../../utils/link'
|
||||
|
||||
export default {
|
||||
name: 'favourite',
|
||||
|
@ -58,6 +58,23 @@ export default {
|
|||
this.$router.push({ path: tag })
|
||||
return tag
|
||||
}
|
||||
const accountURL = findAccount(e.target)
|
||||
if (accountURL !== null) {
|
||||
this.$store.commit('TimelineSpace/Contents/SideBar/changeOpenSideBar', true)
|
||||
this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/searchAccount', accountURL)
|
||||
.then((account) => {
|
||||
this.$store.dispatch('TimelineSpace/Contents/SideBar/openAccountComponent')
|
||||
this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/changeAccount', account)
|
||||
})
|
||||
.catch(() => {
|
||||
this.$message({
|
||||
message: 'Account not found',
|
||||
type: 'error'
|
||||
})
|
||||
this.$store.commit('TimelineSpace/Contents/SideBar/changeOpenSideBar', false)
|
||||
})
|
||||
return accountURL
|
||||
}
|
||||
const link = findLink(e.target)
|
||||
if (link !== null) {
|
||||
return shell.openExternal(link)
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
<script>
|
||||
import moment from 'moment'
|
||||
import { shell } from 'electron'
|
||||
import { findLink, isTag } from '../../../../utils/link'
|
||||
import { findAccount, findLink, isTag } from '../../../../utils/link'
|
||||
|
||||
export default {
|
||||
name: 'reblog',
|
||||
|
@ -58,6 +58,23 @@ export default {
|
|||
this.$router.push({ path: tag })
|
||||
return tag
|
||||
}
|
||||
const accountURL = findAccount(e.target)
|
||||
if (accountURL !== null) {
|
||||
this.$store.commit('TimelineSpace/Contents/SideBar/changeOpenSideBar', true)
|
||||
this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/searchAccount', accountURL)
|
||||
.then((account) => {
|
||||
this.$store.dispatch('TimelineSpace/Contents/SideBar/openAccountComponent')
|
||||
this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/changeAccount', account)
|
||||
})
|
||||
.catch(() => {
|
||||
this.$message({
|
||||
message: 'Account not found',
|
||||
type: 'error'
|
||||
})
|
||||
this.$store.commit('TimelineSpace/Contents/SideBar/changeOpenSideBar', false)
|
||||
})
|
||||
return accountURL
|
||||
}
|
||||
const link = findLink(e.target)
|
||||
if (link !== null) {
|
||||
return shell.openExternal(link)
|
||||
|
|
|
@ -5,7 +5,9 @@ export function findLink (target) {
|
|||
if (target.parentNode === undefined || target.parentNode === null) {
|
||||
return null
|
||||
}
|
||||
if (target.parentNode.getAttribute('class') === 'toot') {
|
||||
if ((target.parentNode.getAttribute('class') === 'toot') ||
|
||||
(target.parentNode.getAttribute('class') === 'favourite') ||
|
||||
(target.parentNode.getAttribute('class') === 'reblog')) {
|
||||
return null
|
||||
}
|
||||
return findLink(target.parentNode)
|
||||
|
@ -18,7 +20,9 @@ export function isTag (target) {
|
|||
if (target.parentNode === undefined || target.parentNode === null) {
|
||||
return false
|
||||
}
|
||||
if (target.parentNode.getAttribute('class') === 'toot') {
|
||||
if ((target.parentNode.getAttribute('class') === 'toot') ||
|
||||
(target.parentNode.getAttribute('class') === 'favourite') ||
|
||||
(target.parentNode.getAttribute('class') === 'reblog')) {
|
||||
return false
|
||||
}
|
||||
return isTag(target.parentNode)
|
||||
|
@ -31,7 +35,9 @@ export function findAccount (target) {
|
|||
if (target.parentNode === undefined || target.parentNode === null) {
|
||||
return null
|
||||
}
|
||||
if (target.parentNode.getAttribute('class') === 'toot') {
|
||||
if ((target.parentNode.getAttribute('class') === 'toot') ||
|
||||
(target.parentNode.getAttribute('class') === 'favourite') ||
|
||||
(target.parentNode.getAttribute('class') === 'reblog')) {
|
||||
return null
|
||||
}
|
||||
return findAccount(target.parentNode)
|
||||
|
|
Loading…
Reference in New Issue