refactor promisedRequest to always return whole response
This commit is contained in:
parent
c81813064b
commit
1ca0ffb1f0
25 changed files with 352 additions and 327 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
import { parseChat } from 'src/services/entity_normalizer/entity_normalizer.service.js'
|
|
||||||
import { paramsString, promisedRequest } from './helpers.js'
|
import { paramsString, promisedRequest } from './helpers.js'
|
||||||
|
|
||||||
|
import { parseChat } from 'src/services/entity_normalizer/entity_normalizer.service.js'
|
||||||
|
|
||||||
const PLEROMA_CHATS_URL = '/api/v1/pleroma/chats'
|
const PLEROMA_CHATS_URL = '/api/v1/pleroma/chats'
|
||||||
const PLEROMA_CHAT_URL = (id) => `/api/v1/pleroma/chats/by-account-id/${id}`
|
const PLEROMA_CHAT_URL = (id) => `/api/v1/pleroma/chats/by-account-id/${id}`
|
||||||
const PLEROMA_CHAT_MESSAGES_URL = (id, { maxId, sinceId, limit }) =>
|
const PLEROMA_CHAT_MESSAGES_URL = (id, { maxId, sinceId, limit }) =>
|
||||||
|
|
@ -13,7 +14,7 @@ export const chats = ({ credentials }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
url: PLEROMA_CHATS_URL,
|
url: PLEROMA_CHATS_URL,
|
||||||
credentials,
|
credentials,
|
||||||
}).then((data) => ({
|
}).then(({ data }) => ({
|
||||||
chatList: data.map(parseChat).filter((c) => c),
|
chatList: data.map(parseChat).filter((c) => c),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,7 @@ export const promisedRequest = async ({
|
||||||
)
|
)
|
||||||
.join('&')
|
.join('&')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (formData || payload) {
|
if (formData || payload) {
|
||||||
options.body = formData || JSON.stringify(payload)
|
options.body = formData || JSON.stringify(payload)
|
||||||
}
|
}
|
||||||
|
|
@ -109,33 +110,37 @@ export const promisedRequest = async ({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await fetch(url, options)
|
let response = null
|
||||||
|
|
||||||
// 204 is "No content", which fails to parse json (as you'd might think)
|
|
||||||
if (response.ok && response.status === 204) return { _response: response }
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const json = await response.json()
|
response = await fetch(url, options)
|
||||||
|
const data = await (async () => {
|
||||||
|
const [contentType] = response.headers
|
||||||
|
.get('content-type')
|
||||||
|
.split(';')
|
||||||
|
.map((x) => x.toLowerCase().trim())
|
||||||
|
|
||||||
if (typeof json !== 'object') {
|
switch (contentType) {
|
||||||
return {
|
case 'text/plain':
|
||||||
_response: response,
|
return await response.text()
|
||||||
_value: json,
|
case 'application/json':
|
||||||
|
return await response.json()
|
||||||
|
default:
|
||||||
|
return await response.bytes()
|
||||||
}
|
}
|
||||||
}
|
})()
|
||||||
|
|
||||||
json._response = response
|
const { ok, status } = response
|
||||||
|
|
||||||
if (!response.ok) {
|
if (ok) {
|
||||||
|
return { response, status, data }
|
||||||
|
} else {
|
||||||
throw new StatusCodeError(
|
throw new StatusCodeError(
|
||||||
response.status,
|
response.status,
|
||||||
json,
|
data,
|
||||||
{ url, options },
|
{ url, options },
|
||||||
response,
|
response,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return json
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new StatusCodeError(
|
throw new StatusCodeError(
|
||||||
response.status,
|
response.status,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
import { concat, each, last, map } from 'lodash'
|
import { concat, each, last, map } from 'lodash'
|
||||||
|
|
||||||
|
import { paramsString, promisedRequest } from './helpers.js'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
parseAttachment,
|
parseAttachment,
|
||||||
parseChat,
|
parseChat,
|
||||||
|
|
@ -9,8 +11,6 @@ import {
|
||||||
parseStatus,
|
parseStatus,
|
||||||
parseUser,
|
parseUser,
|
||||||
} from 'src/services/entity_normalizer/entity_normalizer.service.js'
|
} from 'src/services/entity_normalizer/entity_normalizer.service.js'
|
||||||
import { paramsString, promisedRequest } from './helpers.js'
|
|
||||||
|
|
||||||
import { RegistrationError, StatusCodeError } from 'src/services/errors/errors'
|
import { RegistrationError, StatusCodeError } from 'src/services/errors/errors'
|
||||||
|
|
||||||
const SUGGESTIONS_URL = '/api/v1/suggestions'
|
const SUGGESTIONS_URL = '/api/v1/suggestions'
|
||||||
|
|
@ -102,7 +102,7 @@ export const fetchUser = ({ id, credentials }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
url: `${MASTODON_USER_URL}/${id}`,
|
url: `${MASTODON_USER_URL}/${id}`,
|
||||||
credentials,
|
credentials,
|
||||||
}).then((data) => parseUser(data))
|
}).then(({ data, ...rest }) => ({ ...rest, data: parseUser(data) }))
|
||||||
|
|
||||||
export const fetchUserByName = ({ name, credentials }) =>
|
export const fetchUserByName = ({ name, credentials }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
|
|
@ -126,7 +126,7 @@ export const fetchFriends = ({ id, maxId, sinceId, limit = 20, credentials }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
url: MASTODON_FOLLOWING_URL(id, { maxId, sinceId, limit }),
|
url: MASTODON_FOLLOWING_URL(id, { maxId, sinceId, limit }),
|
||||||
credentials,
|
credentials,
|
||||||
}).then((data) => data.map(parseUser))
|
}).then(({ data, ...rest }) => ({ ...rest, data: data.map(parseUser) }))
|
||||||
|
|
||||||
export const fetchFollowers = ({
|
export const fetchFollowers = ({
|
||||||
id,
|
id,
|
||||||
|
|
@ -143,16 +143,20 @@ export const fetchFollowers = ({
|
||||||
withRelationships: true,
|
withRelationships: true,
|
||||||
}),
|
}),
|
||||||
credentials,
|
credentials,
|
||||||
}).then((data) => data.map(parseUser))
|
}).then(({ data, ...rest }) => ({ ...rest, data: data.map(parseUser) }))
|
||||||
|
|
||||||
export const fetchConversation = ({ id, credentials }) =>
|
export const fetchConversation = ({ id, credentials }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
url: MASTODON_STATUS_CONTEXT_URL(id),
|
url: MASTODON_STATUS_CONTEXT_URL(id),
|
||||||
credentials,
|
credentials,
|
||||||
})
|
})
|
||||||
.then(({ ancestors, descendants }) => ({
|
.then((result) => ({
|
||||||
ancestors: ancestors.map(parseStatus),
|
...result,
|
||||||
descendants: descendants.map(parseStatus),
|
data: {
|
||||||
|
...result.data,
|
||||||
|
ancestors: result.data.ancestors.map(parseStatus),
|
||||||
|
descendants: result.data.descendants.map(parseStatus),
|
||||||
|
},
|
||||||
}))
|
}))
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
throw new Error('Error fetching timeline', error)
|
throw new Error('Error fetching timeline', error)
|
||||||
|
|
@ -163,7 +167,7 @@ export const fetchStatus = ({ id, credentials }) =>
|
||||||
url: MASTODON_STATUS_URL(id),
|
url: MASTODON_STATUS_URL(id),
|
||||||
credentials,
|
credentials,
|
||||||
})
|
})
|
||||||
.then((data) => parseStatus(data))
|
.then(({ data, ...rest }) => ({ ...rest, data: parseStatus(data) }))
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
throw new Error('Error fetching timeline', error)
|
throw new Error('Error fetching timeline', error)
|
||||||
})
|
})
|
||||||
|
|
@ -173,7 +177,7 @@ export const fetchStatusSource = ({ id, credentials }) =>
|
||||||
url: MASTODON_STATUS_SOURCE_URL(id),
|
url: MASTODON_STATUS_SOURCE_URL(id),
|
||||||
credentials,
|
credentials,
|
||||||
})
|
})
|
||||||
.then((data) => parseSource(data))
|
.then(({ data, ...rest }) => ({ ...rest, data: parseSource(data) }))
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
throw new Error('Error fetching timeline', error)
|
throw new Error('Error fetching timeline', error)
|
||||||
})
|
})
|
||||||
|
|
@ -182,9 +186,8 @@ export const fetchStatusHistory = ({ status, credentials }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
url: MASTODON_STATUS_HISTORY_URL(status.id),
|
url: MASTODON_STATUS_HISTORY_URL(status.id),
|
||||||
credentials,
|
credentials,
|
||||||
}).then((data) => {
|
}).then(({ data }) => {
|
||||||
data.reverse()
|
return [...data].reverse().map((item) => {
|
||||||
return data.map((item) => {
|
|
||||||
item.originalStatus = status
|
item.originalStatus = status
|
||||||
return parseStatus(item)
|
return parseStatus(item)
|
||||||
})
|
})
|
||||||
|
|
@ -277,16 +280,17 @@ export const fetchTimeline = ({
|
||||||
return promisedRequest({
|
return promisedRequest({
|
||||||
url: url + paramsString(params),
|
url: url + paramsString(params),
|
||||||
credentials,
|
credentials,
|
||||||
}).then(async (data) => {
|
}).then(async (result) => {
|
||||||
const pagination = parseLinkHeaderPagination(
|
const pagination = parseLinkHeaderPagination(
|
||||||
data._response.headers.get('Link'),
|
result.response.headers.get('Link'),
|
||||||
{
|
{
|
||||||
flakeId: timeline !== 'bookmarks' && timeline !== 'notifications',
|
flakeId: timeline !== 'bookmarks' && timeline !== 'notifications',
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data: data.map(isNotifications ? parseNotification : parseStatus),
|
...result,
|
||||||
|
data: result.data.map(isNotifications ? parseNotification : parseStatus),
|
||||||
pagination,
|
pagination,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -301,13 +305,13 @@ export const fetchPinnedStatuses = ({ id, credentials }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
url: MASTODON_USER_TIMELINE_URL(id) + '?pinned=true',
|
url: MASTODON_USER_TIMELINE_URL(id) + '?pinned=true',
|
||||||
credentials,
|
credentials,
|
||||||
}).then((data) => data.map(parseStatus))
|
}).then(({ data, ...rest }) => ({ ...rest, data: data.map(parseStatus) }))
|
||||||
|
|
||||||
export const verifyCredentials = ({ credentials }) =>
|
export const verifyCredentials = ({ credentials }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
url: MASTODON_LOGIN_URL,
|
url: MASTODON_LOGIN_URL,
|
||||||
credentials,
|
credentials,
|
||||||
}).then((data) => (data.error ? data : parseUser(data)))
|
}).then(({ data, ...rest }) => ({ ...rest, data: parseUser(data) }))
|
||||||
|
|
||||||
export const suggestions = ({ credentials }) =>
|
export const suggestions = ({ credentials }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
|
|
@ -327,25 +331,26 @@ export const fetchFavoritedByUsers = ({ id, credentials }) =>
|
||||||
url: MASTODON_STATUS_FAVORITEDBY_URL(id),
|
url: MASTODON_STATUS_FAVORITEDBY_URL(id),
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
credentials,
|
credentials,
|
||||||
}).then((users) => users.map(parseUser))
|
}).then(({ data, ...rest }) => ({ ...rest, data: parseUser(data) }))
|
||||||
|
|
||||||
export const fetchRebloggedByUsers = ({ id, credentials }) =>
|
export const fetchRebloggedByUsers = ({ id, credentials }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
url: MASTODON_STATUS_REBLOGGEDBY_URL(id),
|
url: MASTODON_STATUS_REBLOGGEDBY_URL(id),
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
credentials,
|
credentials,
|
||||||
}).then((users) => users.map(parseUser))
|
}).then(({ data, ...rest }) => ({ ...rest, data: parseUser(data) }))
|
||||||
|
|
||||||
export const fetchEmojiReactions = ({ id, credentials }) =>
|
export const fetchEmojiReactions = ({ id, credentials }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
url: PLEROMA_EMOJI_REACTIONS_URL(id),
|
url: PLEROMA_EMOJI_REACTIONS_URL(id),
|
||||||
credentials,
|
credentials,
|
||||||
}).then((reactions) =>
|
}).then(({ data, ...rest }) => ({
|
||||||
reactions.map((r) => {
|
...rest,
|
||||||
|
data: data.map((r) => {
|
||||||
r.accounts = r.accounts.map(parseUser)
|
r.accounts = r.accounts.map(parseUser)
|
||||||
return r
|
return r
|
||||||
}),
|
}),
|
||||||
)
|
}))
|
||||||
|
|
||||||
export const searchUsers = ({ credentials, query }) =>
|
export const searchUsers = ({ credentials, query }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
|
|
@ -355,7 +360,7 @@ export const searchUsers = ({ credentials, query }) =>
|
||||||
resolve: true,
|
resolve: true,
|
||||||
},
|
},
|
||||||
credentials,
|
credentials,
|
||||||
}).then((data) => data.map(parseUser))
|
}).then(({ data, ...rest }) => ({ ...rest, data: data.map(parseUser) }))
|
||||||
|
|
||||||
export const search2 = ({
|
export const search2 = ({
|
||||||
credentials,
|
credentials,
|
||||||
|
|
@ -404,10 +409,10 @@ export const search2 = ({
|
||||||
url,
|
url,
|
||||||
credentials,
|
credentials,
|
||||||
})
|
})
|
||||||
.then((data) => {
|
.then(({ data, ...rest }) => {
|
||||||
data.accounts = data.accounts.slice(0, limit).map((u) => parseUser(u))
|
data.accounts = data.accounts.slice(0, limit).map((u) => parseUser(u))
|
||||||
data.statuses = data.statuses.slice(0, limit).map((s) => parseStatus(s))
|
data.statuses = data.statuses.slice(0, limit).map((s) => parseStatus(s))
|
||||||
return data
|
return { ...rest, data }
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
throw new Error('Error fetching timeline', error)
|
throw new Error('Error fetching timeline', error)
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,13 @@
|
||||||
import { concat, each, last, map } from 'lodash'
|
import { concat, each, last, map } from 'lodash'
|
||||||
|
|
||||||
|
import { paramsString, promisedRequest } from './helpers.js'
|
||||||
|
import { fetchFriends, MASTODON_STATUS_URL } from './public.js'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
parseAttachment,
|
parseAttachment,
|
||||||
parseNotification,
|
|
||||||
parseSource,
|
|
||||||
parseStatus,
|
parseStatus,
|
||||||
parseUser,
|
parseUser,
|
||||||
} from 'src/services/entity_normalizer/entity_normalizer.service.js'
|
} from 'src/services/entity_normalizer/entity_normalizer.service.js'
|
||||||
import { paramsString, promisedRequest } from './helpers.js'
|
|
||||||
import { fetchFriends, MASTODON_STATUS_URL } from './public.js'
|
|
||||||
|
|
||||||
const MUTES_IMPORT_URL = '/api/pleroma/mutes_import'
|
const MUTES_IMPORT_URL = '/api/pleroma/mutes_import'
|
||||||
const BLOCKS_IMPORT_URL = '/api/pleroma/blocks_import'
|
const BLOCKS_IMPORT_URL = '/api/pleroma/blocks_import'
|
||||||
|
|
@ -99,42 +98,42 @@ export const favorite = ({ id, credentials }) =>
|
||||||
url: MASTODON_FAVORITE_URL(id),
|
url: MASTODON_FAVORITE_URL(id),
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
credentials,
|
credentials,
|
||||||
}).then((data) => parseStatus(data))
|
}).then(({ data, ...rest }) => ({ ...rest, data: parseStatus(data) }))
|
||||||
|
|
||||||
export const unfavorite = ({ id, credentials }) =>
|
export const unfavorite = ({ id, credentials }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
url: MASTODON_UNFAVORITE_URL(id),
|
url: MASTODON_UNFAVORITE_URL(id),
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
credentials,
|
credentials,
|
||||||
}).then((data) => parseStatus(data))
|
}).then(({ data, ...rest }) => ({ ...rest, data: parseStatus(data) }))
|
||||||
|
|
||||||
export const retweet = ({ id, credentials }) =>
|
export const retweet = ({ id, credentials }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
url: MASTODON_RETWEET_URL(id),
|
url: MASTODON_RETWEET_URL(id),
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
credentials,
|
credentials,
|
||||||
}).then((data) => parseStatus(data))
|
}).then(({ data, ...rest }) => ({ ...rest, data: parseStatus(data) }))
|
||||||
|
|
||||||
export const unretweet = ({ id, credentials }) =>
|
export const unretweet = ({ id, credentials }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
url: MASTODON_UNRETWEET_URL(id),
|
url: MASTODON_UNRETWEET_URL(id),
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
credentials,
|
credentials,
|
||||||
}).then((data) => parseStatus(data))
|
}).then(({ data, ...rest }) => ({ ...rest, data: parseStatus(data) }))
|
||||||
|
|
||||||
export const reactWithEmoji = ({ id, emoji, credentials }) =>
|
export const reactWithEmoji = ({ id, emoji, credentials }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
url: PLEROMA_EMOJI_REACT_URL(id, emoji),
|
url: PLEROMA_EMOJI_REACT_URL(id, emoji),
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
credentials,
|
credentials,
|
||||||
}).then(parseStatus)
|
}).then(({ data, ...rest }) => ({ ...rest, data: parseStatus(data) }))
|
||||||
|
|
||||||
export const unreactWithEmoji = ({ id, emoji, credentials }) =>
|
export const unreactWithEmoji = ({ id, emoji, credentials }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
url: PLEROMA_EMOJI_UNREACT_URL(id, emoji),
|
url: PLEROMA_EMOJI_UNREACT_URL(id, emoji),
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
credentials,
|
credentials,
|
||||||
}).then(parseStatus)
|
}).then(({ data, ...rest }) => ({ ...rest, data: parseStatus(data) }))
|
||||||
|
|
||||||
export const bookmarkStatus = ({ id, credentials, ...options }) =>
|
export const bookmarkStatus = ({ id, credentials, ...options }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
|
|
@ -158,28 +157,28 @@ export const pinOwnStatus = ({ id, credentials }) =>
|
||||||
url: MASTODON_PIN_OWN_STATUS(id),
|
url: MASTODON_PIN_OWN_STATUS(id),
|
||||||
credentials,
|
credentials,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
}).then((data) => parseStatus(data))
|
}).then(({ data, ...rest }) => ({ ...rest, data: parseStatus(data) }))
|
||||||
|
|
||||||
export const unpinOwnStatus = ({ id, credentials }) =>
|
export const unpinOwnStatus = ({ id, credentials }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
url: MASTODON_UNPIN_OWN_STATUS(id),
|
url: MASTODON_UNPIN_OWN_STATUS(id),
|
||||||
credentials,
|
credentials,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
}).then((data) => parseStatus(data))
|
}).then(({ data, ...rest }) => ({ ...rest, data: parseStatus(data) }))
|
||||||
|
|
||||||
export const muteConversation = ({ id, credentials }) =>
|
export const muteConversation = ({ id, credentials }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
url: MASTODON_MUTE_CONVERSATION(id),
|
url: MASTODON_MUTE_CONVERSATION(id),
|
||||||
credentials,
|
credentials,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
}).then((data) => parseStatus(data))
|
}).then(({ data, ...rest }) => ({ ...rest, data: parseStatus(data) }))
|
||||||
|
|
||||||
export const unmuteConversation = ({ id, credentials }) =>
|
export const unmuteConversation = ({ id, credentials }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
url: MASTODON_UNMUTE_CONVERSATION(id),
|
url: MASTODON_UNMUTE_CONVERSATION(id),
|
||||||
credentials,
|
credentials,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
}).then((data) => parseStatus(data))
|
}).then(({ data, ...rest }) => ({ ...rest, data: parseStatus(data) }))
|
||||||
|
|
||||||
export const vote = ({ pollId, choices, credentials }) => {
|
export const vote = ({ pollId, choices, credentials }) => {
|
||||||
const form = new FormData()
|
const form = new FormData()
|
||||||
|
|
@ -256,7 +255,7 @@ export const postStatus = ({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
credentials,
|
credentials,
|
||||||
headers,
|
headers,
|
||||||
}).then((data) => (data.error ? data : parseStatus(data)))
|
}).then(({ data, ...rest }) => ({ ...rest, data: parseStatus(data) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
export const editStatus = ({
|
export const editStatus = ({
|
||||||
|
|
@ -299,7 +298,7 @@ export const editStatus = ({
|
||||||
formData: form,
|
formData: form,
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
credentials,
|
credentials,
|
||||||
}).then((data) => (data.error ? data : parseStatus(data)))
|
}).then(({ data, ...rest }) => ({ ...rest, data: parseStatus(data) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
export const deleteStatus = ({ id, credentials }) =>
|
export const deleteStatus = ({ id, credentials }) =>
|
||||||
|
|
@ -315,7 +314,7 @@ export const uploadMedia = ({ formData, credentials }) =>
|
||||||
formData,
|
formData,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
credentials,
|
credentials,
|
||||||
}).then((data) => parseAttachment(data))
|
}).then(({ data, ...rest }) => ({ ...rest, data: parseAttachment(data) }))
|
||||||
|
|
||||||
export const setMediaDescription = ({ id, description, credentials }) =>
|
export const setMediaDescription = ({ id, description, credentials }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
|
|
@ -325,7 +324,7 @@ export const setMediaDescription = ({ id, description, credentials }) =>
|
||||||
payload: {
|
payload: {
|
||||||
description,
|
description,
|
||||||
},
|
},
|
||||||
}).then((data) => parseAttachment(data))
|
}).then(({ data, ...rest }) => ({ ...rest, data: parseAttachment(data) }))
|
||||||
|
|
||||||
// #Notifications
|
// #Notifications
|
||||||
export const dismissNotification = ({ credentials, id }) =>
|
export const dismissNotification = ({ credentials, id }) =>
|
||||||
|
|
@ -456,12 +455,7 @@ export const updateProfileImages = ({
|
||||||
credentials,
|
credentials,
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
formData: form,
|
formData: form,
|
||||||
}).then((data) => {
|
}).then(({ data, ...rest }) => ({ ...rest, data: parseUser(data) }))
|
||||||
if (data.error) {
|
|
||||||
throw new Error(data.error)
|
|
||||||
}
|
|
||||||
return parseUser(data)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const updateProfile = ({ credentials, params }) => {
|
export const updateProfile = ({ credentials, params }) => {
|
||||||
|
|
@ -489,7 +483,7 @@ export const updateProfile = ({ credentials, params }) => {
|
||||||
credentials,
|
credentials,
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
formData,
|
formData,
|
||||||
}).then((data) => parseUser(data))
|
}).then(({ data, ...rest }) => ({ ...rest, data: parseUser(data) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
export const updateProfileJSON = ({ credentials, params }) =>
|
export const updateProfileJSON = ({ credentials, params }) =>
|
||||||
|
|
@ -498,7 +492,7 @@ export const updateProfileJSON = ({ credentials, params }) =>
|
||||||
credentials,
|
credentials,
|
||||||
payload: params,
|
payload: params,
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
}).then((data) => parseUser(data))
|
}).then(({ data, ...rest }) => ({ ...rest, data: parseUser(data) }))
|
||||||
|
|
||||||
export const changeEmail = ({ credentials, email, password }) => {
|
export const changeEmail = ({ credentials, email, password }) => {
|
||||||
const form = new FormData()
|
const form = new FormData()
|
||||||
|
|
@ -671,7 +665,7 @@ export const fetchFollowRequests = ({ credentials }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
url: MASTODON_FOLLOW_REQUESTS_URL,
|
url: MASTODON_FOLLOW_REQUESTS_URL,
|
||||||
credentials,
|
credentials,
|
||||||
}).then((data) => data.map(parseUser))
|
}).then(({ data, ...rest }) => ({ ...rest, data: data.map(parseUser) }))
|
||||||
|
|
||||||
export const approveUser = ({ id, credentials }) =>
|
export const approveUser = ({ id, credentials }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
|
|
@ -701,7 +695,7 @@ export const fetchMutes = ({ maxId, credentials }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
url: MASTODON_USER_MUTES_URL({ maxId, withRelationships: true }),
|
url: MASTODON_USER_MUTES_URL({ maxId, withRelationships: true }),
|
||||||
credentials,
|
credentials,
|
||||||
}).then((users) => users.map(parseUser))
|
}).then(({ data, ...rest }) => ({ ...rest, data: data.map(parseUser) }))
|
||||||
|
|
||||||
export const muteUser = ({ id, expiresIn, credentials }) => {
|
export const muteUser = ({ id, expiresIn, credentials }) => {
|
||||||
const payload = {}
|
const payload = {}
|
||||||
|
|
@ -728,7 +722,7 @@ export const fetchBlocks = ({ maxId, credentials }) =>
|
||||||
promisedRequest({
|
promisedRequest({
|
||||||
url: MASTODON_USER_BLOCKS_URL({ maxId, withRelationships: true }),
|
url: MASTODON_USER_BLOCKS_URL({ maxId, withRelationships: true }),
|
||||||
credentials,
|
credentials,
|
||||||
}).then((users) => users.map(parseUser))
|
}).then(({ data, ...rest }) => ({ ...rest, data: data.map(parseUser) }))
|
||||||
|
|
||||||
export const blockUser = ({ id, expiresIn, credentials }) => {
|
export const blockUser = ({ id, expiresIn, credentials }) => {
|
||||||
const payload = {}
|
const payload = {}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import { mapGetters, mapState } from 'vuex'
|
||||||
import ChatMessage from 'src/components/chat_message/chat_message.vue'
|
import ChatMessage from 'src/components/chat_message/chat_message.vue'
|
||||||
import ChatTitle from 'src/components/chat_title/chat_title.vue'
|
import ChatTitle from 'src/components/chat_title/chat_title.vue'
|
||||||
import PostStatusForm from 'src/components/post_status_form/post_status_form.vue'
|
import PostStatusForm from 'src/components/post_status_form/post_status_form.vue'
|
||||||
import { WSConnectionStatus } from 'src/api/public.js'
|
|
||||||
import chatService from '../../services/chat_service/chat_service.js'
|
import chatService from '../../services/chat_service/chat_service.js'
|
||||||
import { buildFakeMessage } from '../../services/chat_utils/chat_utils.js'
|
import { buildFakeMessage } from '../../services/chat_utils/chat_utils.js'
|
||||||
import { promiseInterval } from '../../services/promise_interval/promise_interval.js'
|
import { promiseInterval } from '../../services/promise_interval/promise_interval.js'
|
||||||
|
|
@ -24,6 +23,7 @@ import {
|
||||||
getOrCreateChat,
|
getOrCreateChat,
|
||||||
sendChatMessage,
|
sendChatMessage,
|
||||||
} from 'src/api/chats.js'
|
} from 'src/api/chats.js'
|
||||||
|
import { WSConnectionStatus } from 'src/api/public.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import { faChevronDown, faChevronLeft } from '@fortawesome/free-solid-svg-icons'
|
import { faChevronDown, faChevronLeft } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,16 @@ import { mapState } from 'vuex'
|
||||||
import QuickFilterSettings from 'src/components/quick_filter_settings/quick_filter_settings.vue'
|
import QuickFilterSettings from 'src/components/quick_filter_settings/quick_filter_settings.vue'
|
||||||
import QuickViewSettings from 'src/components/quick_view_settings/quick_view_settings.vue'
|
import QuickViewSettings from 'src/components/quick_view_settings/quick_view_settings.vue'
|
||||||
import ThreadTree from 'src/components/thread_tree/thread_tree.vue'
|
import ThreadTree from 'src/components/thread_tree/thread_tree.vue'
|
||||||
import { WSConnectionStatus } from 'src/api/public.js'
|
|
||||||
|
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
|
||||||
import { useInterfaceStore } from 'src/stores/interface'
|
import { useInterfaceStore } from 'src/stores/interface'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
|
|
||||||
import { fetchConversation, fetchStatus } from 'src/api/public.js'
|
import {
|
||||||
|
fetchConversation,
|
||||||
|
fetchStatus,
|
||||||
|
WSConnectionStatus,
|
||||||
|
} from 'src/api/public.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import {
|
import {
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,9 @@ import SharedComputedObject from '../helpers/shared_computed_object.js'
|
||||||
import UnitSetting from '../helpers/unit_setting.vue'
|
import UnitSetting from '../helpers/unit_setting.vue'
|
||||||
import Preview from './old_theme_tab/theme_preview.vue'
|
import Preview from './old_theme_tab/theme_preview.vue'
|
||||||
|
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
import { normalizeThemeData, useInterfaceStore } from 'src/stores/interface.js'
|
import { normalizeThemeData, useInterfaceStore } from 'src/stores/interface.js'
|
||||||
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
|
|
||||||
import { updateProfileImages } from 'src/api/user.js'
|
import { updateProfileImages } from 'src/api/user.js'
|
||||||
import { newImporter } from 'src/services/export_import/export_import.js'
|
import { newImporter } from 'src/services/export_import/export_import.js'
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,10 @@ import IntegerSetting from '../helpers/integer_setting.vue'
|
||||||
import SharedComputedObject from '../helpers/shared_computed_object.js'
|
import SharedComputedObject from '../helpers/shared_computed_object.js'
|
||||||
import UnitSetting from '../helpers/unit_setting.vue'
|
import UnitSetting from '../helpers/unit_setting.vue'
|
||||||
|
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
|
||||||
import { updateProfile } from 'src/api/user.js'
|
import { updateProfile } from 'src/api/user.js'
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,11 @@ import FloatSetting from '../helpers/float_setting.vue'
|
||||||
import SharedComputedObject from '../helpers/shared_computed_object.js'
|
import SharedComputedObject from '../helpers/shared_computed_object.js'
|
||||||
import UnitSetting from '../helpers/unit_setting.vue'
|
import UnitSetting from '../helpers/unit_setting.vue'
|
||||||
|
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
||||||
import { useLocalConfigStore } from 'src/stores/local_config.js'
|
import { useLocalConfigStore } from 'src/stores/local_config.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
|
||||||
import { updateProfile } from 'src/api/user.js'
|
import { updateProfile } from 'src/api/user.js'
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import { Socket } from 'phoenix'
|
import { Socket } from 'phoenix'
|
||||||
|
|
||||||
import { WSConnectionStatus } from 'src/api/public.js'
|
|
||||||
import { maybeShowChatNotification } from '../services/chat_utils/chat_utils.js'
|
import { maybeShowChatNotification } from '../services/chat_utils/chat_utils.js'
|
||||||
|
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
|
|
@ -13,6 +12,7 @@ import {
|
||||||
fetchTimeline,
|
fetchTimeline,
|
||||||
getMastodonSocketURI,
|
getMastodonSocketURI,
|
||||||
ProcessedWS,
|
ProcessedWS,
|
||||||
|
WSConnectionStatus,
|
||||||
} from 'src/api/public.js'
|
} from 'src/api/public.js'
|
||||||
import followRequestFetcher from 'src/services/follow_request_fetcher/follow_request_fetcher.service'
|
import followRequestFetcher from 'src/services/follow_request_fetcher/follow_request_fetcher.service'
|
||||||
import notificationsFetcher from 'src/services/notifications_fetcher/notifications_fetcher.service.js'
|
import notificationsFetcher from 'src/services/notifications_fetcher/notifications_fetcher.service.js'
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import { markNotificationsAsSeen } from 'src/api/user.js'
|
|
||||||
import {
|
import {
|
||||||
closeAllDesktopNotifications,
|
closeAllDesktopNotifications,
|
||||||
closeDesktopNotification,
|
closeDesktopNotification,
|
||||||
|
|
@ -15,7 +14,7 @@ import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
import { useReportsStore } from 'src/stores/reports.js'
|
import { useReportsStore } from 'src/stores/reports.js'
|
||||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
|
||||||
import { dismissNotification } from 'src/api/user.js'
|
import { dismissNotification, markNotificationsAsSeen } from 'src/api/user.js'
|
||||||
|
|
||||||
const emptyNotifications = () => ({
|
const emptyNotifications = () => ({
|
||||||
desktopNotificationSilence: true,
|
desktopNotificationSilence: true,
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,7 @@ import { get, set } from 'lodash'
|
||||||
|
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
|
|
||||||
import {
|
import { updateNotificationSettings, updateProfile } from 'src/api/user.js'
|
||||||
updateNotificationSettings,
|
|
||||||
updateProfile,
|
|
||||||
} from 'src/api/user.js'
|
|
||||||
|
|
||||||
const defaultApi = ({ rootState, commit }, { path, value }) => {
|
const defaultApi = ({ rootState, commit }, { path, value }) => {
|
||||||
const params = {}
|
const params = {}
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ const getLatestScrobble = (state, user) => {
|
||||||
state.scrobblesNextFetch[user.id] = Date.now() + 24 * 60 * 60 * 1000
|
state.scrobblesNextFetch[user.id] = Date.now() + 24 * 60 * 60 * 1000
|
||||||
if (!scrobblesSupport) return
|
if (!scrobblesSupport) return
|
||||||
fetchScrobbles({ accountId: user.id })
|
fetchScrobbles({ accountId: user.id })
|
||||||
.then((scrobbles) => {
|
.then(({ data: scrobbles }) => {
|
||||||
if (scrobbles?.error) {
|
if (scrobbles?.error) {
|
||||||
useInstanceCapabilitiesStore().set('pleromaScrobblesAvailable', false)
|
useInstanceCapabilitiesStore().set('pleromaScrobblesAvailable', false)
|
||||||
return
|
return
|
||||||
|
|
@ -627,7 +627,7 @@ const statuses = {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
fetchStatus({ rootState, dispatch }, id) {
|
fetchStatus({ rootState, dispatch }, id) {
|
||||||
return fetchStatus({ id }).then((status) =>
|
return fetchStatus({ id }).then(({ data: status }) =>
|
||||||
dispatch('addNewStatuses', { statuses: [status] }),
|
dispatch('addNewStatuses', { statuses: [status] }),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
@ -635,10 +635,10 @@ const statuses = {
|
||||||
return fetchStatusSource({
|
return fetchStatusSource({
|
||||||
id: status.id,
|
id: status.id,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
})
|
}).then(({ data }) => data)
|
||||||
},
|
},
|
||||||
fetchStatusHistory(_, status) {
|
fetchStatusHistory(_, status) {
|
||||||
return fetchStatusHistory({ status })
|
return fetchStatusHistory({ status }).then(({ data }) => data)
|
||||||
},
|
},
|
||||||
deleteStatus({ rootState, commit }, status) {
|
deleteStatus({ rootState, commit }, status) {
|
||||||
deleteStatus({
|
deleteStatus({
|
||||||
|
|
@ -670,7 +670,7 @@ const statuses = {
|
||||||
favorite({
|
favorite({
|
||||||
id: status.id,
|
id: status.id,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((status) =>
|
}).then(({ data: status }) =>
|
||||||
commit('setFavoritedConfirm', {
|
commit('setFavoritedConfirm', {
|
||||||
status,
|
status,
|
||||||
user: rootState.users.currentUser,
|
user: rootState.users.currentUser,
|
||||||
|
|
@ -683,7 +683,7 @@ const statuses = {
|
||||||
unfavorite({
|
unfavorite({
|
||||||
id: status.id,
|
id: status.id,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((status) =>
|
}).then(({ data: status }) =>
|
||||||
commit('setFavoritedConfirm', {
|
commit('setFavoritedConfirm', {
|
||||||
status,
|
status,
|
||||||
user: rootState.users.currentUser,
|
user: rootState.users.currentUser,
|
||||||
|
|
@ -694,7 +694,7 @@ const statuses = {
|
||||||
fetchPinnedStatuses({
|
fetchPinnedStatuses({
|
||||||
id: userId,
|
id: userId,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((statuses) =>
|
}).then(({ data: statuses }) =>
|
||||||
dispatch('addNewStatuses', {
|
dispatch('addNewStatuses', {
|
||||||
statuses,
|
statuses,
|
||||||
timeline: 'user',
|
timeline: 'user',
|
||||||
|
|
@ -708,25 +708,29 @@ const statuses = {
|
||||||
return pinOwnStatus({
|
return pinOwnStatus({
|
||||||
id: statusId,
|
id: statusId,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((status) => dispatch('addNewStatuses', { statuses: [status] }))
|
}).then(({ data: status }) =>
|
||||||
|
dispatch('addNewStatuses', { statuses: [status] }),
|
||||||
|
)
|
||||||
},
|
},
|
||||||
unpinStatus({ rootState, dispatch }, statusId) {
|
unpinStatus({ rootState, dispatch }, statusId) {
|
||||||
return unpinOwnStatus({
|
return unpinOwnStatus({
|
||||||
id: statusId,
|
id: statusId,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((status) => dispatch('addNewStatuses', { statuses: [status] }))
|
}).then(({ data: status }) =>
|
||||||
|
dispatch('addNewStatuses', { statuses: [status] }),
|
||||||
|
)
|
||||||
},
|
},
|
||||||
muteConversation({ rootState, commit }, { id: statusId }) {
|
muteConversation({ rootState, commit }, { id: statusId }) {
|
||||||
return muteConversation({
|
return muteConversation({
|
||||||
id: statusId,
|
id: statusId,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((status) => commit('setMutedStatus', status))
|
}).then(({ data: status }) => commit('setMutedStatus', status))
|
||||||
},
|
},
|
||||||
unmuteConversation({ rootState, commit }, { id: statusId }) {
|
unmuteConversation({ rootState, commit }, { id: statusId }) {
|
||||||
return unmuteConversation({
|
return unmuteConversation({
|
||||||
id: statusId,
|
id: statusId,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((status) => commit('setMutedStatus', status))
|
}).then(({ data: status }) => commit('setMutedStatus', status))
|
||||||
},
|
},
|
||||||
retweet({ rootState, commit }, status) {
|
retweet({ rootState, commit }, status) {
|
||||||
// Optimistic retweeting...
|
// Optimistic retweeting...
|
||||||
|
|
@ -734,7 +738,7 @@ const statuses = {
|
||||||
retweet({
|
retweet({
|
||||||
id: status.id,
|
id: status.id,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((status) =>
|
}).then(({ data: status }) =>
|
||||||
commit('setRetweetedConfirm', {
|
commit('setRetweetedConfirm', {
|
||||||
status: status.retweeted_status,
|
status: status.retweeted_status,
|
||||||
user: rootState.users.currentUser,
|
user: rootState.users.currentUser,
|
||||||
|
|
@ -747,7 +751,7 @@ const statuses = {
|
||||||
unretweet({
|
unretweet({
|
||||||
id: status.id,
|
id: status.id,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((status) =>
|
}).then(({ data: status }) =>
|
||||||
commit('setRetweetedConfirm', {
|
commit('setRetweetedConfirm', {
|
||||||
status,
|
status,
|
||||||
user: rootState.users.currentUser,
|
user: rootState.users.currentUser,
|
||||||
|
|
@ -760,7 +764,7 @@ const statuses = {
|
||||||
id: status.id,
|
id: status.id,
|
||||||
folder_id: status.bookmark_folder_id,
|
folder_id: status.bookmark_folder_id,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((status) => {
|
}).then(({ data: status }) => {
|
||||||
commit('setBookmarkedConfirm', { status })
|
commit('setBookmarkedConfirm', { status })
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
@ -769,7 +773,7 @@ const statuses = {
|
||||||
unbookmarkStatus({
|
unbookmarkStatus({
|
||||||
id: status.id,
|
id: status.id,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((status) => {
|
}).then(({ data: status }) => {
|
||||||
commit('setBookmarkedConfirm', { status })
|
commit('setBookmarkedConfirm', { status })
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
@ -789,7 +793,7 @@ const statuses = {
|
||||||
id,
|
id,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}),
|
}),
|
||||||
]).then(([favoritedByUsers, rebloggedByUsers]) => {
|
]).then(([{ data: favoritedByUsers }, { data: rebloggedByUsers }]) => {
|
||||||
commit('addFavs', {
|
commit('addFavs', {
|
||||||
id,
|
id,
|
||||||
favoritedByUsers,
|
favoritedByUsers,
|
||||||
|
|
@ -832,7 +836,7 @@ const statuses = {
|
||||||
return fetchEmojiReactions({
|
return fetchEmojiReactions({
|
||||||
id,
|
id,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((emojiReactions) => {
|
}).then(({ data: emojiReactions }) => {
|
||||||
commit('addEmojiReactionsBy', {
|
commit('addEmojiReactionsBy', {
|
||||||
id,
|
id,
|
||||||
emojiReactions,
|
emojiReactions,
|
||||||
|
|
@ -844,7 +848,7 @@ const statuses = {
|
||||||
fetchFavoritedByUsers({
|
fetchFavoritedByUsers({
|
||||||
id,
|
id,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((favoritedByUsers) =>
|
}).then(({ data: favoritedByUsers }) =>
|
||||||
commit('addFavs', {
|
commit('addFavs', {
|
||||||
id,
|
id,
|
||||||
favoritedByUsers,
|
favoritedByUsers,
|
||||||
|
|
@ -856,7 +860,7 @@ const statuses = {
|
||||||
fetchRebloggedByUsers({
|
fetchRebloggedByUsers({
|
||||||
id,
|
id,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((rebloggedByUsers) =>
|
}).then(({ data: rebloggedByUsers }) =>
|
||||||
commit('addRepeats', {
|
commit('addRepeats', {
|
||||||
id,
|
id,
|
||||||
rebloggedByUsers,
|
rebloggedByUsers,
|
||||||
|
|
@ -873,7 +877,7 @@ const statuses = {
|
||||||
following,
|
following,
|
||||||
type,
|
type,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((data) => {
|
}).then(({ data }) => {
|
||||||
store.commit('addNewUsers', data.accounts)
|
store.commit('addNewUsers', data.accounts)
|
||||||
store.commit(
|
store.commit(
|
||||||
'addNewUsers',
|
'addNewUsers',
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ import {
|
||||||
uniq,
|
uniq,
|
||||||
} from 'lodash'
|
} from 'lodash'
|
||||||
|
|
||||||
import { register } from 'src/api/public.js'
|
|
||||||
import oauthApi from '../services/new_api/oauth.js'
|
import oauthApi from '../services/new_api/oauth.js'
|
||||||
import {
|
import {
|
||||||
registerPushNotifications,
|
registerPushNotifications,
|
||||||
|
|
@ -37,17 +36,21 @@ import {
|
||||||
fetchUser,
|
fetchUser,
|
||||||
fetchUserByName,
|
fetchUserByName,
|
||||||
getCaptcha,
|
getCaptcha,
|
||||||
|
register,
|
||||||
searchUsers,
|
searchUsers,
|
||||||
verifyCredentials,
|
verifyCredentials,
|
||||||
} from 'src/api/public.js'
|
} from 'src/api/public.js'
|
||||||
import {
|
import {
|
||||||
|
blockUser as apiBlockUser,
|
||||||
|
muteUser as apiMuteUser,
|
||||||
|
unblockUser as apiUnblockUser,
|
||||||
|
unmuteUser as apiUnmuteUser,
|
||||||
fetchBlocks,
|
fetchBlocks,
|
||||||
fetchDomainMutes,
|
fetchDomainMutes,
|
||||||
fetchMutes,
|
fetchMutes,
|
||||||
fetchUserInLists,
|
fetchUserInLists,
|
||||||
fetchUserRelationship,
|
fetchUserRelationship,
|
||||||
followUser,
|
followUser,
|
||||||
muteUser,
|
|
||||||
} from 'src/api/user.js'
|
} from 'src/api/user.js'
|
||||||
|
|
||||||
// TODO: Unify with mergeOrAdd in statuses.js
|
// TODO: Unify with mergeOrAdd in statuses.js
|
||||||
|
|
@ -92,7 +95,7 @@ const blockUser = (store, args) => {
|
||||||
store.commit('updateUserRelationship', [predictedRelationship])
|
store.commit('updateUserRelationship', [predictedRelationship])
|
||||||
store.commit('addBlockId', id)
|
store.commit('addBlockId', id)
|
||||||
|
|
||||||
return blockUser({ id, expiresIn }).then((relationship) => {
|
return apiBlockUser({ id, expiresIn }).then(({ data: relationship }) => {
|
||||||
store.commit('updateUserRelationship', [relationship])
|
store.commit('updateUserRelationship', [relationship])
|
||||||
store.commit('addBlockId', id)
|
store.commit('addBlockId', id)
|
||||||
|
|
||||||
|
|
@ -106,7 +109,7 @@ const blockUser = (store, args) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const unblockUser = (store, id) => {
|
const unblockUser = (store, id) => {
|
||||||
return unblockUser({ id }).then((relationship) =>
|
return apiUnblockUser({ id }).then(({ data: relationship }) =>
|
||||||
store.commit('updateUserRelationship', [relationship]),
|
store.commit('updateUserRelationship', [relationship]),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -123,7 +126,7 @@ const editUserNote = (store, { id, comment }) => {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const localMuteUser = (store, args) => {
|
const muteUser = (store, args) => {
|
||||||
const id = typeof args === 'object' ? args.id : args
|
const id = typeof args === 'object' ? args.id : args
|
||||||
const expiresIn = typeof args === 'object' ? args.expiresIn : 0
|
const expiresIn = typeof args === 'object' ? args.expiresIn : 0
|
||||||
|
|
||||||
|
|
@ -131,11 +134,11 @@ const localMuteUser = (store, args) => {
|
||||||
store.commit('updateUserRelationship', [predictedRelationship])
|
store.commit('updateUserRelationship', [predictedRelationship])
|
||||||
store.commit('addMuteId', id)
|
store.commit('addMuteId', id)
|
||||||
|
|
||||||
return muteUser({
|
return apiMuteUser({
|
||||||
id,
|
id,
|
||||||
expiresIn,
|
expiresIn,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((relationship) => {
|
}).then(({ data: relationship }) => {
|
||||||
store.commit('updateUserRelationship', [relationship])
|
store.commit('updateUserRelationship', [relationship])
|
||||||
store.commit('addMuteId', id)
|
store.commit('addMuteId', id)
|
||||||
})
|
})
|
||||||
|
|
@ -146,7 +149,7 @@ const unmuteUser = (store, id) => {
|
||||||
predictedRelationship.muting = false
|
predictedRelationship.muting = false
|
||||||
store.commit('updateUserRelationship', [predictedRelationship])
|
store.commit('updateUserRelationship', [predictedRelationship])
|
||||||
|
|
||||||
return unmuteUser({ id }).then((relationship) =>
|
return apiUnmuteUser({ id }).then(({ data: relationship }) =>
|
||||||
store.commit('updateUserRelationship', [relationship]),
|
store.commit('updateUserRelationship', [relationship]),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -156,9 +159,9 @@ const hideReblogs = (store, userId) => {
|
||||||
id: userId,
|
id: userId,
|
||||||
reblogs: false,
|
reblogs: false,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((relationship) => {
|
}).then(({ data: relationship }) =>
|
||||||
store.commit('updateUserRelationship', [relationship])
|
store.commit('updateUserRelationship', [relationship]),
|
||||||
})
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const showReblogs = (store, userId) => {
|
const showReblogs = (store, userId) => {
|
||||||
|
|
@ -166,7 +169,7 @@ const showReblogs = (store, userId) => {
|
||||||
id: userId,
|
id: userId,
|
||||||
reblogs: true,
|
reblogs: true,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((relationship) =>
|
}).then(({ data: relationship }) =>
|
||||||
store.commit('updateUserRelationship', [relationship]),
|
store.commit('updateUserRelationship', [relationship]),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -406,16 +409,24 @@ const users = {
|
||||||
return fetchUser({
|
return fetchUser({
|
||||||
id,
|
id,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((user) => {
|
|
||||||
store.commit('addNewUsers', [user])
|
|
||||||
return user
|
|
||||||
})
|
})
|
||||||
|
.then(({ data: user }) => {
|
||||||
|
store.commit('addNewUsers', [user])
|
||||||
|
return user
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
if (error.statusCode === 404) {
|
||||||
|
console.warn(`User ${id} not found`)
|
||||||
|
} else {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
fetchUserByName(store, name) {
|
fetchUserByName(store, name) {
|
||||||
return fetchUserByName({
|
return fetchUserByName({
|
||||||
name,
|
name,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((user) => {
|
}).then(({ data: user }) => {
|
||||||
store.commit('addNewUsers', [user])
|
store.commit('addNewUsers', [user])
|
||||||
return user
|
return user
|
||||||
})
|
})
|
||||||
|
|
@ -425,7 +436,7 @@ const users = {
|
||||||
fetchUserRelationship({
|
fetchUserRelationship({
|
||||||
id,
|
id,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((relationships) =>
|
}).then(({ data: relationships }) =>
|
||||||
store.commit('updateUserRelationship', relationships),
|
store.commit('updateUserRelationship', relationships),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -435,7 +446,9 @@ const users = {
|
||||||
fetchUserInLists({
|
fetchUserInLists({
|
||||||
id,
|
id,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((inLists) => store.commit('updateUserInLists', { id, inLists }))
|
}).then(({ data: inLists }) =>
|
||||||
|
store.commit('updateUserInLists', { id, inLists }),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fetchBlocks(store, args) {
|
fetchBlocks(store, args) {
|
||||||
|
|
@ -445,7 +458,7 @@ const users = {
|
||||||
return fetchBlocks({
|
return fetchBlocks({
|
||||||
maxId,
|
maxId,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((blocks) => {
|
}).then(({ data: blocks }) => {
|
||||||
if (reset) {
|
if (reset) {
|
||||||
store.commit('saveBlockIds', map(blocks, 'id'))
|
store.commit('saveBlockIds', map(blocks, 'id'))
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -483,7 +496,7 @@ const users = {
|
||||||
return fetchMutes({
|
return fetchMutes({
|
||||||
maxId,
|
maxId,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((mutes) => {
|
}).then(({ data: mutes }) => {
|
||||||
if (reset) {
|
if (reset) {
|
||||||
store.commit('saveMuteIds', map(mutes, 'id'))
|
store.commit('saveMuteIds', map(mutes, 'id'))
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -497,7 +510,7 @@ const users = {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
muteUser(store, data) {
|
muteUser(store, data) {
|
||||||
return localMuteUser(store, data)
|
return muteUser(store, data)
|
||||||
},
|
},
|
||||||
unmuteUser(store, id) {
|
unmuteUser(store, id) {
|
||||||
return unmuteUser(store, id)
|
return unmuteUser(store, id)
|
||||||
|
|
@ -509,7 +522,7 @@ const users = {
|
||||||
return showReblogs(store, id)
|
return showReblogs(store, id)
|
||||||
},
|
},
|
||||||
muteUsers(store, data = []) {
|
muteUsers(store, data = []) {
|
||||||
return Promise.all(data.map((d) => localMuteUser(store, d)))
|
return Promise.all(data.map((d) => muteUser(store, d)))
|
||||||
},
|
},
|
||||||
unmuteUsers(store, ids = []) {
|
unmuteUsers(store, ids = []) {
|
||||||
return Promise.all(ids.map((d) => unmuteUser(store, d)))
|
return Promise.all(ids.map((d) => unmuteUser(store, d)))
|
||||||
|
|
@ -517,7 +530,7 @@ const users = {
|
||||||
fetchDomainMutes(store) {
|
fetchDomainMutes(store) {
|
||||||
return fetchDomainMutes({
|
return fetchDomainMutes({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((domainMutes) => {
|
}).then(({ data: domainMutes }) => {
|
||||||
store.commit('saveDomainMutes', domainMutes)
|
store.commit('saveDomainMutes', domainMutes)
|
||||||
return domainMutes
|
return domainMutes
|
||||||
})
|
})
|
||||||
|
|
@ -541,7 +554,7 @@ const users = {
|
||||||
id,
|
id,
|
||||||
maxId,
|
maxId,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((friends) => {
|
}).then(({ data: friends }) => {
|
||||||
commit('addNewUsers', friends)
|
commit('addNewUsers', friends)
|
||||||
commit('saveFriendIds', { id, friendIds: map(friends, 'id') })
|
commit('saveFriendIds', { id, friendIds: map(friends, 'id') })
|
||||||
return friends
|
return friends
|
||||||
|
|
@ -554,7 +567,7 @@ const users = {
|
||||||
id,
|
id,
|
||||||
maxId,
|
maxId,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((followers) => {
|
}).then(({ data: followers }) => {
|
||||||
commit('addNewUsers', followers)
|
commit('addNewUsers', followers)
|
||||||
commit('saveFollowerIds', { id, followerIds: map(followers, 'id') })
|
commit('saveFollowerIds', { id, followerIds: map(followers, 'id') })
|
||||||
return followers
|
return followers
|
||||||
|
|
@ -571,7 +584,7 @@ const users = {
|
||||||
id,
|
id,
|
||||||
notify: true,
|
notify: true,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((relationship) =>
|
}).then(({ data: relationship }) =>
|
||||||
commit('updateUserRelationship', [relationship]),
|
commit('updateUserRelationship', [relationship]),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
@ -580,7 +593,7 @@ const users = {
|
||||||
id,
|
id,
|
||||||
notify: false,
|
notify: false,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((relationship) =>
|
}).then(({ data: relationship }) =>
|
||||||
commit('updateUserRelationship', [relationship]),
|
commit('updateUserRelationship', [relationship]),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
@ -646,7 +659,7 @@ const users = {
|
||||||
return searchUsers({
|
return searchUsers({
|
||||||
query,
|
query,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((users) => {
|
}).then(({ data: users }) => {
|
||||||
commit('addNewUsers', users)
|
commit('addNewUsers', users)
|
||||||
return users
|
return users
|
||||||
})
|
})
|
||||||
|
|
@ -657,7 +670,7 @@ const users = {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const token = await oauthStore.ensureAppToken()
|
const token = await oauthStore.ensureAppToken()
|
||||||
const data = await register({
|
const { data } = await register({
|
||||||
credentials: token,
|
credentials: token,
|
||||||
params: { ...userInfo },
|
params: { ...userInfo },
|
||||||
})
|
})
|
||||||
|
|
@ -681,7 +694,7 @@ const users = {
|
||||||
getCaptcha(store) {
|
getCaptcha(store) {
|
||||||
return getCaptcha({
|
return getCaptcha({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
})
|
}).then(({ data }) => data)
|
||||||
},
|
},
|
||||||
|
|
||||||
logout(store) {
|
logout(store) {
|
||||||
|
|
@ -727,135 +740,128 @@ const users = {
|
||||||
verifyCredentials({
|
verifyCredentials({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
})
|
})
|
||||||
.then((data) => {
|
.then(({ data: user }) => {
|
||||||
if (!data.error) {
|
// user.credentials = userCredentials
|
||||||
const user = data
|
user.credentials = accessToken
|
||||||
// user.credentials = userCredentials
|
user.blockIds = []
|
||||||
user.credentials = accessToken
|
user.muteIds = []
|
||||||
user.blockIds = []
|
user.domainMutes = []
|
||||||
user.muteIds = []
|
commit('setCurrentUser', user)
|
||||||
user.domainMutes = []
|
|
||||||
commit('setCurrentUser', user)
|
|
||||||
|
|
||||||
useSyncConfigStore()
|
useSyncConfigStore()
|
||||||
.initSyncConfig(user)
|
.initSyncConfig(user)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
useInterfaceStore()
|
useInterfaceStore()
|
||||||
.applyTheme()
|
.applyTheme()
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
console.error('Error setting theme', e)
|
console.error('Error setting theme', e)
|
||||||
})
|
})
|
||||||
})
|
|
||||||
useUserHighlightStore().initUserHighlight(user)
|
|
||||||
commit('addNewUsers', [user])
|
|
||||||
|
|
||||||
useEmojiStore().fetchEmoji()
|
|
||||||
|
|
||||||
getNotificationPermission().then((permission) =>
|
|
||||||
useInterfaceStore().setNotificationPermission(permission),
|
|
||||||
)
|
|
||||||
|
|
||||||
// Do server-side storage migrations
|
|
||||||
|
|
||||||
// Debug snippet to clean up storage and reset migrations
|
|
||||||
/*
|
|
||||||
// Reset wordfilter
|
|
||||||
Object.keys(
|
|
||||||
useSyncConfigStore().prefsStorage.simple.muteFilters
|
|
||||||
).forEach(key => {
|
|
||||||
useSyncConfigStore().unsetSimplePrefAndSave({ path: 'muteFilters.' + key, value: null })
|
|
||||||
})
|
})
|
||||||
|
useUserHighlightStore().initUserHighlight(user)
|
||||||
|
commit('addNewUsers', [user])
|
||||||
|
|
||||||
// Reset flag to 0 to re-run migrations
|
useEmojiStore().fetchEmoji()
|
||||||
useSyncConfigStore().setFlag({ flag: 'configMigration', value: 0 })
|
|
||||||
/**/
|
|
||||||
|
|
||||||
if (user.token) {
|
getNotificationPermission().then((permission) =>
|
||||||
dispatch('setWsToken', user.token)
|
useInterfaceStore().setNotificationPermission(permission),
|
||||||
|
)
|
||||||
|
|
||||||
// Initialize the shout socket.
|
// Do server-side storage migrations
|
||||||
dispatch('initializeSocket')
|
|
||||||
}
|
|
||||||
|
|
||||||
const startPolling = () => {
|
// Debug snippet to clean up storage and reset migrations
|
||||||
// Start getting fresh posts.
|
/*
|
||||||
dispatch('startFetchingTimeline', { timeline: 'friends' })
|
// Reset wordfilter
|
||||||
|
Object.keys(
|
||||||
|
useSyncConfigStore().prefsStorage.simple.muteFilters
|
||||||
|
).forEach(key => {
|
||||||
|
useSyncConfigStore().unsetSimplePrefAndSave({ path: 'muteFilters.' + key, value: null })
|
||||||
|
})
|
||||||
|
|
||||||
// Start fetching notifications
|
// Reset flag to 0 to re-run migrations
|
||||||
dispatch('startFetchingNotifications')
|
useSyncConfigStore().setFlag({ flag: 'configMigration', value: 0 })
|
||||||
|
/**/
|
||||||
|
|
||||||
if (
|
if (user.token) {
|
||||||
useInstanceCapabilitiesStore().pleromaChatMessagesAvailable
|
dispatch('setWsToken', user.token)
|
||||||
) {
|
|
||||||
// Start fetching chats
|
|
||||||
dispatch('startFetchingChats')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
useListsStore().startFetching()
|
// Initialize the shout socket.
|
||||||
useBookmarkFoldersStore().startFetching()
|
dispatch('initializeSocket')
|
||||||
|
}
|
||||||
|
|
||||||
if (user.locked) {
|
const startPolling = () => {
|
||||||
dispatch('startFetchingFollowRequests')
|
// Start getting fresh posts.
|
||||||
}
|
dispatch('startFetchingTimeline', { timeline: 'friends' })
|
||||||
|
|
||||||
if (useMergedConfigStore().mergedConfig.useStreamingApi) {
|
// Start fetching notifications
|
||||||
dispatch('fetchTimeline', {
|
dispatch('startFetchingNotifications')
|
||||||
timeline: 'friends',
|
|
||||||
sinceId: null,
|
|
||||||
})
|
|
||||||
dispatch('fetchNotifications', { sinceId: null })
|
|
||||||
dispatch('enableMastoSockets', true)
|
|
||||||
.catch((error) => {
|
|
||||||
console.error(
|
|
||||||
'Failed initializing MastoAPI Streaming socket',
|
|
||||||
error,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
dispatch('fetchChats', { latest: true })
|
|
||||||
setTimeout(
|
|
||||||
() => dispatch('setNotificationsSilence', false),
|
|
||||||
10000,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
startPolling()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get user mutes
|
if (useInstanceCapabilitiesStore().pleromaChatMessagesAvailable) {
|
||||||
dispatch('fetchMutes')
|
// Start fetching chats
|
||||||
|
dispatch('startFetchingChats')
|
||||||
useInterfaceStore().setLayoutWidth(windowWidth())
|
|
||||||
useInterfaceStore().setLayoutHeight(windowHeight())
|
|
||||||
|
|
||||||
// Fetch our friends
|
|
||||||
fetchFriends({ id: user.id }).then((friends) =>
|
|
||||||
commit('addNewUsers', friends),
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
const response = data.error
|
|
||||||
// Authentication failed
|
|
||||||
commit('endLogin')
|
|
||||||
|
|
||||||
// remove authentication token on client/authentication errors
|
|
||||||
if ([400, 401, 403, 422].includes(response.status)) {
|
|
||||||
useOAuthStore().clearToken()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (response.status === 401) {
|
|
||||||
reject(new Error('Wrong username or password'))
|
|
||||||
} else {
|
|
||||||
reject(new Error('An error occurred, please try again'))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useListsStore().startFetching()
|
||||||
|
useBookmarkFoldersStore().startFetching()
|
||||||
|
|
||||||
|
if (user.locked) {
|
||||||
|
dispatch('startFetchingFollowRequests')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useMergedConfigStore().mergedConfig.useStreamingApi) {
|
||||||
|
dispatch('fetchTimeline', {
|
||||||
|
timeline: 'friends',
|
||||||
|
sinceId: null,
|
||||||
|
})
|
||||||
|
dispatch('fetchNotifications', { sinceId: null })
|
||||||
|
dispatch('enableMastoSockets', true)
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(
|
||||||
|
'Failed initializing MastoAPI Streaming socket',
|
||||||
|
error,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
dispatch('fetchChats', { latest: true })
|
||||||
|
setTimeout(
|
||||||
|
() => dispatch('setNotificationsSilence', false),
|
||||||
|
10000,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
startPolling()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get user mutes
|
||||||
|
dispatch('fetchMutes')
|
||||||
|
|
||||||
|
useInterfaceStore().setLayoutWidth(windowWidth())
|
||||||
|
useInterfaceStore().setLayoutHeight(windowHeight())
|
||||||
|
|
||||||
|
// Fetch our friends
|
||||||
|
fetchFriends({ id: user.id }).then(({ data: friends }) =>
|
||||||
|
commit('addNewUsers', friends),
|
||||||
|
)
|
||||||
commit('endLogin')
|
commit('endLogin')
|
||||||
resolve()
|
resolve()
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
|
||||||
|
// Authentication failed
|
||||||
commit('endLogin')
|
commit('endLogin')
|
||||||
reject(new Error('Failed to connect to server, try again'))
|
|
||||||
|
// remove authentication token on client/authentication errors
|
||||||
|
if ([400, 401, 403, 422].includes(error.statusCode)) {
|
||||||
|
useOAuthStore().clearToken()
|
||||||
|
}
|
||||||
|
|
||||||
|
commit('endLogin')
|
||||||
|
if (error.tatusCode === 401) {
|
||||||
|
throw new Error('Wrong username or password', error)
|
||||||
|
} else {
|
||||||
|
throw new Error('An error occurred, please try again', error)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import { fetchTimeline } from 'src/api/public.js'
|
|
||||||
import { promiseInterval } from '../promise_interval/promise_interval.js'
|
import { promiseInterval } from '../promise_interval/promise_interval.js'
|
||||||
|
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
|
|
@ -6,6 +5,8 @@ import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.j
|
||||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
|
|
||||||
|
import { fetchTimeline } from 'src/api/public.js'
|
||||||
|
|
||||||
const update = ({ store, notifications, older }) => {
|
const update = ({ store, notifications, older }) => {
|
||||||
store.dispatch('addNewNotifications', { notifications, older })
|
store.dispatch('addNewNotifications', { notifications, older })
|
||||||
}
|
}
|
||||||
|
|
@ -97,6 +98,7 @@ const fetchNotifications = ({ store, args, older }) => {
|
||||||
throw new Error(`${response.status} ${response.statusText}`)
|
throw new Error(`${response.status} ${response.statusText}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const notifications = response.data
|
const notifications = response.data
|
||||||
update({ store, notifications, older })
|
update({ store, notifications, older })
|
||||||
return notifications
|
return notifications
|
||||||
|
|
|
||||||
|
|
@ -37,15 +37,16 @@ const postStatus = ({
|
||||||
preview,
|
preview,
|
||||||
idempotencyKey,
|
idempotencyKey,
|
||||||
})
|
})
|
||||||
.then((data) => {
|
.then(({ data }) => {
|
||||||
if (!data.error && !preview) {
|
if (preview) return data
|
||||||
store.dispatch('addNewStatuses', {
|
|
||||||
statuses: [data],
|
store.dispatch('addNewStatuses', {
|
||||||
timeline: 'friends',
|
statuses: [data],
|
||||||
showImmediately: true,
|
timeline: 'friends',
|
||||||
noIdUpdate: true, // To prevent missing notices on next pull.
|
showImmediately: true,
|
||||||
})
|
noIdUpdate: true, // To prevent missing notices on next pull.
|
||||||
}
|
})
|
||||||
|
|
||||||
return data
|
return data
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
|
@ -67,7 +68,7 @@ const editStatus = ({
|
||||||
}) => {
|
}) => {
|
||||||
const mediaIds = map(media, 'id')
|
const mediaIds = map(media, 'id')
|
||||||
|
|
||||||
return editStatus({
|
return apiEditStatus({
|
||||||
id: statusId,
|
id: statusId,
|
||||||
credentials: store.state.users.currentUser.credentials,
|
credentials: store.state.users.currentUser.credentials,
|
||||||
status,
|
status,
|
||||||
|
|
@ -77,15 +78,14 @@ const editStatus = ({
|
||||||
mediaIds,
|
mediaIds,
|
||||||
contentType,
|
contentType,
|
||||||
})
|
})
|
||||||
.then((data) => {
|
.then(({ data }) => {
|
||||||
if (!data.error) {
|
store.dispatch('addNewStatuses', {
|
||||||
store.dispatch('addNewStatuses', {
|
statuses: [data],
|
||||||
statuses: [data],
|
timeline: 'friends',
|
||||||
timeline: 'friends',
|
showImmediately: true,
|
||||||
showImmediately: true,
|
noIdUpdate: true, // To prevent missing notices on next pull.
|
||||||
noIdUpdate: true, // To prevent missing notices on next pull.
|
})
|
||||||
})
|
|
||||||
}
|
|
||||||
return data
|
return data
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
|
@ -98,12 +98,14 @@ const editStatus = ({
|
||||||
|
|
||||||
const uploadMedia = ({ store, formData }) => {
|
const uploadMedia = ({ store, formData }) => {
|
||||||
const credentials = store.state.users.currentUser.credentials
|
const credentials = store.state.users.currentUser.credentials
|
||||||
return apiUploadMedia({ credentials, formData })
|
return apiUploadMedia({ credentials, formData }).then(({ data }) => data)
|
||||||
}
|
}
|
||||||
|
|
||||||
const setMediaDescription = ({ store, id, description }) => {
|
const setMediaDescription = ({ store, id, description }) => {
|
||||||
const credentials = store.state.users.currentUser.credentials
|
const credentials = store.state.users.currentUser.credentials
|
||||||
return apiSetMediaDescription({ credentials, id, description })
|
return apiSetMediaDescription({ credentials, id, description }).then(
|
||||||
|
({ data }) => data,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const statusPosterService = {
|
const statusPosterService = {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import { camelCase } from 'lodash'
|
import { camelCase } from 'lodash'
|
||||||
|
|
||||||
import { fetchTimeline } from 'src/api/public.js'
|
|
||||||
import { promiseInterval } from '../promise_interval/promise_interval.js'
|
import { promiseInterval } from '../promise_interval/promise_interval.js'
|
||||||
|
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
|
|
@ -8,6 +7,8 @@ import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.j
|
||||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
|
|
||||||
|
import { fetchTimeline } from 'src/api/public.js'
|
||||||
|
|
||||||
const update = ({
|
const update = ({
|
||||||
store,
|
store,
|
||||||
statuses,
|
statuses,
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
||||||
loadAdminStuff() {
|
loadAdminStuff() {
|
||||||
getInstanceDBConfig({
|
getInstanceDBConfig({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((backendDbConfig) => {
|
}).then(({ data: backendDbConfig }) => {
|
||||||
if (backendDbConfig.error) {
|
if (backendDbConfig.error) {
|
||||||
if (backendDbConfig.error.status === 400) {
|
if (backendDbConfig.error.status === 400) {
|
||||||
backendDbConfig.error.json().then((errorJson) => {
|
backendDbConfig.error.json().then((errorJson) => {
|
||||||
|
|
@ -106,7 +106,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
||||||
if (this.descriptions === null) {
|
if (this.descriptions === null) {
|
||||||
getInstanceConfigDescriptions({
|
getInstanceConfigDescriptions({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((backendDescriptions) =>
|
}).then(({ data: backendDescriptions }) =>
|
||||||
this.setInstanceAdminDescriptions({
|
this.setInstanceAdminDescriptions({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
backendDescriptions,
|
backendDescriptions,
|
||||||
|
|
@ -251,7 +251,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
||||||
.then(() =>
|
.then(() =>
|
||||||
getInstanceDBConfig({
|
getInstanceDBConfig({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}),
|
}).then(({ data }) => data),
|
||||||
)
|
)
|
||||||
.then((backendDbConfig) =>
|
.then((backendDbConfig) =>
|
||||||
this.setInstanceAdminSettings({
|
this.setInstanceAdminSettings({
|
||||||
|
|
@ -294,7 +294,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
||||||
.then(() =>
|
.then(() =>
|
||||||
getInstanceDBConfig({
|
getInstanceDBConfig({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}),
|
}).then(({ data }) => data),
|
||||||
)
|
)
|
||||||
.then((backendDbConfig) =>
|
.then((backendDbConfig) =>
|
||||||
this.setInstanceAdminSettings({
|
this.setInstanceAdminSettings({
|
||||||
|
|
@ -326,7 +326,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
||||||
.then(() =>
|
.then(() =>
|
||||||
getInstanceDBConfig({
|
getInstanceDBConfig({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}),
|
}).then(({ data }) => data),
|
||||||
)
|
)
|
||||||
.then((backendDbConfig) =>
|
.then((backendDbConfig) =>
|
||||||
this.setInstanceAdminSettings({ backendDbConfig }),
|
this.setInstanceAdminSettings({ backendDbConfig }),
|
||||||
|
|
@ -337,7 +337,9 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
||||||
loadFrontendsStuff() {
|
loadFrontendsStuff() {
|
||||||
getAvailableFrontends({
|
getAvailableFrontends({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((frontends) => this.setAvailableFrontends({ frontends }))
|
}).then(({ data: frontends }) =>
|
||||||
|
this.setAvailableFrontends({ frontends }),
|
||||||
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
setAvailableFrontends({ frontends }) {
|
setAvailableFrontends({ frontends }) {
|
||||||
|
|
@ -355,12 +357,14 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
||||||
installFrontend() {
|
installFrontend() {
|
||||||
return installFrontend({
|
return installFrontend({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
})
|
}).then(({ data }) => data)
|
||||||
},
|
},
|
||||||
|
|
||||||
// Statuses stuff
|
// Statuses stuff
|
||||||
async fetchStatuses(opts) {
|
async fetchStatuses(opts) {
|
||||||
const { total, activities } = await listStatuses({
|
const {
|
||||||
|
data: { total, activities },
|
||||||
|
} = await listStatuses({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
opts,
|
opts,
|
||||||
})
|
})
|
||||||
|
|
@ -375,20 +379,21 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async changeStatusScope(opts) {
|
async changeStatusScope(opts) {
|
||||||
const raw = await changeStatusScope({
|
const { data } = await changeStatusScope({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
opts,
|
opts,
|
||||||
})
|
})
|
||||||
const status = parseStatus(raw)
|
const status = parseStatus(data)
|
||||||
|
|
||||||
await window.vuex.dispatch('addNewStatuses', { statuses: [status] })
|
await window.vuex.dispatch('addNewStatuses', { statuses: [status] })
|
||||||
},
|
},
|
||||||
|
|
||||||
// Users stuff
|
// Users stuff
|
||||||
async fetchUsers(opts) {
|
async fetchUsers(opts) {
|
||||||
const { users, count } = await listUsers({
|
const {
|
||||||
|
data: { users, count },
|
||||||
|
} = await listUsers({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
|
|
||||||
opts,
|
opts,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -412,7 +417,8 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
screen_name,
|
screen_name,
|
||||||
})
|
})
|
||||||
window.vuex.commit('updateUserAdminData', { user: result })
|
|
||||||
|
window.vuex.commit('updateUserAdminData', { user: result.data })
|
||||||
},
|
},
|
||||||
async deleteUsers({ users }) {
|
async deleteUsers({ users }) {
|
||||||
const screen_names = users.map((u) => u.screen_name)
|
const screen_names = users.map((u) => u.screen_name)
|
||||||
|
|
@ -423,7 +429,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
||||||
screen_names,
|
screen_names,
|
||||||
})
|
})
|
||||||
|
|
||||||
resultUserIds.forEach((userId) => {
|
resultUserIds.data.forEach((userId) => {
|
||||||
window.vuex.dispatch(
|
window.vuex.dispatch(
|
||||||
'markStatusesAsDeleted',
|
'markStatusesAsDeleted',
|
||||||
(status) => userId === status.user.id,
|
(status) => userId === status.user.id,
|
||||||
|
|
@ -439,7 +445,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
||||||
return resendConfirmationEmail({
|
return resendConfirmationEmail({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
screen_names,
|
screen_names,
|
||||||
})
|
}).then(({ data }) => data)
|
||||||
},
|
},
|
||||||
requirePasswordChange({ users }) {
|
requirePasswordChange({ users }) {
|
||||||
const screen_names = users.map((u) => u.screen_name)
|
const screen_names = users.map((u) => u.screen_name)
|
||||||
|
|
@ -447,7 +453,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
||||||
return requirePasswordChange({
|
return requirePasswordChange({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
screen_names,
|
screen_names,
|
||||||
})
|
}).then(({ data }) => data)
|
||||||
},
|
},
|
||||||
// Singular only!
|
// Singular only!
|
||||||
disableMFA({ user }) {
|
disableMFA({ user }) {
|
||||||
|
|
@ -456,7 +462,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
||||||
return disableMFA({
|
return disableMFA({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
screen_name,
|
screen_name,
|
||||||
})
|
}).then(({ data }) => data)
|
||||||
},
|
},
|
||||||
async setUsersTags({ users, tags, value }) {
|
async setUsersTags({ users, tags, value }) {
|
||||||
const screen_names = users.map((u) => u.screen_name)
|
const screen_names = users.map((u) => u.screen_name)
|
||||||
|
|
@ -498,7 +504,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
||||||
value,
|
value,
|
||||||
})
|
})
|
||||||
|
|
||||||
resultUsers.forEach((user) => {
|
resultUsers.data.forEach((user) => {
|
||||||
window.vuex.commit('updateUserAdminData', { user })
|
window.vuex.commit('updateUserAdminData', { user })
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
@ -512,7 +518,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
||||||
value,
|
value,
|
||||||
})
|
})
|
||||||
|
|
||||||
resultUsers.forEach((user) => {
|
resultUsers.data.forEach((user) => {
|
||||||
window.vuex.commit('updateUserAdminData', { user })
|
window.vuex.commit('updateUserAdminData', { user })
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
@ -538,27 +544,31 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
||||||
screen_names,
|
screen_names,
|
||||||
})
|
})
|
||||||
|
|
||||||
resultUsers.forEach((user) => {
|
resultUsers.data.forEach((user) => {
|
||||||
window.vuex.commit('updateUserAdminData', { user })
|
window.vuex.commit('updateUserAdminData', { user })
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
reloadEmoji() {
|
reloadEmoji() {
|
||||||
return reloadEmoji({ credentials: useOAuthStore().token })
|
return reloadEmoji({ credentials: useOAuthStore().token }).then(
|
||||||
|
({ data }) => data,
|
||||||
|
)
|
||||||
},
|
},
|
||||||
importEmojiFromFS() {
|
importEmojiFromFS() {
|
||||||
return importEmojiFromFS({ credentials: useOAuthStore().token })
|
return importEmojiFromFS({ credentials: useOAuthStore().token }).then(
|
||||||
|
({ data }) => data,
|
||||||
|
)
|
||||||
},
|
},
|
||||||
listEmojiPacks(params) {
|
listEmojiPacks(params) {
|
||||||
return listEmojiPacks({
|
return listEmojiPacks({
|
||||||
...params,
|
...params,
|
||||||
credentials: useOAuthStore().token
|
credentials: useOAuthStore().token,
|
||||||
})
|
}).then(({ data }) => data)
|
||||||
},
|
},
|
||||||
listRemoteEmojiPacks(params) {
|
listRemoteEmojiPacks(params) {
|
||||||
return listRemoteEmojiPacks({
|
return listRemoteEmojiPacks({
|
||||||
...params,
|
...params,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
})
|
}).then(({ data }) => data)
|
||||||
},
|
},
|
||||||
addNewEmojiFile({ packName, file, shortcode, filename }) {
|
addNewEmojiFile({ packName, file, shortcode, filename }) {
|
||||||
return addNewEmojiFile({
|
return addNewEmojiFile({
|
||||||
|
|
@ -567,7 +577,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
||||||
shortcode,
|
shortcode,
|
||||||
filename,
|
filename,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
})
|
}).then(({ data }) => data)
|
||||||
},
|
},
|
||||||
downloadRemoteEmojiPack({ instance, packName, as }) {
|
downloadRemoteEmojiPack({ instance, packName, as }) {
|
||||||
return downloadRemoteEmojiPack({
|
return downloadRemoteEmojiPack({
|
||||||
|
|
@ -575,33 +585,33 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
||||||
packName,
|
packName,
|
||||||
as,
|
as,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
})
|
}).then(({ data }) => data)
|
||||||
},
|
},
|
||||||
downloadRemoteEmojiPackZIP({ url, packName }) {
|
downloadRemoteEmojiPackZIP({ url, packName }) {
|
||||||
return downloadRemoteEmojiPackZIP({
|
return downloadRemoteEmojiPackZIP({
|
||||||
url,
|
url,
|
||||||
packName,
|
packName,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
})
|
}).then(({ data }) => data)
|
||||||
},
|
},
|
||||||
createEmojiPack({ name }) {
|
createEmojiPack({ name }) {
|
||||||
return createEmojiPack({
|
return createEmojiPack({
|
||||||
name,
|
name,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
})
|
}).then(({ data }) => data)
|
||||||
},
|
},
|
||||||
deleteEmojiPack({ name }) {
|
deleteEmojiPack({ name }) {
|
||||||
return createEmojiPack({
|
return createEmojiPack({
|
||||||
name,
|
name,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
})
|
}).then(({ data }) => data)
|
||||||
},
|
},
|
||||||
saveEmojiPackMetadata({ name, newData }) {
|
saveEmojiPackMetadata({ name, newData }) {
|
||||||
return createEmojiPack({
|
return createEmojiPack({
|
||||||
name,
|
name,
|
||||||
newData,
|
newData,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
})
|
}).then(({ data }) => data)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -44,15 +44,16 @@ export const useAnnouncementsStore = defineStore('announcements', {
|
||||||
|
|
||||||
const fetchAnnouncements = async () => {
|
const fetchAnnouncements = async () => {
|
||||||
if (!isAdmin) {
|
if (!isAdmin) {
|
||||||
return getAnnouncements({
|
const result = await getAnnouncements({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
})
|
})
|
||||||
|
return result.data
|
||||||
}
|
}
|
||||||
|
|
||||||
const all = await adminGetAnnouncements({
|
const { data: all } = await adminGetAnnouncements({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
})
|
})
|
||||||
const visible = await getAnnouncements({
|
const { data: visible } = await getAnnouncements({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
})
|
})
|
||||||
const visibleObject = visible.reduce((a, c) => {
|
const visibleObject = visible.reduce((a, c) => {
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,7 @@ export const useBookmarkFoldersStore = defineStore('bookmarkFolders', {
|
||||||
this.fetcher = fetchBookmarkFolders({
|
this.fetcher = fetchBookmarkFolders({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
})
|
})
|
||||||
.then(
|
.then(({ data: folders }) => this.setBookmarkFolders(folders))
|
||||||
(folders) => this.setBookmarkFolders(folders),
|
|
||||||
(rej) => console.error(rej),
|
|
||||||
)
|
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
})
|
})
|
||||||
|
|
@ -61,7 +58,7 @@ export const useBookmarkFoldersStore = defineStore('bookmarkFolders', {
|
||||||
name,
|
name,
|
||||||
emoji,
|
emoji,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then((folder) => {
|
}).then(({ data: folder }) => {
|
||||||
this.setBookmarkFolder(folder)
|
this.setBookmarkFolder(folder)
|
||||||
return folder
|
return folder
|
||||||
})
|
})
|
||||||
|
|
@ -72,7 +69,7 @@ export const useBookmarkFoldersStore = defineStore('bookmarkFolders', {
|
||||||
folderId,
|
folderId,
|
||||||
name,
|
name,
|
||||||
emoji,
|
emoji,
|
||||||
}).then((folder) => {
|
}).then(({ data: folder }) => {
|
||||||
this.setBookmarkFolder(folder)
|
this.setBookmarkFolder(folder)
|
||||||
return folder
|
return folder
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import { merge } from 'lodash'
|
import { merge } from 'lodash'
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
|
|
||||||
import { ensureFinalFallback } from 'src/i18n/languages.js'
|
|
||||||
import { listEmojiPacks } from 'src/api/public.js'
|
import { listEmojiPacks } from 'src/api/public.js'
|
||||||
|
import { ensureFinalFallback } from 'src/i18n/languages.js'
|
||||||
|
|
||||||
import { annotationsLoader } from 'virtual:pleroma-fe/emoji-annotations'
|
import { annotationsLoader } from 'virtual:pleroma-fe/emoji-annotations'
|
||||||
|
|
||||||
|
|
@ -188,7 +188,8 @@ export const useEmojiStore = defineStore('emoji', {
|
||||||
this.adminPacksLocalLoading = true
|
this.adminPacksLocalLoading = true
|
||||||
this.adminPacksLocal = await this.getAdminPacks(
|
this.adminPacksLocal = await this.getAdminPacks(
|
||||||
useInstanceStore().server,
|
useInstanceStore().server,
|
||||||
(params) => listEmojiPacks({
|
(params) =>
|
||||||
|
listEmojiPacks({
|
||||||
...params,
|
...params,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}),
|
}),
|
||||||
|
|
@ -221,14 +222,13 @@ export const useEmojiStore = defineStore('emoji', {
|
||||||
instance,
|
instance,
|
||||||
page: i,
|
page: i,
|
||||||
pageSize,
|
pageSize,
|
||||||
})
|
}).then((pageData) => {
|
||||||
.then((pageData) => {
|
if (pageData.error !== undefined) {
|
||||||
if (pageData.error !== undefined) {
|
return Promise.reject(pageData.error)
|
||||||
return Promise.reject(pageData.error)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return pageData.packs
|
return pageData.packs
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,11 @@ import {
|
||||||
LOCAL_DEFAULT_CONFIG_DEFINITIONS,
|
LOCAL_DEFAULT_CONFIG_DEFINITIONS,
|
||||||
validateSetting,
|
validateSetting,
|
||||||
} from '../modules/default_config_state.js'
|
} from '../modules/default_config_state.js'
|
||||||
import { fetchKnownDomains } from 'src/api/public.js'
|
|
||||||
|
|
||||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||||
|
|
||||||
|
import { fetchKnownDomains } from 'src/api/public.js'
|
||||||
|
|
||||||
const REMOTE_INTERACTION_URL = '/main/ostatus'
|
const REMOTE_INTERACTION_URL = '/main/ostatus'
|
||||||
|
|
||||||
const ROOT_STATE_DEFINITIONS = {
|
const ROOT_STATE_DEFINITIONS = {
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,7 @@ export const useListsStore = defineStore('lists', {
|
||||||
this.fetcher = fetchLists({
|
this.fetcher = fetchLists({
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
})
|
})
|
||||||
.then(
|
.then(({ data: lists }) => this.setLists(lists))
|
||||||
(lists) => this.setLists(lists),
|
|
||||||
(rej) => console.error(rej),
|
|
||||||
)
|
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,11 @@ import { toRaw } from 'vue'
|
||||||
|
|
||||||
import { CURRENT_UPDATE_COUNTER } from 'src/components/update_notification/update_notification.js'
|
import { CURRENT_UPDATE_COUNTER } from 'src/components/update_notification/update_notification.js'
|
||||||
|
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
import { useLocalConfigStore } from 'src/stores/local_config.js'
|
import { useLocalConfigStore } from 'src/stores/local_config.js'
|
||||||
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
|
|
||||||
|
import { updateProfileJSON } from 'src/api/user.js'
|
||||||
import { storage } from 'src/lib/storage.js'
|
import { storage } from 'src/lib/storage.js'
|
||||||
import {
|
import {
|
||||||
makeUndefined,
|
makeUndefined,
|
||||||
|
|
@ -32,7 +33,6 @@ import {
|
||||||
validateSetting,
|
validateSetting,
|
||||||
} from 'src/modules/default_config_state.js'
|
} from 'src/modules/default_config_state.js'
|
||||||
import { oldDefaultConfigSync } from 'src/modules/old_default_config_state.js'
|
import { oldDefaultConfigSync } from 'src/modules/old_default_config_state.js'
|
||||||
import { updateProfileJSON } from 'src/api/user.js'
|
|
||||||
|
|
||||||
export const VERSION = 2
|
export const VERSION = 2
|
||||||
export const NEW_USER_DATE = new Date('2026-03-16') // date of writing this, basically
|
export const NEW_USER_DATE = new Date('2026-03-16') // date of writing this, basically
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@ import { toRaw } from 'vue'
|
||||||
|
|
||||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
|
|
||||||
import { storage } from 'src/lib/storage.js'
|
|
||||||
import { updateProfileJSON } from 'src/api/user.js'
|
import { updateProfileJSON } from 'src/api/user.js'
|
||||||
|
import { storage } from 'src/lib/storage.js'
|
||||||
|
|
||||||
export const NEW_USER_DATE = new Date('2022-08-04') // date of writing this, basically
|
export const NEW_USER_DATE = new Date('2022-08-04') // date of writing this, basically
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue