mirror of
https://github.com/h3poteto/whalebird-desktop
synced 2025-01-27 07:46:15 +01:00
Merge pull request #60 from h3poteto/iss-51
closes #51 Add favourite on toot
This commit is contained in:
commit
e0886921d8
@ -16,7 +16,7 @@
|
||||
<div class="tool-box">
|
||||
<el-button type="text"><icon name="reply" scale="0.9"></icon></el-button>
|
||||
<el-button type="text"><icon name="retweet" scale="0.9"></icon></el-button>
|
||||
<el-button type="text"><icon name="star" scale="0.9"></icon></el-button>
|
||||
<el-button type="text" @click="addFavourite(message)"><icon name="star" scale="0.9"></icon></el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
@ -40,6 +40,15 @@ export default {
|
||||
if (link !== null) {
|
||||
shell.openExternal(link)
|
||||
}
|
||||
},
|
||||
addFavourite (message) {
|
||||
this.$store.dispatch('TimelineSpace/Cards/Toot/addFavourite', message)
|
||||
.catch(() => {
|
||||
this.$message({
|
||||
message: 'Failed to favourite',
|
||||
type: 'error'
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import SideMenu from './TimelineSpace/SideMenu'
|
||||
import Favourites from './TimelineSpace/Favourites'
|
||||
import Local from './TimelineSpace/Local'
|
||||
import Public from './TimelineSpace/Public'
|
||||
import Cards from './TimelineSpace/Cards'
|
||||
import router from '../router'
|
||||
|
||||
const TimelineSpace = {
|
||||
@ -12,7 +13,8 @@ const TimelineSpace = {
|
||||
SideMenu,
|
||||
Favourites,
|
||||
Local,
|
||||
Public
|
||||
Public,
|
||||
Cards
|
||||
},
|
||||
state: {
|
||||
account: {
|
||||
|
10
src/renderer/store/TimelineSpace/Cards.js
Normal file
10
src/renderer/store/TimelineSpace/Cards.js
Normal file
@ -0,0 +1,10 @@
|
||||
import Toot from './Cards/Toot'
|
||||
|
||||
const Cards = {
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Toot
|
||||
}
|
||||
}
|
||||
|
||||
export default Cards
|
26
src/renderer/store/TimelineSpace/Cards/Toot.js
Normal file
26
src/renderer/store/TimelineSpace/Cards/Toot.js
Normal file
@ -0,0 +1,26 @@
|
||||
import Mastodon from 'mastodon-api'
|
||||
|
||||
const Toot = {
|
||||
namespaced: true,
|
||||
state: {},
|
||||
mutations: {},
|
||||
actions: {
|
||||
addFavourite ({ state, commit, rootState }, message) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const client = new Mastodon(
|
||||
{
|
||||
access_token: rootState.TimelineSpace.account.accessToken,
|
||||
api_url: rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||
}
|
||||
)
|
||||
client.post(`/statuses/${message.id}/favourite`, {}, (err, data, res) => {
|
||||
if (err) return reject(err)
|
||||
// TODO: update toot data
|
||||
resolve(res)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default Toot
|
Loading…
x
Reference in New Issue
Block a user