2022-07-04 22:52:53 +00:00
|
|
|
import type { Module } from 'vuex'
|
|
|
|
import type { RootState } from '~/store/index'
|
|
|
|
import type { availableLanguages } from '~/init/locale'
|
|
|
|
|
2018-06-21 21:26:17 +00:00
|
|
|
import axios from 'axios'
|
2019-01-25 10:34:30 +00:00
|
|
|
import moment from 'moment'
|
2018-03-01 22:46:32 +00:00
|
|
|
|
2022-05-03 00:30:43 +00:00
|
|
|
type SupportedExtension = 'flac' | 'ogg' | 'mp3' | 'opus' | 'aac' | 'm4a' | 'aiff' | 'aif'
|
|
|
|
|
2022-05-06 19:41:36 +00:00
|
|
|
export type RouteWithPreferences = 'library.artists.browse' | 'library.podcasts.browse' | 'library.radios.browse'
|
2022-05-03 00:30:43 +00:00
|
|
|
| 'library.playlists.browse' | 'library.albums.me' | 'library.artists.me' | 'library.radios.me'
|
|
|
|
| 'library.playlists.me' | 'content.libraries.files' | 'library.detail.upload' | 'library.detail.edit'
|
|
|
|
| 'library.detail' | 'favorites' | 'manage.channels' | 'manage.library.tags' | 'manage.library.uploads'
|
|
|
|
| 'manage.library.libraries' | 'manage.library.tracks' | 'manage.library.albums' | 'manage.library.artists'
|
|
|
|
| 'manage.library.edits' | 'manage.users.users.list' | 'manage.users.invitations.list'
|
|
|
|
| 'manage.moderation.accounts.list' | 'manage.moderation.domains.list' | 'manage.moderation.requests.list'
|
|
|
|
| 'manage.moderation.reports.list' | 'library.albums.browse'
|
|
|
|
|
|
|
|
export type WebSocketEventName = 'inbox.item_added' | 'import.status_updated' | 'mutation.created' | 'mutation.updated'
|
|
|
|
| 'report.created' | 'user_request.created' | 'Listen'
|
|
|
|
|
2022-06-11 22:00:57 +00:00
|
|
|
export type OrderingField = 'creation_date' | 'title' | 'album__title' | 'artist__name' | 'release_date' | 'name'
|
2022-06-25 22:06:30 +00:00
|
|
|
| 'applied_date' | 'followers_count' | 'uploads_count' | 'length' | 'items_count' | 'modification_date' | 'size'
|
|
|
|
| 'accessed_date' | 'bitrate' | 'duration' | 'last_fetch_date' | 'preferred_username' | 'domain' | 'handled_date'
|
|
|
|
| 'album_title' | 'artist_name' | 'actors_count' | 'outbox_activities_count' | 'expiration_date' | 'date_joined'
|
|
|
|
| 'last_activity' | 'username'
|
2022-06-11 22:00:57 +00:00
|
|
|
|
2022-05-06 19:41:36 +00:00
|
|
|
export type OrderingDirection = '-' | '+'
|
2022-05-03 00:30:43 +00:00
|
|
|
interface RoutePreferences {
|
|
|
|
paginateBy: number
|
|
|
|
orderingDirection: OrderingDirection
|
2022-05-06 19:41:36 +00:00
|
|
|
ordering: OrderingField
|
2022-05-03 00:30:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface WebSocketEvent {
|
|
|
|
type: WebSocketEventName
|
|
|
|
}
|
|
|
|
|
|
|
|
type WebSocketHandlers = Record<string, (event: WebSocketEvent) => void>
|
|
|
|
|
|
|
|
interface Message {
|
|
|
|
displayTime: number
|
|
|
|
key: string
|
|
|
|
}
|
|
|
|
|
|
|
|
type NotificationsKey = 'inbox' | 'pendingReviewEdits' | 'pendingReviewReports' | 'pendingReviewRequests'
|
|
|
|
|
|
|
|
export interface State {
|
|
|
|
currentLanguage: 'en_US' | keyof typeof availableLanguages
|
|
|
|
selectedLanguage: boolean
|
2022-07-03 18:12:09 +00:00
|
|
|
queueFocused: null | 'queue' | 'player'
|
2022-05-03 00:30:43 +00:00
|
|
|
momentLocale: 'en'
|
|
|
|
lastDate: Date
|
|
|
|
maxMessages: number
|
|
|
|
messageDisplayDuration: number
|
|
|
|
supportedExtensions: SupportedExtension[]
|
|
|
|
messages: Message[]
|
|
|
|
window: {
|
|
|
|
height: number
|
|
|
|
width: number
|
|
|
|
}
|
|
|
|
pageTitle: null
|
|
|
|
|
|
|
|
notifications: Record<NotificationsKey, number>
|
|
|
|
websocketEventsHandlers: Record<WebSocketEventName, WebSocketHandlers>
|
|
|
|
routePreferences: Record<RouteWithPreferences, RoutePreferences>
|
|
|
|
}
|
|
|
|
|
|
|
|
const store: Module<State, RootState> = {
|
2018-03-01 22:46:32 +00:00
|
|
|
namespaced: true,
|
|
|
|
state: {
|
2018-06-30 10:05:52 +00:00
|
|
|
currentLanguage: 'en_US',
|
2019-09-11 10:30:31 +00:00
|
|
|
selectedLanguage: false,
|
2019-12-26 10:38:26 +00:00
|
|
|
queueFocused: null,
|
2019-01-25 10:34:30 +00:00
|
|
|
momentLocale: 'en',
|
2018-06-07 10:59:22 +00:00
|
|
|
lastDate: new Date(),
|
|
|
|
maxMessages: 100,
|
2020-07-04 09:38:37 +00:00
|
|
|
messageDisplayDuration: 5 * 1000,
|
2021-12-06 10:35:20 +00:00
|
|
|
supportedExtensions: ['flac', 'ogg', 'mp3', 'opus', 'aac', 'm4a', 'aiff', 'aif'],
|
2018-06-21 21:26:17 +00:00
|
|
|
messages: [],
|
2020-02-23 14:31:03 +00:00
|
|
|
window: {
|
|
|
|
height: 0,
|
2021-12-06 10:35:20 +00:00
|
|
|
width: 0
|
2020-02-23 14:31:03 +00:00
|
|
|
},
|
2018-06-21 21:26:17 +00:00
|
|
|
notifications: {
|
2018-09-13 15:18:23 +00:00
|
|
|
inbox: 0,
|
2019-02-28 08:31:04 +00:00
|
|
|
pendingReviewEdits: 0,
|
2019-08-27 08:55:24 +00:00
|
|
|
pendingReviewReports: 0,
|
2021-12-06 10:35:20 +00:00
|
|
|
pendingReviewRequests: 0
|
2018-09-13 15:18:23 +00:00
|
|
|
},
|
|
|
|
websocketEventsHandlers: {
|
|
|
|
'inbox.item_added': {},
|
|
|
|
'import.status_updated': {},
|
2019-02-28 08:31:04 +00:00
|
|
|
'mutation.created': {},
|
|
|
|
'mutation.updated': {},
|
2019-09-13 04:09:48 +00:00
|
|
|
'report.created': {},
|
2020-03-18 10:57:33 +00:00
|
|
|
'user_request.created': {},
|
2021-12-06 10:35:20 +00:00
|
|
|
Listen: {}
|
2019-04-08 08:01:21 +00:00
|
|
|
},
|
2019-11-12 14:51:45 +00:00
|
|
|
pageTitle: null,
|
|
|
|
routePreferences: {
|
2021-12-06 10:35:20 +00:00
|
|
|
'library.albums.browse': {
|
2019-11-12 14:51:45 +00:00
|
|
|
paginateBy: 25,
|
2021-12-06 10:35:20 +00:00
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
2019-11-12 14:51:45 +00:00
|
|
|
},
|
2021-12-06 10:35:20 +00:00
|
|
|
'library.artists.browse': {
|
2019-11-12 14:51:45 +00:00
|
|
|
paginateBy: 30,
|
2021-12-06 10:35:20 +00:00
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
2020-12-04 08:33:17 +00:00
|
|
|
},
|
2021-12-06 10:35:20 +00:00
|
|
|
'library.podcasts.browse': {
|
2020-12-04 08:33:17 +00:00
|
|
|
paginateBy: 30,
|
2021-12-06 10:35:20 +00:00
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
2019-11-12 14:51:45 +00:00
|
|
|
},
|
2021-12-06 10:35:20 +00:00
|
|
|
'library.radios.browse': {
|
2019-11-12 14:51:45 +00:00
|
|
|
paginateBy: 12,
|
2021-12-06 10:35:20 +00:00
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
2019-11-12 14:51:45 +00:00
|
|
|
},
|
2021-12-06 10:35:20 +00:00
|
|
|
'library.playlists.browse': {
|
2019-11-12 14:51:45 +00:00
|
|
|
paginateBy: 25,
|
2021-12-06 10:35:20 +00:00
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
2019-11-12 14:51:45 +00:00
|
|
|
},
|
2021-12-06 10:35:20 +00:00
|
|
|
'library.albums.me': {
|
2019-12-26 10:38:26 +00:00
|
|
|
paginateBy: 25,
|
2021-12-06 10:35:20 +00:00
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
2019-12-26 10:38:26 +00:00
|
|
|
},
|
2021-12-06 10:35:20 +00:00
|
|
|
'library.artists.me': {
|
2019-12-26 10:38:26 +00:00
|
|
|
paginateBy: 30,
|
2021-12-06 10:35:20 +00:00
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
2019-12-26 10:38:26 +00:00
|
|
|
},
|
2021-12-06 10:35:20 +00:00
|
|
|
'library.radios.me': {
|
2019-12-26 10:38:26 +00:00
|
|
|
paginateBy: 12,
|
2021-12-06 10:35:20 +00:00
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
2019-12-26 10:38:26 +00:00
|
|
|
},
|
2021-12-06 10:35:20 +00:00
|
|
|
'library.playlists.me': {
|
2019-12-26 10:38:26 +00:00
|
|
|
paginateBy: 25,
|
2021-12-06 10:35:20 +00:00
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
2019-12-26 10:38:26 +00:00
|
|
|
},
|
2021-12-06 10:35:20 +00:00
|
|
|
'content.libraries.files': {
|
2020-01-30 09:38:35 +00:00
|
|
|
paginateBy: 50,
|
2021-12-06 10:35:20 +00:00
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
2020-01-30 09:38:35 +00:00
|
|
|
},
|
2021-12-06 10:35:20 +00:00
|
|
|
'library.detail.upload': {
|
2020-01-30 09:38:35 +00:00
|
|
|
paginateBy: 50,
|
2021-12-06 10:35:20 +00:00
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
2020-01-30 09:38:35 +00:00
|
|
|
},
|
2021-12-06 10:35:20 +00:00
|
|
|
'library.detail.edit': {
|
2020-03-04 21:18:28 +00:00
|
|
|
paginateBy: 50,
|
2021-12-06 10:35:20 +00:00
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
2020-03-04 21:18:28 +00:00
|
|
|
},
|
2021-12-06 10:35:20 +00:00
|
|
|
'library.detail': {
|
2020-02-05 13:53:20 +00:00
|
|
|
paginateBy: 50,
|
2021-12-06 10:35:20 +00:00
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
2020-02-05 13:53:20 +00:00
|
|
|
},
|
2021-12-06 10:35:20 +00:00
|
|
|
favorites: {
|
2020-03-03 12:33:04 +00:00
|
|
|
paginateBy: 50,
|
2021-12-06 10:35:20 +00:00
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
2020-03-03 12:33:04 +00:00
|
|
|
},
|
2021-12-19 17:37:48 +00:00
|
|
|
'manage.channels': {
|
|
|
|
paginateBy: 50,
|
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
|
|
|
},
|
|
|
|
'manage.library.tags': {
|
|
|
|
paginateBy: 50,
|
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
|
|
|
},
|
|
|
|
'manage.library.uploads': {
|
|
|
|
paginateBy: 50,
|
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
|
|
|
},
|
|
|
|
'manage.library.libraries': {
|
|
|
|
paginateBy: 50,
|
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
|
|
|
},
|
|
|
|
'manage.library.tracks': {
|
|
|
|
paginateBy: 50,
|
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
|
|
|
},
|
|
|
|
'manage.library.albums': {
|
|
|
|
paginateBy: 50,
|
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
|
|
|
},
|
|
|
|
'manage.library.artists': {
|
|
|
|
paginateBy: 50,
|
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
|
|
|
},
|
|
|
|
'manage.library.edits': {
|
|
|
|
paginateBy: 25,
|
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
|
|
|
},
|
|
|
|
'manage.users.users.list': {
|
|
|
|
paginateBy: 50,
|
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
|
|
|
},
|
|
|
|
'manage.users.invitations.list': {
|
|
|
|
paginateBy: 50,
|
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
|
|
|
},
|
|
|
|
'manage.moderation.accounts.list': {
|
|
|
|
paginateBy: 50,
|
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
|
|
|
},
|
|
|
|
'manage.moderation.domains.list': {
|
|
|
|
paginateBy: 50,
|
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
|
|
|
},
|
2021-12-06 10:35:20 +00:00
|
|
|
'manage.moderation.requests.list': {
|
2020-03-18 10:57:33 +00:00
|
|
|
paginateBy: 25,
|
2021-12-06 10:35:20 +00:00
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
2020-03-18 10:57:33 +00:00
|
|
|
},
|
2021-12-06 10:35:20 +00:00
|
|
|
'manage.moderation.reports.list': {
|
2020-03-18 10:57:33 +00:00
|
|
|
paginateBy: 25,
|
2021-12-06 10:35:20 +00:00
|
|
|
orderingDirection: '-',
|
|
|
|
ordering: 'creation_date'
|
|
|
|
}
|
2020-01-08 11:16:41 +00:00
|
|
|
}
|
2018-03-01 22:46:32 +00:00
|
|
|
},
|
2019-09-23 09:30:25 +00:00
|
|
|
getters: {
|
|
|
|
showInstanceSupportMessage: (state, getters, rootState) => {
|
|
|
|
if (!rootState.auth.profile) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if (!rootState.instance.settings.instance.support_message.value) {
|
|
|
|
return false
|
|
|
|
}
|
2021-12-06 10:35:20 +00:00
|
|
|
const displayDate = rootState.auth.profile.instance_support_message_display_date
|
2019-09-23 09:30:25 +00:00
|
|
|
if (!displayDate) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return moment(displayDate) < moment(state.lastDate)
|
|
|
|
},
|
|
|
|
showFunkwhaleSupportMessage: (state, getters, rootState) => {
|
|
|
|
if (!rootState.auth.profile) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if (!rootState.instance.settings.instance.funkwhale_support_message_enabled.value) {
|
|
|
|
return false
|
|
|
|
}
|
2021-12-06 10:35:20 +00:00
|
|
|
const displayDate = rootState.auth.profile.funkwhale_support_message_display_date
|
2019-09-23 09:30:25 +00:00
|
|
|
if (!displayDate) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return moment(displayDate) < moment(state.lastDate)
|
|
|
|
},
|
|
|
|
additionalNotifications: (state, getters) => {
|
|
|
|
let count = 0
|
|
|
|
if (getters.showInstanceSupportMessage) {
|
|
|
|
count += 1
|
|
|
|
}
|
|
|
|
if (getters.showFunkwhaleSupportMessage) {
|
|
|
|
count += 1
|
|
|
|
}
|
|
|
|
return count
|
2020-02-23 14:31:03 +00:00
|
|
|
},
|
|
|
|
|
2022-05-03 00:30:43 +00:00
|
|
|
windowSize: (state) => {
|
2020-02-23 14:31:03 +00:00
|
|
|
// IMPORTANT: if you modify these breakpoints, also modify the values in
|
|
|
|
// style/vendor/_media.scss
|
2021-12-06 10:35:20 +00:00
|
|
|
const width = state.window.width
|
|
|
|
const breakpoints = [
|
|
|
|
{ name: 'widedesktop', width: 1200 },
|
|
|
|
{ name: 'desktop', width: 1024 },
|
|
|
|
{ name: 'tablet', width: 768 },
|
|
|
|
{ name: 'phone', width: 320 }
|
2020-02-23 14:31:03 +00:00
|
|
|
]
|
|
|
|
for (let index = 0; index < breakpoints.length; index++) {
|
2021-12-06 10:35:20 +00:00
|
|
|
const element = breakpoints[index]
|
2020-02-23 14:31:03 +00:00
|
|
|
if (width >= element.width) {
|
|
|
|
return element.name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 'phone'
|
|
|
|
},
|
|
|
|
layoutVersion: (state, getters) => {
|
|
|
|
if (['tablet', 'phone'].indexOf(getters.windowSize) > -1) {
|
|
|
|
return 'small'
|
|
|
|
} else {
|
|
|
|
return 'large'
|
|
|
|
}
|
2019-09-23 09:30:25 +00:00
|
|
|
}
|
|
|
|
},
|
2018-03-01 22:46:32 +00:00
|
|
|
mutations: {
|
2022-05-03 00:30:43 +00:00
|
|
|
addWebsocketEventHandler: (state, { eventName, id, handler }: { eventName: WebSocketEventName, id: string, handler: () => void}) => {
|
2018-09-13 15:18:23 +00:00
|
|
|
state.websocketEventsHandlers[eventName][id] = handler
|
|
|
|
},
|
2022-05-03 00:30:43 +00:00
|
|
|
removeWebsocketEventHandler: (state, { eventName, id }: { eventName: WebSocketEventName, id: string }) => {
|
2018-09-13 15:18:23 +00:00
|
|
|
delete state.websocketEventsHandlers[eventName][id]
|
|
|
|
},
|
2018-06-30 10:05:52 +00:00
|
|
|
currentLanguage: (state, value) => {
|
|
|
|
state.currentLanguage = value
|
2019-09-11 10:30:31 +00:00
|
|
|
state.selectedLanguage = true
|
2018-06-30 10:05:52 +00:00
|
|
|
},
|
2019-01-25 10:34:30 +00:00
|
|
|
momentLocale: (state, value) => {
|
|
|
|
state.momentLocale = value
|
|
|
|
moment.locale(value)
|
|
|
|
},
|
2018-03-01 22:46:32 +00:00
|
|
|
computeLastDate: (state) => {
|
|
|
|
state.lastDate = new Date()
|
2018-06-07 10:59:22 +00:00
|
|
|
},
|
2019-12-26 10:38:26 +00:00
|
|
|
queueFocused: (state, value) => {
|
|
|
|
state.queueFocused = value
|
|
|
|
},
|
|
|
|
|
2018-06-07 10:59:22 +00:00
|
|
|
addMessage (state, message) {
|
2021-12-06 10:35:20 +00:00
|
|
|
const finalMessage = {
|
2020-02-14 11:41:29 +00:00
|
|
|
displayTime: state.messageDisplayDuration,
|
|
|
|
key: String(new Date()),
|
2021-12-06 10:35:20 +00:00
|
|
|
...message
|
2020-02-14 11:41:29 +00:00
|
|
|
}
|
2022-04-18 08:24:47 +00:00
|
|
|
|
2021-12-06 10:35:20 +00:00
|
|
|
const key = finalMessage.key
|
2022-04-18 08:24:47 +00:00
|
|
|
state.messages.splice(state.messages.findIndex(message => message.key === key), 1)
|
2020-02-14 11:41:29 +00:00
|
|
|
state.messages.push(finalMessage)
|
2018-06-07 10:59:22 +00:00
|
|
|
if (state.messages.length > state.maxMessages) {
|
|
|
|
state.messages.shift()
|
|
|
|
}
|
2018-06-21 21:26:17 +00:00
|
|
|
},
|
2020-02-14 11:41:29 +00:00
|
|
|
removeMessage (state, key) {
|
2022-04-18 08:24:47 +00:00
|
|
|
state.messages.splice(state.messages.findIndex(message => message.key === key), 1)
|
2020-02-14 11:41:29 +00:00
|
|
|
},
|
2022-05-03 00:30:43 +00:00
|
|
|
notifications (state, { type, count }: { type: NotificationsKey, count: number }) {
|
2018-06-21 21:26:17 +00:00
|
|
|
state.notifications[type] = count
|
2018-09-13 15:18:23 +00:00
|
|
|
},
|
2022-07-21 00:19:31 +00:00
|
|
|
incrementNotifications (state, { type, count, value }: { type: NotificationsKey, count: number, value?: number }) {
|
2021-12-06 10:35:20 +00:00
|
|
|
if (value !== undefined) {
|
|
|
|
state.notifications[type] = Math.max(0, value)
|
2019-02-28 08:31:04 +00:00
|
|
|
} else {
|
|
|
|
state.notifications[type] = Math.max(0, state.notifications[type] + count)
|
|
|
|
}
|
2019-04-08 08:01:21 +00:00
|
|
|
},
|
|
|
|
pageTitle: (state, value) => {
|
|
|
|
state.pageTitle = value
|
2019-11-12 14:51:45 +00:00
|
|
|
},
|
2020-02-23 14:31:03 +00:00
|
|
|
window: (state, value) => {
|
|
|
|
state.window = value
|
2020-01-08 11:16:41 +00:00
|
|
|
}
|
2018-06-21 21:26:17 +00:00
|
|
|
},
|
|
|
|
actions: {
|
2022-05-03 00:30:43 +00:00
|
|
|
fetchUnreadNotifications ({ commit }) {
|
2021-12-06 10:35:20 +00:00
|
|
|
axios.get('federation/inbox/', { params: { is_read: false, page_size: 1 } }).then((response) => {
|
|
|
|
commit('notifications', { type: 'inbox', count: response.data.count })
|
2018-06-21 21:26:17 +00:00
|
|
|
})
|
|
|
|
},
|
2022-05-03 00:30:43 +00:00
|
|
|
fetchPendingReviewEdits ({ commit }) {
|
2021-12-06 10:35:20 +00:00
|
|
|
axios.get('mutations/', { params: { is_approved: 'null', page_size: 1 } }).then((response) => {
|
|
|
|
commit('notifications', { type: 'pendingReviewEdits', count: response.data.count })
|
2019-02-28 08:31:04 +00:00
|
|
|
})
|
|
|
|
},
|
2022-05-03 00:30:43 +00:00
|
|
|
fetchPendingReviewReports ({ commit }) {
|
2021-12-06 10:35:20 +00:00
|
|
|
axios.get('manage/moderation/reports/', { params: { is_handled: 'false', page_size: 1 } }).then((response) => {
|
|
|
|
commit('notifications', { type: 'pendingReviewReports', count: response.data.count })
|
2019-08-27 08:55:24 +00:00
|
|
|
})
|
|
|
|
},
|
2022-05-03 00:30:43 +00:00
|
|
|
fetchPendingReviewRequests ({ commit }) {
|
2021-12-06 10:35:20 +00:00
|
|
|
axios.get('manage/moderation/requests/', { params: { status: 'pending', page_size: 1 } }).then((response) => {
|
|
|
|
commit('notifications', { type: 'pendingReviewRequests', count: response.data.count })
|
2020-03-18 10:57:33 +00:00
|
|
|
})
|
|
|
|
},
|
2020-07-05 09:22:31 +00:00
|
|
|
|
2022-05-03 00:30:43 +00:00
|
|
|
async currentLanguage ({ commit, rootState }, value) {
|
2021-12-06 10:35:20 +00:00
|
|
|
commit('currentLanguage', value)
|
2020-07-05 09:22:31 +00:00
|
|
|
if (rootState.auth.authenticated) {
|
2021-12-06 10:35:20 +00:00
|
|
|
await axios.post('users/settings', { language: value })
|
2020-07-05 09:22:31 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2022-05-03 00:30:43 +00:00
|
|
|
websocketEvent ({ state }, event: WebSocketEvent) {
|
2021-12-06 10:35:20 +00:00
|
|
|
const handlers = state.websocketEventsHandlers[event.type]
|
2019-01-02 14:19:45 +00:00
|
|
|
console.log('Dispatching websocket event', event, handlers)
|
2018-09-13 15:18:23 +00:00
|
|
|
if (!handlers) {
|
2018-06-21 21:26:17 +00:00
|
|
|
return
|
|
|
|
}
|
2022-05-03 00:30:43 +00:00
|
|
|
|
2021-12-06 10:35:20 +00:00
|
|
|
const names = Object.keys(handlers)
|
2018-09-13 15:18:23 +00:00
|
|
|
names.forEach((k) => {
|
2021-12-06 10:35:20 +00:00
|
|
|
const handler = handlers[k]
|
2018-09-13 15:18:23 +00:00
|
|
|
handler(event)
|
2018-06-21 21:26:17 +00:00
|
|
|
})
|
2018-03-01 22:46:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-05-03 00:30:43 +00:00
|
|
|
|
|
|
|
export default store
|