refs #1713 Support to add bookmark
This commit is contained in:
parent
aec86a85d2
commit
1ecb52f2a9
|
@ -76,6 +76,7 @@ const status1: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
@ -110,6 +111,7 @@ const status2: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
|
|
@ -90,6 +90,7 @@ const status1: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
const status2: Entity.Status = {
|
||||
|
@ -123,6 +124,7 @@ const status2: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ const status1: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
const status2: Entity.Status = {
|
||||
|
@ -109,6 +110,7 @@ const status2: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ const status1: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
const status2: Entity.Status = {
|
||||
|
@ -108,6 +109,7 @@ const status2: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
|
|
@ -77,6 +77,7 @@ const status1: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
@ -111,6 +112,7 @@ const status2: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ const status1: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
const status2: Entity.Status = {
|
||||
|
@ -108,6 +109,7 @@ const status2: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ const status: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
|
|
@ -98,6 +98,7 @@ const status1: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
@ -132,6 +133,7 @@ const status2: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
@ -166,6 +168,7 @@ const rebloggedStatus: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ const status1: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
const status2: Entity.Status = {
|
||||
|
@ -108,6 +109,7 @@ const status2: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
|
|
@ -80,6 +80,7 @@ const status: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ const status1: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
const status2: Entity.Status = {
|
||||
|
@ -86,6 +87,7 @@ const status2: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
@ -120,6 +122,7 @@ const rebloggedStatus: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ const status1: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
const status2: Entity.Status = {
|
||||
|
@ -86,6 +87,7 @@ const status2: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
@ -120,6 +122,7 @@ const rebloggedStatus: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ const status1: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
const status2: Entity.Status = {
|
||||
|
@ -86,6 +87,7 @@ const status2: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
@ -289,6 +291,7 @@ describe('TimelineSpace/Contents/Home', () => {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
const favouritedStatus: Entity.Status = Object.assign(status1, {
|
||||
|
@ -365,6 +368,7 @@ describe('TimelineSpace/Contents/Home', () => {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
state = {
|
||||
|
|
|
@ -53,6 +53,7 @@ const status1: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
const status2: Entity.Status = {
|
||||
|
@ -86,6 +87,7 @@ const status2: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
@ -120,6 +122,7 @@ const rebloggedStatus: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ const status1: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
const status2: Entity.Status = {
|
||||
|
@ -86,6 +87,7 @@ const status2: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
@ -120,6 +122,7 @@ const rebloggedStatus: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ const status1: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
@ -110,6 +111,7 @@ const status2: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
@ -144,6 +146,7 @@ const rebloggedStatus: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ const status1: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
@ -110,6 +111,7 @@ const status2: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
@ -144,6 +146,7 @@ const rebloggedStatus: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ const status1: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
const status2: Entity.Status = {
|
||||
|
@ -86,6 +87,7 @@ const status2: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
@ -120,6 +122,7 @@ const rebloggedStatus: Entity.Status = {
|
|||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
|
|
|
@ -327,7 +327,7 @@
|
|||
"reblog": "Reblog",
|
||||
"fav": "Favourite",
|
||||
"detail": "Toot details",
|
||||
"bookmark": "Add bookmark",
|
||||
"bookmark": "Bookmark",
|
||||
"pinned": "Pinned toot",
|
||||
"poll": {
|
||||
"vote": "Vote",
|
||||
|
@ -424,6 +424,8 @@
|
|||
"unreblog_error": "Failed to unreblog",
|
||||
"favourite_error": "Failed to favourite",
|
||||
"unfavourite_error": "Failed to unfavourite",
|
||||
"bookmark_error": "Failed to bookmark",
|
||||
"unbookmark_error": "Failed to remove bookmark",
|
||||
"delete_error": "Failed to delete the toot",
|
||||
"search_error": "Failed to search",
|
||||
"toot_error": "Failed to toot",
|
||||
|
|
|
@ -168,7 +168,8 @@
|
|||
{{ favouritesCount }}
|
||||
</span>
|
||||
<el-button
|
||||
class="bookmark"
|
||||
@click="changeBookmark(originalMessage)"
|
||||
:class="originalMessage.bookmarked ? 'bookmarked' : 'bookmark'"
|
||||
type="text"
|
||||
:text="$t('cards.toot.bookmark')"
|
||||
:aria-label="$t('cards.toot.bookmark')"
|
||||
|
@ -574,6 +575,35 @@ export default {
|
|||
})
|
||||
}
|
||||
},
|
||||
changeBookmark(message) {
|
||||
if (message.bookmarked) {
|
||||
this.$store
|
||||
.dispatch('organisms/Toot/removeBookmark', message)
|
||||
.then(data => {
|
||||
this.$emit('update', data)
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err)
|
||||
this.$message({
|
||||
message: this.$t('message.unbookmark_error'),
|
||||
type: 'error'
|
||||
})
|
||||
})
|
||||
} else {
|
||||
this.$store
|
||||
.dispatch('organisms/Toot/addBookmark', message)
|
||||
.then(data => {
|
||||
this.$emit('update', data)
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err)
|
||||
this.$message({
|
||||
message: this.$t('message.bookmark_error'),
|
||||
type: 'error'
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
openImage(url, rawMediaList) {
|
||||
const mediaList = rawMediaList.map(media => {
|
||||
return media.url
|
||||
|
|
|
@ -46,7 +46,7 @@ const actions: ActionTree<TootState, RootState> = {
|
|||
dispatch('TimelineSpace/updateTootForAllTimelines', res.data, { root: true })
|
||||
return res.data
|
||||
},
|
||||
addFavourite: async ({ rootState, dispatch }, message: Entity.Status) => {
|
||||
addFavourite: async ({ rootState, dispatch }, message: Entity.Status): Promise<Entity.Status> => {
|
||||
const client = generator(
|
||||
rootState.TimelineSpace.sns,
|
||||
rootState.TimelineSpace.account.baseURL,
|
||||
|
@ -58,7 +58,7 @@ const actions: ActionTree<TootState, RootState> = {
|
|||
dispatch('TimelineSpace/updateTootForAllTimelines', res.data, { root: true })
|
||||
return res.data
|
||||
},
|
||||
removeFavourite: async ({ rootState, dispatch }, message: Entity.Status) => {
|
||||
removeFavourite: async ({ rootState, dispatch }, message: Entity.Status): Promise<Entity.Status> => {
|
||||
const client = generator(
|
||||
rootState.TimelineSpace.sns,
|
||||
rootState.TimelineSpace.account.baseURL,
|
||||
|
@ -69,6 +69,29 @@ const actions: ActionTree<TootState, RootState> = {
|
|||
dispatch('TimelineSpace/updateTootForAllTimelines', res.data, { root: true })
|
||||
return res.data
|
||||
},
|
||||
addBookmark: async ({ rootState, dispatch }, message: Entity.Status): Promise<Entity.Status> => {
|
||||
const client = generator(
|
||||
rootState.TimelineSpace.sns,
|
||||
rootState.TimelineSpace.account.baseURL,
|
||||
rootState.TimelineSpace.account.accessToken,
|
||||
rootState.App.userAgent
|
||||
)
|
||||
const res = await client.bookmarkStatus(message.id)
|
||||
win.ipcRenderer.send('fav-rt-action-sound')
|
||||
dispatch('TimelineSpace/updateTootForAllTimelines', res.data, { root: true })
|
||||
return res.data
|
||||
},
|
||||
removeBookmark: async ({ rootState, dispatch }, message: Entity.Status): Promise<Entity.Status> => {
|
||||
const client = generator(
|
||||
rootState.TimelineSpace.sns,
|
||||
rootState.TimelineSpace.account.baseURL,
|
||||
rootState.TimelineSpace.account.accessToken,
|
||||
rootState.App.userAgent
|
||||
)
|
||||
const res = await client.unbookmarkStatus(message.id)
|
||||
dispatch('TimelineSpace/updateTootForAllTimelines', res.data, { root: true })
|
||||
return res.data
|
||||
},
|
||||
deleteToot: async ({ rootState }, message: Entity.Status) => {
|
||||
const client = generator(
|
||||
rootState.TimelineSpace.sns,
|
||||
|
|
Loading…
Reference in New Issue