add basic api support
This commit is contained in:
parent
e6ca489d30
commit
54ddda401c
5 changed files with 132 additions and 4 deletions
|
@ -20,6 +20,7 @@ import ChatPanel from 'components/chat_panel/chat_panel.vue'
|
|||
import WhoToFollow from 'components/who_to_follow/who_to_follow.vue'
|
||||
import About from 'components/about/about.vue'
|
||||
import RemoteUserResolver from 'components/remote_user_resolver/remote_user_resolver.vue'
|
||||
import Lists from 'components/lists/lists.vue'
|
||||
|
||||
export default (store) => {
|
||||
const validateAuthenticatedRoute = (to, from, next) => {
|
||||
|
@ -69,7 +70,8 @@ export default (store) => {
|
|||
{ name: 'search', path: '/search', component: Search, props: (route) => ({ query: route.query.query }) },
|
||||
{ name: 'who-to-follow', path: '/who-to-follow', component: WhoToFollow, beforeEnter: validateAuthenticatedRoute },
|
||||
{ name: 'about', path: '/about', component: About },
|
||||
{ name: 'user-profile', path: '/(users/)?:name', component: UserProfile }
|
||||
{ name: 'user-profile', path: '/(users/)?:name', component: UserProfile },
|
||||
{ name: 'lists', path: '/lists', component: Lists, beforeEnter: validateAuthenticatedRoute }
|
||||
]
|
||||
|
||||
if (store.state.instance.pleromaChatMessagesAvailable) {
|
||||
|
|
34
src/components/lists/lists.vue
Normal file
34
src/components/lists/lists.vue
Normal file
|
@ -0,0 +1,34 @@
|
|||
<template>
|
||||
<div class="Lists">
|
||||
<div
|
||||
v-for="list in lists"
|
||||
:key="list.id"
|
||||
>
|
||||
{{ list.title }}
|
||||
</div>
|
||||
<div
|
||||
v-if="lists.length === 0"
|
||||
class="list-empty-content faint"
|
||||
>
|
||||
No lists
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
lists: [{ title: 'ASD', id: '1' }, { title: 'ASD2', id: '2' }]
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
@import '../../_variables.scss';
|
||||
|
||||
.Lists {
|
||||
height: 10em;
|
||||
}
|
||||
</style>
|
|
@ -59,6 +59,15 @@
|
|||
/>{{ $t("nav.twkn") }}
|
||||
</router-link>
|
||||
</li>
|
||||
<li v-if="currentUser">
|
||||
<router-link :to="{ name: 'lists' }">
|
||||
<FAIcon
|
||||
fixed-width
|
||||
class="fa-scale-110 fa-old-padding "
|
||||
icon="globe"
|
||||
/>{{ $t("nav.lists") }}
|
||||
</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div
|
||||
|
|
|
@ -126,7 +126,8 @@
|
|||
"who_to_follow": "Who to follow",
|
||||
"preferences": "Preferences",
|
||||
"timelines": "Timelines",
|
||||
"chats": "Chats"
|
||||
"chats": "Chats",
|
||||
"lists": "Lists"
|
||||
},
|
||||
"notifications": {
|
||||
"broken_favorite": "Unknown status, searching for it…",
|
||||
|
|
|
@ -79,6 +79,9 @@ const MASTODON_USER_SEARCH_URL = '/api/v1/accounts/search'
|
|||
const MASTODON_DOMAIN_BLOCKS_URL = '/api/v1/domain_blocks'
|
||||
const MASTODON_STREAMING = '/api/v1/streaming'
|
||||
const MASTODON_KNOWN_DOMAIN_LIST_URL = '/api/v1/instance/peers'
|
||||
const MASTODON_LISTS_URL = '/api/v1/lists'
|
||||
const MASTODON_LIST_URL = id => `/api/v1/lists/${id}`
|
||||
const MASTODON_LIST_ACCOUNTS_URL = id => `/api/v1/lists/${id}/accounts`
|
||||
const PLEROMA_EMOJI_REACTIONS_URL = id => `/api/v1/pleroma/statuses/${id}/reactions`
|
||||
const PLEROMA_EMOJI_REACT_URL = (id, emoji) => `/api/v1/pleroma/statuses/${id}/reactions/${emoji}`
|
||||
const PLEROMA_EMOJI_UNREACT_URL = (id, emoji) => `/api/v1/pleroma/statuses/${id}/reactions/${emoji}`
|
||||
|
@ -560,7 +563,7 @@ const fetchTimeline = ({
|
|||
})
|
||||
.then((data) => data.json())
|
||||
.then((data) => {
|
||||
if (!data.error) {
|
||||
if (!data.errors) {
|
||||
return { data: data.map(isNotifications ? parseNotification : parseStatus), pagination }
|
||||
} else {
|
||||
data.status = status
|
||||
|
@ -1257,6 +1260,77 @@ const deleteChatMessage = ({ chatId, messageId, credentials }) => {
|
|||
})
|
||||
}
|
||||
|
||||
const lists = ({ credentials }) => {
|
||||
return promisedRequest({
|
||||
url: MASTODON_LISTS_URL,
|
||||
method: 'GET',
|
||||
credentials
|
||||
})
|
||||
}
|
||||
|
||||
const list = ({ listId, credentials }) => {
|
||||
return promisedRequest({
|
||||
url: MASTODON_LIST_URL(listId),
|
||||
method: 'GET',
|
||||
credentials
|
||||
})
|
||||
}
|
||||
|
||||
const createList = ({ title, credentials }) => {
|
||||
return promisedRequest({
|
||||
url: MASTODON_LISTS_URL,
|
||||
method: 'POST',
|
||||
payload: { title },
|
||||
credentials
|
||||
})
|
||||
}
|
||||
|
||||
const updateList = ({ title, listId, credentials }) => {
|
||||
return promisedRequest({
|
||||
url: MASTODON_LIST_URL(listId),
|
||||
method: 'PUT',
|
||||
payload: { title },
|
||||
credentials
|
||||
})
|
||||
}
|
||||
|
||||
const deleteList = ({ listId, credentials }) => {
|
||||
return promisedRequest({
|
||||
url: MASTODON_LIST_URL(listId),
|
||||
method: 'DELETE',
|
||||
credentials
|
||||
})
|
||||
}
|
||||
|
||||
const listUsers = ({ listId, credentials }) => {
|
||||
// TODO: pagination
|
||||
return promisedRequest({
|
||||
url: MASTODON_LIST_ACCOUNTS_URL(listId),
|
||||
method: 'GET',
|
||||
credentials
|
||||
})
|
||||
.then(data => data.json())
|
||||
.then(response => response.map(u => parseUser(u)))
|
||||
}
|
||||
|
||||
const addUsersToList = ({ listId, userIds, credentials }) => {
|
||||
return promisedRequest({
|
||||
url: MASTODON_LIST_ACCOUNTS_URL(listId),
|
||||
method: 'POST',
|
||||
payload: { 'account_ids': userIds },
|
||||
credentials
|
||||
})
|
||||
}
|
||||
|
||||
const removeUsersFromList = ({ listId, userIds, credentials }) => {
|
||||
return promisedRequest({
|
||||
url: MASTODON_LIST_ACCOUNTS_URL(listId),
|
||||
method: 'DELETE',
|
||||
payload: { 'account_ids': userIds },
|
||||
credentials
|
||||
})
|
||||
}
|
||||
|
||||
const apiService = {
|
||||
verifyCredentials,
|
||||
fetchTimeline,
|
||||
|
@ -1342,7 +1416,15 @@ const apiService = {
|
|||
chatMessages,
|
||||
sendChatMessage,
|
||||
readChat,
|
||||
deleteChatMessage
|
||||
deleteChatMessage,
|
||||
lists,
|
||||
list,
|
||||
createList,
|
||||
updateList,
|
||||
deleteList,
|
||||
listUsers,
|
||||
addUsersToList,
|
||||
removeUsersFromList
|
||||
}
|
||||
|
||||
export default apiService
|
||||
|
|
Loading…
Reference in a new issue