refs #409 Fix findLink method to detect link, tag, and account
This commit is contained in:
parent
09615f01c1
commit
45f1ed5c00
|
@ -36,7 +36,7 @@
|
||||||
<script>
|
<script>
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import { shell } from 'electron'
|
import { shell } from 'electron'
|
||||||
import { findLink, isTag } from '../../../../utils/link'
|
import { findAccount, findLink, isTag } from '../../../../utils/link'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'favourite',
|
name: 'favourite',
|
||||||
|
@ -58,6 +58,23 @@ export default {
|
||||||
this.$router.push({ path: tag })
|
this.$router.push({ path: tag })
|
||||||
return 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)
|
const link = findLink(e.target)
|
||||||
if (link !== null) {
|
if (link !== null) {
|
||||||
return shell.openExternal(link)
|
return shell.openExternal(link)
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
<script>
|
<script>
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import { shell } from 'electron'
|
import { shell } from 'electron'
|
||||||
import { findLink, isTag } from '../../../../utils/link'
|
import { findAccount, findLink, isTag } from '../../../../utils/link'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'reblog',
|
name: 'reblog',
|
||||||
|
@ -58,6 +58,23 @@ export default {
|
||||||
this.$router.push({ path: tag })
|
this.$router.push({ path: tag })
|
||||||
return 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)
|
const link = findLink(e.target)
|
||||||
if (link !== null) {
|
if (link !== null) {
|
||||||
return shell.openExternal(link)
|
return shell.openExternal(link)
|
||||||
|
|
|
@ -5,7 +5,9 @@ export function findLink (target) {
|
||||||
if (target.parentNode === undefined || target.parentNode === null) {
|
if (target.parentNode === undefined || target.parentNode === null) {
|
||||||
return 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 null
|
||||||
}
|
}
|
||||||
return findLink(target.parentNode)
|
return findLink(target.parentNode)
|
||||||
|
@ -18,7 +20,9 @@ export function isTag (target) {
|
||||||
if (target.parentNode === undefined || target.parentNode === null) {
|
if (target.parentNode === undefined || target.parentNode === null) {
|
||||||
return false
|
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 false
|
||||||
}
|
}
|
||||||
return isTag(target.parentNode)
|
return isTag(target.parentNode)
|
||||||
|
@ -31,7 +35,9 @@ export function findAccount (target) {
|
||||||
if (target.parentNode === undefined || target.parentNode === null) {
|
if (target.parentNode === undefined || target.parentNode === null) {
|
||||||
return 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 null
|
||||||
}
|
}
|
||||||
return findAccount(target.parentNode)
|
return findAccount(target.parentNode)
|
||||||
|
|
Loading…
Reference in New Issue