diff --git a/src/api/reports.js b/src/api/reports.js index 9bad8f86..073f84ad 100644 --- a/src/api/reports.js +++ b/src/api/reports.js @@ -12,25 +12,6 @@ export async function changeState(state, id, authHost, token) { }) } -export async function changeStatusScope(id, sensitive, visibility, authHost, token) { - return await request({ - baseURL: baseName(authHost), - url: `/api/pleroma/admin/statuses/${id}`, - method: 'put', - headers: authHeaders(token), - data: { sensitive, visibility } - }) -} - -export async function deleteStatus(id, authHost, token) { - return await request({ - baseURL: baseName(authHost), - url: `/api/pleroma/admin/statuses/${id}`, - method: 'delete', - headers: authHeaders(token) - }) -} - export async function fetchReports(filter, page, pageSize, authHost, token) { const url = filter.length > 0 ? `/api/pleroma/admin/reports?state=${filter}&page=${page}&page_size=${pageSize}` diff --git a/src/api/status.js b/src/api/status.js new file mode 100644 index 00000000..7d931ae0 --- /dev/null +++ b/src/api/status.js @@ -0,0 +1,24 @@ +import request from '@/utils/request' +import { getToken } from '@/utils/auth' +import { baseName } from './utils' + +export async function changeStatusScope(id, sensitive, visibility, authHost, token) { + return await request({ + baseURL: baseName(authHost), + url: `/api/pleroma/admin/statuses/${id}`, + method: 'put', + headers: authHeaders(token), + data: { sensitive, visibility } + }) +} + +export async function deleteStatus(id, authHost, token) { + return await request({ + baseURL: baseName(authHost), + url: `/api/pleroma/admin/statuses/${id}`, + method: 'delete', + headers: authHeaders(token) + }) +} + +const authHeaders = (token) => token ? { 'Authorization': `Bearer ${getToken()}` } : {} diff --git a/src/store/index.js b/src/store/index.js index 830c0788..9a3cad50 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -6,6 +6,7 @@ import invites from './modules/invites' import permission from './modules/permission' import reports from './modules/reports' import settings from './modules/settings' +import status from './modules/status' import tagsView from './modules/tagsView' import user from './modules/user' import userProfile from './modules/userProfile' @@ -23,6 +24,7 @@ const store = new Vuex.Store({ permission, reports, settings, + status, tagsView, user, userProfile, diff --git a/src/store/modules/reports.js b/src/store/modules/reports.js index 9922f465..8e3d2c4f 100644 --- a/src/store/modules/reports.js +++ b/src/store/modules/reports.js @@ -1,4 +1,4 @@ -import { changeState, changeStatusScope, deleteStatus, fetchReports } from '@/api/reports' +import { changeState, fetchReports } from '@/api/reports' const reports = { state: { @@ -38,18 +38,10 @@ const reports = { await changeState(reportState, reportId, getters.authHost, getters.token) dispatch('FetchReports', state.currentPage) }, - async ChangeStatusScope({ dispatch, getters, state }, { statusId, isSensitive, visibility }) { - await changeStatusScope(statusId, isSensitive, visibility, getters.authHost, getters.token) - dispatch('FetchReports', state.currentPage) - }, ClearFetchedReports({ commit }) { commit('SET_REPORTS', []) commit('SET_LAST_REPORT_ID', '') }, - async DeleteStatus({ dispatch, getters, state }, { statusId }) { - await deleteStatus(statusId, getters.authHost, getters.token) - dispatch('FetchReports', state.currentPage) - }, async FetchReports({ commit, getters, state }, page) { commit('SET_LOADING', true) const { data } = await fetchReports(state.stateFilter, page, state.pageSize, getters.authHost, getters.token) diff --git a/src/store/modules/status.js b/src/store/modules/status.js new file mode 100644 index 00000000..a287f94b --- /dev/null +++ b/src/store/modules/status.js @@ -0,0 +1,16 @@ +import { changeStatusScope, deleteStatus } from '@/api/status' + +const status = { + actions: { + async ChangeStatusScope({ dispatch, getters, state }, { statusId, isSensitive, visibility }) { + await changeStatusScope(statusId, isSensitive, visibility, getters.authHost, getters.token) + dispatch('FetchReports', state.currentPage) + }, + async DeleteStatus({ dispatch, getters, state }, { statusId }) { + await deleteStatus(statusId, getters.authHost, getters.token) + dispatch('FetchReports', state.currentPage) + } + } +} + +export default status