refs #254 Allow delete toot in home
This commit is contained in:
parent
f2477a4762
commit
439966cbcb
|
@ -153,7 +153,7 @@ export default {
|
|||
})
|
||||
.catch(() => {
|
||||
this.$message({
|
||||
message: 'Faild to unreblog',
|
||||
message: 'Failed to unreblog',
|
||||
type: 'error'
|
||||
})
|
||||
})
|
||||
|
@ -164,7 +164,7 @@ export default {
|
|||
})
|
||||
.catch(() => {
|
||||
this.$message({
|
||||
message: 'Faild to reblog',
|
||||
message: 'Failed to reblog',
|
||||
type: 'error'
|
||||
})
|
||||
})
|
||||
|
@ -231,6 +231,16 @@ export default {
|
|||
return this.$store.state.TimelineSpace.account.accountId === this.originalMessage(message).account.id
|
||||
},
|
||||
deleteToot (message) {
|
||||
this.$store.dispatch('TimelineSpace/Contents/Cards/Toot/deleteToot', message)
|
||||
.then((message) => {
|
||||
this.$emit('delete', message)
|
||||
})
|
||||
.catch(() => {
|
||||
this.$message({
|
||||
message: 'Failed to delete the toot',
|
||||
type: 'error'
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div>
|
||||
<transition-group name="timeline" tag="div">
|
||||
<div class="home-timeline" v-for="(message, index) in timeline" v-bind:key="index">
|
||||
<toot :message="message" :key="message.id" v-on:update="updateToot"></toot>
|
||||
<toot :message="message" :key="message.id" v-on:update="updateToot" v-on:delete="deleteToot"></toot>
|
||||
</div>
|
||||
</transition-group>
|
||||
<div class="loading-card" v-loading="lazyLoading" :element-loading-background="backgroundColor">
|
||||
|
@ -67,6 +67,9 @@ export default {
|
|||
},
|
||||
updateToot (message) {
|
||||
this.$store.commit('TimelineSpace/Contents/Home/updateToot', message)
|
||||
},
|
||||
deleteToot (message) {
|
||||
this.$store.commit('TimelineSpace/Contents/Home/deleteToot', message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,20 @@ const Toot = {
|
|||
resolve(data)
|
||||
})
|
||||
})
|
||||
},
|
||||
deleteToot ({ 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.delete(`/statuses/${message.id}`, {}, (err, data, res) => {
|
||||
if (err) return reject(err)
|
||||
resolve(message)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,6 +55,15 @@ const Home = {
|
|||
return toot
|
||||
}
|
||||
})
|
||||
},
|
||||
deleteToot (state, message) {
|
||||
state.timeline = state.timeline.filter((toot) => {
|
||||
if (toot.reblog !== null && toot.reblog.id === message.id) {
|
||||
return false
|
||||
} else {
|
||||
return toot.id !== message.id
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
|
|
Loading…
Reference in New Issue