diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js index b033e60e..cdb35e08 100644 --- a/src/components/timeline/timeline.js +++ b/src/components/timeline/timeline.js @@ -6,11 +6,13 @@ import TimelineMenuTabs from '../timeline_menu_tabs/timeline_menu_tabs.vue' import TimelineQuickSettings from './timeline_quick_settings.vue' import { debounce, throttle, keyBy } from 'lodash' import { library } from '@fortawesome/fontawesome-svg-core' -import { faCircleNotch, faCog } from '@fortawesome/free-solid-svg-icons' +import { faCircleNotch, faCog, faPlus, faMinus } from '@fortawesome/free-solid-svg-icons' library.add( faCircleNotch, - faCog + faCog, + faPlus, + faMinus ) const Timeline = { @@ -90,6 +92,15 @@ const Timeline = { }, showPanelNavShortcuts () { return this.$store.getters.mergedConfig.showPanelNavShortcuts + }, + currentUser () { + return this.$store.state.users.currentUser + }, + tagData () { + return this.$store.state.tags.tags[this.tag] + }, + tagFollowed () { + return this.$store.state.tags.tags[this.tag]?.following } }, created () { @@ -118,6 +129,10 @@ const Timeline = { } window.addEventListener('keydown', this.handleShortKey) setTimeout(this.determineVisibleStatuses, 250) + + if (this.tag) { + this.$store.dispatch('getTag', this.tag) + } }, unmounted () { window.removeEventListener('scroll', this.handleScroll) @@ -232,6 +247,12 @@ const Timeline = { }, 200), handleVisibilityChange () { this.unfocused = document.hidden + }, + followTag (tag) { + return this.$store.dispatch('followTag', tag) + }, + unfollowTag (tag) { + return this.$store.dispatch('unfollowTag', tag) } }, watch: { diff --git a/src/components/timeline/timeline.vue b/src/components/timeline/timeline.vue index d75114df..9302cce6 100644 --- a/src/components/timeline/timeline.vue +++ b/src/components/timeline/timeline.vue @@ -21,6 +21,36 @@ {{ $t('timeline.up_to_date') }} +
+ +
+
+ +
{ + commit('setTag', { name: tagName, data: tag }) + return tag + }) + }, + followTag (store, tagName) { + return store.rootState.api.backendInteractor.followHashtag({ tag: tagName }) + .then((resp) => { + store.commit('setTag', { name: tagName, data: resp }) + return resp + }) + }, + unfollowTag ({ rootState, commit }, tag) { + return rootState.api.backendInteractor.unfollowHashtag({ tag }) + .then((resp) => { + commit('setTag', { name: tag, data: resp }) + return resp + }) + } + } +} + +export default tags diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index aeb43661..9e6f39f2 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -108,6 +108,9 @@ const PLEROMA_EDIT_ANNOUNCEMENT_URL = id => `/api/v1/pleroma/admin/announcements const PLEROMA_DELETE_ANNOUNCEMENT_URL = id => `/api/v1/pleroma/admin/announcements/${id}` const AKKOMA_SETTING_PROFILE_URL = (name) => `/api/v1/akkoma/frontend_settings/pleroma-fe/${name}` const AKKOMA_SETTING_PROFILE_LIST = `/api/v1/akkoma/frontend_settings/pleroma-fe` +const MASTODON_TAG_URL = (name) => `/api/v1/tags/${name}` +const MASTODON_FOLLOW_TAG_URL = (name) => `/api/v1/tags/${name}/follow` +const MASTODON_UNFOLLOW_TAG_URL = (name) => `/api/v1/tags/${name}/unfollow` const oldfetch = window.fetch @@ -1549,6 +1552,29 @@ const listSettingsProfiles = ({ credentials }) => { }) } +const getHashtag = ({ tag, credentials }) => { + return promisedRequest({ + url: MASTODON_TAG_URL(tag), + credentials + }) +} + +const followHashtag = ({ tag, credentials }) => { + return promisedRequest({ + url: MASTODON_FOLLOW_TAG_URL(tag), + method: 'POST', + credentials + }) +} + +const unfollowHashtag = ({ tag, credentials }) => { + return promisedRequest({ + url: MASTODON_UNFOLLOW_TAG_URL(tag), + method: 'POST', + credentials + }) +} + export const getMastodonSocketURI = ({ credentials, stream, args = {} }) => { return Object.entries({ ...(credentials @@ -1784,7 +1810,10 @@ const apiService = { getReports, updateReportStates, addNoteToReport, - deleteNoteFromReport + deleteNoteFromReport, + getHashtag, + followHashtag, + unfollowHashtag } export default apiService