sforkowany z mirror/soapbox
Actions: TypeScript
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>settings-alert
rodzic
f3b0230480
commit
d8cb953955
|
@ -1,527 +0,0 @@
|
||||||
import { defineMessages } from 'react-intl';
|
|
||||||
|
|
||||||
import snackbar from 'soapbox/actions/snackbar';
|
|
||||||
import { isLoggedIn } from 'soapbox/utils/auth';
|
|
||||||
|
|
||||||
import api from '../api';
|
|
||||||
|
|
||||||
import { importFetchedAccounts, importFetchedStatus } from './importer';
|
|
||||||
|
|
||||||
export const REBLOG_REQUEST = 'REBLOG_REQUEST';
|
|
||||||
export const REBLOG_SUCCESS = 'REBLOG_SUCCESS';
|
|
||||||
export const REBLOG_FAIL = 'REBLOG_FAIL';
|
|
||||||
|
|
||||||
export const FAVOURITE_REQUEST = 'FAVOURITE_REQUEST';
|
|
||||||
export const FAVOURITE_SUCCESS = 'FAVOURITE_SUCCESS';
|
|
||||||
export const FAVOURITE_FAIL = 'FAVOURITE_FAIL';
|
|
||||||
|
|
||||||
export const UNREBLOG_REQUEST = 'UNREBLOG_REQUEST';
|
|
||||||
export const UNREBLOG_SUCCESS = 'UNREBLOG_SUCCESS';
|
|
||||||
export const UNREBLOG_FAIL = 'UNREBLOG_FAIL';
|
|
||||||
|
|
||||||
export const UNFAVOURITE_REQUEST = 'UNFAVOURITE_REQUEST';
|
|
||||||
export const UNFAVOURITE_SUCCESS = 'UNFAVOURITE_SUCCESS';
|
|
||||||
export const UNFAVOURITE_FAIL = 'UNFAVOURITE_FAIL';
|
|
||||||
|
|
||||||
export const REBLOGS_FETCH_REQUEST = 'REBLOGS_FETCH_REQUEST';
|
|
||||||
export const REBLOGS_FETCH_SUCCESS = 'REBLOGS_FETCH_SUCCESS';
|
|
||||||
export const REBLOGS_FETCH_FAIL = 'REBLOGS_FETCH_FAIL';
|
|
||||||
|
|
||||||
export const FAVOURITES_FETCH_REQUEST = 'FAVOURITES_FETCH_REQUEST';
|
|
||||||
export const FAVOURITES_FETCH_SUCCESS = 'FAVOURITES_FETCH_SUCCESS';
|
|
||||||
export const FAVOURITES_FETCH_FAIL = 'FAVOURITES_FETCH_FAIL';
|
|
||||||
|
|
||||||
export const REACTIONS_FETCH_REQUEST = 'REACTIONS_FETCH_REQUEST';
|
|
||||||
export const REACTIONS_FETCH_SUCCESS = 'REACTIONS_FETCH_SUCCESS';
|
|
||||||
export const REACTIONS_FETCH_FAIL = 'REACTIONS_FETCH_FAIL';
|
|
||||||
|
|
||||||
export const PIN_REQUEST = 'PIN_REQUEST';
|
|
||||||
export const PIN_SUCCESS = 'PIN_SUCCESS';
|
|
||||||
export const PIN_FAIL = 'PIN_FAIL';
|
|
||||||
|
|
||||||
export const UNPIN_REQUEST = 'UNPIN_REQUEST';
|
|
||||||
export const UNPIN_SUCCESS = 'UNPIN_SUCCESS';
|
|
||||||
export const UNPIN_FAIL = 'UNPIN_FAIL';
|
|
||||||
|
|
||||||
export const BOOKMARK_REQUEST = 'BOOKMARK_REQUEST';
|
|
||||||
export const BOOKMARK_SUCCESS = 'BOOKMARKED_SUCCESS';
|
|
||||||
export const BOOKMARK_FAIL = 'BOOKMARKED_FAIL';
|
|
||||||
|
|
||||||
export const UNBOOKMARK_REQUEST = 'UNBOOKMARKED_REQUEST';
|
|
||||||
export const UNBOOKMARK_SUCCESS = 'UNBOOKMARKED_SUCCESS';
|
|
||||||
export const UNBOOKMARK_FAIL = 'UNBOOKMARKED_FAIL';
|
|
||||||
|
|
||||||
export const REMOTE_INTERACTION_REQUEST = 'REMOTE_INTERACTION_REQUEST';
|
|
||||||
export const REMOTE_INTERACTION_SUCCESS = 'REMOTE_INTERACTION_SUCCESS';
|
|
||||||
export const REMOTE_INTERACTION_FAIL = 'REMOTE_INTERACTION_FAIL';
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
|
||||||
bookmarkAdded: { id: 'status.bookmarked', defaultMessage: 'Bookmark added.' },
|
|
||||||
bookmarkRemoved: { id: 'status.unbookmarked', defaultMessage: 'Bookmark removed.' },
|
|
||||||
view: { id: 'snackbar.view', defaultMessage: 'View' },
|
|
||||||
});
|
|
||||||
|
|
||||||
export function reblog(status) {
|
|
||||||
return function(dispatch, getState) {
|
|
||||||
if (!isLoggedIn(getState)) return;
|
|
||||||
|
|
||||||
dispatch(reblogRequest(status));
|
|
||||||
|
|
||||||
api(getState).post(`/api/v1/statuses/${status.get('id')}/reblog`).then(function(response) {
|
|
||||||
// The reblog API method returns a new status wrapped around the original. In this case we are only
|
|
||||||
// interested in how the original is modified, hence passing it skipping the wrapper
|
|
||||||
dispatch(importFetchedStatus(response.data.reblog));
|
|
||||||
dispatch(reblogSuccess(status));
|
|
||||||
}).catch(function(error) {
|
|
||||||
dispatch(reblogFail(status, error));
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function unreblog(status) {
|
|
||||||
return (dispatch, getState) => {
|
|
||||||
if (!isLoggedIn(getState)) return;
|
|
||||||
|
|
||||||
dispatch(unreblogRequest(status));
|
|
||||||
|
|
||||||
api(getState).post(`/api/v1/statuses/${status.get('id')}/unreblog`).then(response => {
|
|
||||||
dispatch(unreblogSuccess(status));
|
|
||||||
}).catch(error => {
|
|
||||||
dispatch(unreblogFail(status, error));
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function reblogRequest(status) {
|
|
||||||
return {
|
|
||||||
type: REBLOG_REQUEST,
|
|
||||||
status: status,
|
|
||||||
skipLoading: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function reblogSuccess(status) {
|
|
||||||
return {
|
|
||||||
type: REBLOG_SUCCESS,
|
|
||||||
status: status,
|
|
||||||
skipLoading: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function reblogFail(status, error) {
|
|
||||||
return {
|
|
||||||
type: REBLOG_FAIL,
|
|
||||||
status: status,
|
|
||||||
error: error,
|
|
||||||
skipLoading: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function unreblogRequest(status) {
|
|
||||||
return {
|
|
||||||
type: UNREBLOG_REQUEST,
|
|
||||||
status: status,
|
|
||||||
skipLoading: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function unreblogSuccess(status) {
|
|
||||||
return {
|
|
||||||
type: UNREBLOG_SUCCESS,
|
|
||||||
status: status,
|
|
||||||
skipLoading: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function unreblogFail(status, error) {
|
|
||||||
return {
|
|
||||||
type: UNREBLOG_FAIL,
|
|
||||||
status: status,
|
|
||||||
error: error,
|
|
||||||
skipLoading: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function favourite(status) {
|
|
||||||
return function(dispatch, getState) {
|
|
||||||
if (!isLoggedIn(getState)) return;
|
|
||||||
|
|
||||||
dispatch(favouriteRequest(status));
|
|
||||||
|
|
||||||
api(getState).post(`/api/v1/statuses/${status.get('id')}/favourite`).then(function(response) {
|
|
||||||
dispatch(favouriteSuccess(status));
|
|
||||||
}).catch(function(error) {
|
|
||||||
dispatch(favouriteFail(status, error));
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function unfavourite(status) {
|
|
||||||
return (dispatch, getState) => {
|
|
||||||
if (!isLoggedIn(getState)) return;
|
|
||||||
|
|
||||||
dispatch(unfavouriteRequest(status));
|
|
||||||
|
|
||||||
api(getState).post(`/api/v1/statuses/${status.get('id')}/unfavourite`).then(response => {
|
|
||||||
dispatch(unfavouriteSuccess(status));
|
|
||||||
}).catch(error => {
|
|
||||||
dispatch(unfavouriteFail(status, error));
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function favouriteRequest(status) {
|
|
||||||
return {
|
|
||||||
type: FAVOURITE_REQUEST,
|
|
||||||
status: status,
|
|
||||||
skipLoading: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function favouriteSuccess(status) {
|
|
||||||
return {
|
|
||||||
type: FAVOURITE_SUCCESS,
|
|
||||||
status: status,
|
|
||||||
skipLoading: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function favouriteFail(status, error) {
|
|
||||||
return {
|
|
||||||
type: FAVOURITE_FAIL,
|
|
||||||
status: status,
|
|
||||||
error: error,
|
|
||||||
skipLoading: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function unfavouriteRequest(status) {
|
|
||||||
return {
|
|
||||||
type: UNFAVOURITE_REQUEST,
|
|
||||||
status: status,
|
|
||||||
skipLoading: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function unfavouriteSuccess(status) {
|
|
||||||
return {
|
|
||||||
type: UNFAVOURITE_SUCCESS,
|
|
||||||
status: status,
|
|
||||||
skipLoading: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function unfavouriteFail(status, error) {
|
|
||||||
return {
|
|
||||||
type: UNFAVOURITE_FAIL,
|
|
||||||
status: status,
|
|
||||||
error: error,
|
|
||||||
skipLoading: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function bookmark(status) {
|
|
||||||
return function(dispatch, getState) {
|
|
||||||
dispatch(bookmarkRequest(status));
|
|
||||||
|
|
||||||
api(getState).post(`/api/v1/statuses/${status.get('id')}/bookmark`).then(function(response) {
|
|
||||||
dispatch(importFetchedStatus(response.data));
|
|
||||||
dispatch(bookmarkSuccess(status, response.data));
|
|
||||||
dispatch(snackbar.success(messages.bookmarkAdded, messages.view, '/bookmarks'));
|
|
||||||
}).catch(function(error) {
|
|
||||||
dispatch(bookmarkFail(status, error));
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function unbookmark(status) {
|
|
||||||
return (dispatch, getState) => {
|
|
||||||
dispatch(unbookmarkRequest(status));
|
|
||||||
|
|
||||||
api(getState).post(`/api/v1/statuses/${status.get('id')}/unbookmark`).then(response => {
|
|
||||||
dispatch(importFetchedStatus(response.data));
|
|
||||||
dispatch(unbookmarkSuccess(status, response.data));
|
|
||||||
dispatch(snackbar.success(messages.bookmarkRemoved));
|
|
||||||
}).catch(error => {
|
|
||||||
dispatch(unbookmarkFail(status, error));
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function bookmarkRequest(status) {
|
|
||||||
return {
|
|
||||||
type: BOOKMARK_REQUEST,
|
|
||||||
status: status,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function bookmarkSuccess(status, response) {
|
|
||||||
return {
|
|
||||||
type: BOOKMARK_SUCCESS,
|
|
||||||
status: status,
|
|
||||||
response: response,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function bookmarkFail(status, error) {
|
|
||||||
return {
|
|
||||||
type: BOOKMARK_FAIL,
|
|
||||||
status: status,
|
|
||||||
error: error,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function unbookmarkRequest(status) {
|
|
||||||
return {
|
|
||||||
type: UNBOOKMARK_REQUEST,
|
|
||||||
status: status,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function unbookmarkSuccess(status, response) {
|
|
||||||
return {
|
|
||||||
type: UNBOOKMARK_SUCCESS,
|
|
||||||
status: status,
|
|
||||||
response: response,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function unbookmarkFail(status, error) {
|
|
||||||
return {
|
|
||||||
type: UNBOOKMARK_FAIL,
|
|
||||||
status: status,
|
|
||||||
error: error,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function fetchReblogs(id) {
|
|
||||||
return (dispatch, getState) => {
|
|
||||||
if (!isLoggedIn(getState)) return;
|
|
||||||
|
|
||||||
dispatch(fetchReblogsRequest(id));
|
|
||||||
|
|
||||||
api(getState).get(`/api/v1/statuses/${id}/reblogged_by`).then(response => {
|
|
||||||
dispatch(importFetchedAccounts(response.data));
|
|
||||||
dispatch(fetchReblogsSuccess(id, response.data));
|
|
||||||
}).catch(error => {
|
|
||||||
dispatch(fetchReblogsFail(id, error));
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function fetchReblogsRequest(id) {
|
|
||||||
return {
|
|
||||||
type: REBLOGS_FETCH_REQUEST,
|
|
||||||
id,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function fetchReblogsSuccess(id, accounts) {
|
|
||||||
return {
|
|
||||||
type: REBLOGS_FETCH_SUCCESS,
|
|
||||||
id,
|
|
||||||
accounts,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function fetchReblogsFail(id, error) {
|
|
||||||
return {
|
|
||||||
type: REBLOGS_FETCH_FAIL,
|
|
||||||
error,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function fetchFavourites(id) {
|
|
||||||
return (dispatch, getState) => {
|
|
||||||
if (!isLoggedIn(getState)) return;
|
|
||||||
|
|
||||||
dispatch(fetchFavouritesRequest(id));
|
|
||||||
|
|
||||||
api(getState).get(`/api/v1/statuses/${id}/favourited_by`).then(response => {
|
|
||||||
dispatch(importFetchedAccounts(response.data));
|
|
||||||
dispatch(fetchFavouritesSuccess(id, response.data));
|
|
||||||
}).catch(error => {
|
|
||||||
dispatch(fetchFavouritesFail(id, error));
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function fetchFavouritesRequest(id) {
|
|
||||||
return {
|
|
||||||
type: FAVOURITES_FETCH_REQUEST,
|
|
||||||
id,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function fetchFavouritesSuccess(id, accounts) {
|
|
||||||
return {
|
|
||||||
type: FAVOURITES_FETCH_SUCCESS,
|
|
||||||
id,
|
|
||||||
accounts,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function fetchFavouritesFail(id, error) {
|
|
||||||
return {
|
|
||||||
type: FAVOURITES_FETCH_FAIL,
|
|
||||||
error,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function fetchReactions(id) {
|
|
||||||
return (dispatch, getState) => {
|
|
||||||
dispatch(fetchReactionsRequest(id));
|
|
||||||
|
|
||||||
api(getState).get(`/api/v1/pleroma/statuses/${id}/reactions`).then(response => {
|
|
||||||
dispatch(importFetchedAccounts(response.data.map(({ accounts }) => accounts).flat()));
|
|
||||||
dispatch(fetchReactionsSuccess(id, response.data));
|
|
||||||
}).catch(error => {
|
|
||||||
dispatch(fetchReactionsFail(id, error));
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function fetchReactionsRequest(id) {
|
|
||||||
return {
|
|
||||||
type: REACTIONS_FETCH_REQUEST,
|
|
||||||
id,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function fetchReactionsSuccess(id, reactions) {
|
|
||||||
return {
|
|
||||||
type: REACTIONS_FETCH_SUCCESS,
|
|
||||||
id,
|
|
||||||
reactions,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function fetchReactionsFail(id, error) {
|
|
||||||
return {
|
|
||||||
type: REACTIONS_FETCH_FAIL,
|
|
||||||
error,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function pin(status) {
|
|
||||||
return (dispatch, getState) => {
|
|
||||||
if (!isLoggedIn(getState)) return;
|
|
||||||
|
|
||||||
dispatch(pinRequest(status));
|
|
||||||
|
|
||||||
api(getState).post(`/api/v1/statuses/${status.get('id')}/pin`).then(response => {
|
|
||||||
dispatch(importFetchedStatus(response.data));
|
|
||||||
dispatch(pinSuccess(status));
|
|
||||||
}).catch(error => {
|
|
||||||
dispatch(pinFail(status, error));
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function pinRequest(status) {
|
|
||||||
return {
|
|
||||||
type: PIN_REQUEST,
|
|
||||||
status,
|
|
||||||
skipLoading: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function pinSuccess(status) {
|
|
||||||
return {
|
|
||||||
type: PIN_SUCCESS,
|
|
||||||
status,
|
|
||||||
skipLoading: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function pinFail(status, error) {
|
|
||||||
return {
|
|
||||||
type: PIN_FAIL,
|
|
||||||
status,
|
|
||||||
error,
|
|
||||||
skipLoading: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function unpin(status) {
|
|
||||||
return (dispatch, getState) => {
|
|
||||||
if (!isLoggedIn(getState)) return;
|
|
||||||
|
|
||||||
dispatch(unpinRequest(status));
|
|
||||||
|
|
||||||
api(getState).post(`/api/v1/statuses/${status.get('id')}/unpin`).then(response => {
|
|
||||||
dispatch(importFetchedStatus(response.data));
|
|
||||||
dispatch(unpinSuccess(status));
|
|
||||||
}).catch(error => {
|
|
||||||
dispatch(unpinFail(status, error));
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function unpinRequest(status) {
|
|
||||||
return {
|
|
||||||
type: UNPIN_REQUEST,
|
|
||||||
status,
|
|
||||||
skipLoading: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function unpinSuccess(status) {
|
|
||||||
return {
|
|
||||||
type: UNPIN_SUCCESS,
|
|
||||||
status,
|
|
||||||
skipLoading: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function unpinFail(status, error) {
|
|
||||||
return {
|
|
||||||
type: UNPIN_FAIL,
|
|
||||||
status,
|
|
||||||
error,
|
|
||||||
skipLoading: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function remoteInteraction(ap_id, profile) {
|
|
||||||
return (dispatch, getState) => {
|
|
||||||
dispatch(remoteInteractionRequest(ap_id, profile));
|
|
||||||
|
|
||||||
return api(getState).post('/api/v1/pleroma/remote_interaction', { ap_id, profile }).then(({ data }) => {
|
|
||||||
if (data.error) throw new Error(data.error);
|
|
||||||
|
|
||||||
dispatch(remoteInteractionSuccess(ap_id, profile, data.url));
|
|
||||||
|
|
||||||
return data.url;
|
|
||||||
}).catch(error => {
|
|
||||||
dispatch(remoteInteractionFail(ap_id, profile, error));
|
|
||||||
throw error;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function remoteInteractionRequest(ap_id, profile) {
|
|
||||||
return {
|
|
||||||
type: REMOTE_INTERACTION_REQUEST,
|
|
||||||
ap_id,
|
|
||||||
profile,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function remoteInteractionSuccess(ap_id, profile, url) {
|
|
||||||
return {
|
|
||||||
type: REMOTE_INTERACTION_SUCCESS,
|
|
||||||
ap_id,
|
|
||||||
profile,
|
|
||||||
url,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function remoteInteractionFail(ap_id, profile, error) {
|
|
||||||
return {
|
|
||||||
type: REMOTE_INTERACTION_FAIL,
|
|
||||||
ap_id,
|
|
||||||
profile,
|
|
||||||
error,
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -0,0 +1,537 @@
|
||||||
|
import { defineMessages } from 'react-intl';
|
||||||
|
|
||||||
|
import snackbar from 'soapbox/actions/snackbar';
|
||||||
|
import { isLoggedIn } from 'soapbox/utils/auth';
|
||||||
|
|
||||||
|
import api from '../api';
|
||||||
|
|
||||||
|
import { importFetchedAccounts, importFetchedStatus } from './importer';
|
||||||
|
|
||||||
|
import type { AxiosError } from 'axios';
|
||||||
|
import type { AppDispatch, RootState } from 'soapbox/store';
|
||||||
|
import type { APIEntity, Status as StatusEntity } from 'soapbox/types/entities';
|
||||||
|
|
||||||
|
const REBLOG_REQUEST = 'REBLOG_REQUEST';
|
||||||
|
const REBLOG_SUCCESS = 'REBLOG_SUCCESS';
|
||||||
|
const REBLOG_FAIL = 'REBLOG_FAIL';
|
||||||
|
|
||||||
|
const FAVOURITE_REQUEST = 'FAVOURITE_REQUEST';
|
||||||
|
const FAVOURITE_SUCCESS = 'FAVOURITE_SUCCESS';
|
||||||
|
const FAVOURITE_FAIL = 'FAVOURITE_FAIL';
|
||||||
|
|
||||||
|
const UNREBLOG_REQUEST = 'UNREBLOG_REQUEST';
|
||||||
|
const UNREBLOG_SUCCESS = 'UNREBLOG_SUCCESS';
|
||||||
|
const UNREBLOG_FAIL = 'UNREBLOG_FAIL';
|
||||||
|
|
||||||
|
const UNFAVOURITE_REQUEST = 'UNFAVOURITE_REQUEST';
|
||||||
|
const UNFAVOURITE_SUCCESS = 'UNFAVOURITE_SUCCESS';
|
||||||
|
const UNFAVOURITE_FAIL = 'UNFAVOURITE_FAIL';
|
||||||
|
|
||||||
|
const REBLOGS_FETCH_REQUEST = 'REBLOGS_FETCH_REQUEST';
|
||||||
|
const REBLOGS_FETCH_SUCCESS = 'REBLOGS_FETCH_SUCCESS';
|
||||||
|
const REBLOGS_FETCH_FAIL = 'REBLOGS_FETCH_FAIL';
|
||||||
|
|
||||||
|
const FAVOURITES_FETCH_REQUEST = 'FAVOURITES_FETCH_REQUEST';
|
||||||
|
const FAVOURITES_FETCH_SUCCESS = 'FAVOURITES_FETCH_SUCCESS';
|
||||||
|
const FAVOURITES_FETCH_FAIL = 'FAVOURITES_FETCH_FAIL';
|
||||||
|
|
||||||
|
const REACTIONS_FETCH_REQUEST = 'REACTIONS_FETCH_REQUEST';
|
||||||
|
const REACTIONS_FETCH_SUCCESS = 'REACTIONS_FETCH_SUCCESS';
|
||||||
|
const REACTIONS_FETCH_FAIL = 'REACTIONS_FETCH_FAIL';
|
||||||
|
|
||||||
|
const PIN_REQUEST = 'PIN_REQUEST';
|
||||||
|
const PIN_SUCCESS = 'PIN_SUCCESS';
|
||||||
|
const PIN_FAIL = 'PIN_FAIL';
|
||||||
|
|
||||||
|
const UNPIN_REQUEST = 'UNPIN_REQUEST';
|
||||||
|
const UNPIN_SUCCESS = 'UNPIN_SUCCESS';
|
||||||
|
const UNPIN_FAIL = 'UNPIN_FAIL';
|
||||||
|
|
||||||
|
const BOOKMARK_REQUEST = 'BOOKMARK_REQUEST';
|
||||||
|
const BOOKMARK_SUCCESS = 'BOOKMARKED_SUCCESS';
|
||||||
|
const BOOKMARK_FAIL = 'BOOKMARKED_FAIL';
|
||||||
|
|
||||||
|
const UNBOOKMARK_REQUEST = 'UNBOOKMARKED_REQUEST';
|
||||||
|
const UNBOOKMARK_SUCCESS = 'UNBOOKMARKED_SUCCESS';
|
||||||
|
const UNBOOKMARK_FAIL = 'UNBOOKMARKED_FAIL';
|
||||||
|
|
||||||
|
const REMOTE_INTERACTION_REQUEST = 'REMOTE_INTERACTION_REQUEST';
|
||||||
|
const REMOTE_INTERACTION_SUCCESS = 'REMOTE_INTERACTION_SUCCESS';
|
||||||
|
const REMOTE_INTERACTION_FAIL = 'REMOTE_INTERACTION_FAIL';
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
bookmarkAdded: { id: 'status.bookmarked', defaultMessage: 'Bookmark added.' },
|
||||||
|
bookmarkRemoved: { id: 'status.unbookmarked', defaultMessage: 'Bookmark removed.' },
|
||||||
|
view: { id: 'snackbar.view', defaultMessage: 'View' },
|
||||||
|
});
|
||||||
|
|
||||||
|
const reblog = (status: StatusEntity) =>
|
||||||
|
function(dispatch: AppDispatch, getState: () => RootState) {
|
||||||
|
if (!isLoggedIn(getState)) return;
|
||||||
|
|
||||||
|
dispatch(reblogRequest(status));
|
||||||
|
|
||||||
|
api(getState).post(`/api/v1/statuses/${status.get('id')}/reblog`).then(function(response) {
|
||||||
|
// The reblog API method returns a new status wrapped around the original. In this case we are only
|
||||||
|
// interested in how the original is modified, hence passing it skipping the wrapper
|
||||||
|
dispatch(importFetchedStatus(response.data.reblog));
|
||||||
|
dispatch(reblogSuccess(status));
|
||||||
|
}).catch(error => {
|
||||||
|
dispatch(reblogFail(status, error));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const unreblog = (status: StatusEntity) =>
|
||||||
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||||
|
if (!isLoggedIn(getState)) return;
|
||||||
|
|
||||||
|
dispatch(unreblogRequest(status));
|
||||||
|
|
||||||
|
api(getState).post(`/api/v1/statuses/${status.get('id')}/unreblog`).then(() => {
|
||||||
|
dispatch(unreblogSuccess(status));
|
||||||
|
}).catch(error => {
|
||||||
|
dispatch(unreblogFail(status, error));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const reblogRequest = (status: StatusEntity) => ({
|
||||||
|
type: REBLOG_REQUEST,
|
||||||
|
status: status,
|
||||||
|
skipLoading: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const reblogSuccess = (status: StatusEntity) => ({
|
||||||
|
type: REBLOG_SUCCESS,
|
||||||
|
status: status,
|
||||||
|
skipLoading: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const reblogFail = (status: StatusEntity, error: AxiosError) => ({
|
||||||
|
type: REBLOG_FAIL,
|
||||||
|
status: status,
|
||||||
|
error: error,
|
||||||
|
skipLoading: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const unreblogRequest = (status: StatusEntity) => ({
|
||||||
|
type: UNREBLOG_REQUEST,
|
||||||
|
status: status,
|
||||||
|
skipLoading: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const unreblogSuccess = (status: StatusEntity) => ({
|
||||||
|
type: UNREBLOG_SUCCESS,
|
||||||
|
status: status,
|
||||||
|
skipLoading: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const unreblogFail = (status: StatusEntity, error: AxiosError) => ({
|
||||||
|
type: UNREBLOG_FAIL,
|
||||||
|
status: status,
|
||||||
|
error: error,
|
||||||
|
skipLoading: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const favourite = (status: StatusEntity) =>
|
||||||
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||||
|
if (!isLoggedIn(getState)) return;
|
||||||
|
|
||||||
|
dispatch(favouriteRequest(status));
|
||||||
|
|
||||||
|
api(getState).post(`/api/v1/statuses/${status.get('id')}/favourite`).then(function(response) {
|
||||||
|
dispatch(favouriteSuccess(status));
|
||||||
|
}).catch(function(error) {
|
||||||
|
dispatch(favouriteFail(status, error));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const unfavourite = (status: StatusEntity) =>
|
||||||
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||||
|
if (!isLoggedIn(getState)) return;
|
||||||
|
|
||||||
|
dispatch(unfavouriteRequest(status));
|
||||||
|
|
||||||
|
api(getState).post(`/api/v1/statuses/${status.get('id')}/unfavourite`).then(() => {
|
||||||
|
dispatch(unfavouriteSuccess(status));
|
||||||
|
}).catch(error => {
|
||||||
|
dispatch(unfavouriteFail(status, error));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const favouriteRequest = (status: StatusEntity) => ({
|
||||||
|
type: FAVOURITE_REQUEST,
|
||||||
|
status: status,
|
||||||
|
skipLoading: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const favouriteSuccess = (status: StatusEntity) => ({
|
||||||
|
type: FAVOURITE_SUCCESS,
|
||||||
|
status: status,
|
||||||
|
skipLoading: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const favouriteFail = (status: StatusEntity, error: AxiosError) => ({
|
||||||
|
type: FAVOURITE_FAIL,
|
||||||
|
status: status,
|
||||||
|
error: error,
|
||||||
|
skipLoading: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const unfavouriteRequest = (status: StatusEntity) => ({
|
||||||
|
type: UNFAVOURITE_REQUEST,
|
||||||
|
status: status,
|
||||||
|
skipLoading: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const unfavouriteSuccess = (status: StatusEntity) => ({
|
||||||
|
type: UNFAVOURITE_SUCCESS,
|
||||||
|
status: status,
|
||||||
|
skipLoading: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const unfavouriteFail = (status: StatusEntity, error: AxiosError) => ({
|
||||||
|
type: UNFAVOURITE_FAIL,
|
||||||
|
status: status,
|
||||||
|
error: error,
|
||||||
|
skipLoading: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const bookmark = (status: StatusEntity) =>
|
||||||
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||||
|
dispatch(bookmarkRequest(status));
|
||||||
|
|
||||||
|
api(getState).post(`/api/v1/statuses/${status.get('id')}/bookmark`).then(function(response) {
|
||||||
|
dispatch(importFetchedStatus(response.data));
|
||||||
|
dispatch(bookmarkSuccess(status, response.data));
|
||||||
|
dispatch(snackbar.success(messages.bookmarkAdded, messages.view, '/bookmarks'));
|
||||||
|
}).catch(function(error) {
|
||||||
|
dispatch(bookmarkFail(status, error));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const unbookmark = (status: StatusEntity) =>
|
||||||
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||||
|
dispatch(unbookmarkRequest(status));
|
||||||
|
|
||||||
|
api(getState).post(`/api/v1/statuses/${status.get('id')}/unbookmark`).then(response => {
|
||||||
|
dispatch(importFetchedStatus(response.data));
|
||||||
|
dispatch(unbookmarkSuccess(status, response.data));
|
||||||
|
dispatch(snackbar.success(messages.bookmarkRemoved));
|
||||||
|
}).catch(error => {
|
||||||
|
dispatch(unbookmarkFail(status, error));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const bookmarkRequest = (status: StatusEntity) => ({
|
||||||
|
type: BOOKMARK_REQUEST,
|
||||||
|
status: status,
|
||||||
|
});
|
||||||
|
|
||||||
|
const bookmarkSuccess = (status: StatusEntity, response: APIEntity) => ({
|
||||||
|
type: BOOKMARK_SUCCESS,
|
||||||
|
status: status,
|
||||||
|
response: response,
|
||||||
|
});
|
||||||
|
|
||||||
|
const bookmarkFail = (status: StatusEntity, error: AxiosError) => ({
|
||||||
|
type: BOOKMARK_FAIL,
|
||||||
|
status: status,
|
||||||
|
error: error,
|
||||||
|
});
|
||||||
|
|
||||||
|
const unbookmarkRequest = (status: StatusEntity) => ({
|
||||||
|
type: UNBOOKMARK_REQUEST,
|
||||||
|
status: status,
|
||||||
|
});
|
||||||
|
|
||||||
|
const unbookmarkSuccess = (status: StatusEntity, response: APIEntity) => ({
|
||||||
|
type: UNBOOKMARK_SUCCESS,
|
||||||
|
status: status,
|
||||||
|
response: response,
|
||||||
|
});
|
||||||
|
|
||||||
|
const unbookmarkFail = (status: StatusEntity, error: AxiosError) => ({
|
||||||
|
type: UNBOOKMARK_FAIL,
|
||||||
|
status: status,
|
||||||
|
error,
|
||||||
|
});
|
||||||
|
|
||||||
|
const fetchReblogs = (id: string) =>
|
||||||
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||||
|
if (!isLoggedIn(getState)) return;
|
||||||
|
|
||||||
|
dispatch(fetchReblogsRequest(id));
|
||||||
|
|
||||||
|
api(getState).get(`/api/v1/statuses/${id}/reblogged_by`).then(response => {
|
||||||
|
dispatch(importFetchedAccounts(response.data));
|
||||||
|
dispatch(fetchReblogsSuccess(id, response.data));
|
||||||
|
}).catch(error => {
|
||||||
|
dispatch(fetchReblogsFail(id, error));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const fetchReblogsRequest = (id: string) => ({
|
||||||
|
type: REBLOGS_FETCH_REQUEST,
|
||||||
|
id,
|
||||||
|
});
|
||||||
|
|
||||||
|
const fetchReblogsSuccess = (id: string, accounts: APIEntity[]) => ({
|
||||||
|
type: REBLOGS_FETCH_SUCCESS,
|
||||||
|
id,
|
||||||
|
accounts,
|
||||||
|
});
|
||||||
|
|
||||||
|
const fetchReblogsFail = (id: string, error: AxiosError) => ({
|
||||||
|
type: REBLOGS_FETCH_FAIL,
|
||||||
|
id,
|
||||||
|
error,
|
||||||
|
});
|
||||||
|
|
||||||
|
const fetchFavourites = (id: string) =>
|
||||||
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||||
|
if (!isLoggedIn(getState)) return;
|
||||||
|
|
||||||
|
dispatch(fetchFavouritesRequest(id));
|
||||||
|
|
||||||
|
api(getState).get(`/api/v1/statuses/${id}/favourited_by`).then(response => {
|
||||||
|
dispatch(importFetchedAccounts(response.data));
|
||||||
|
dispatch(fetchFavouritesSuccess(id, response.data));
|
||||||
|
}).catch(error => {
|
||||||
|
dispatch(fetchFavouritesFail(id, error));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const fetchFavouritesRequest = (id: string) => ({
|
||||||
|
type: FAVOURITES_FETCH_REQUEST,
|
||||||
|
id,
|
||||||
|
});
|
||||||
|
|
||||||
|
const fetchFavouritesSuccess = (id: string, accounts: APIEntity[]) => ({
|
||||||
|
type: FAVOURITES_FETCH_SUCCESS,
|
||||||
|
id,
|
||||||
|
accounts,
|
||||||
|
});
|
||||||
|
|
||||||
|
const fetchFavouritesFail = (id: string, error: AxiosError) => ({
|
||||||
|
type: FAVOURITES_FETCH_FAIL,
|
||||||
|
id,
|
||||||
|
error,
|
||||||
|
});
|
||||||
|
|
||||||
|
const fetchReactions = (id: string) =>
|
||||||
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||||
|
dispatch(fetchReactionsRequest(id));
|
||||||
|
|
||||||
|
api(getState).get(`/api/v1/pleroma/statuses/${id}/reactions`).then(response => {
|
||||||
|
dispatch(importFetchedAccounts((response.data as APIEntity[]).map(({ accounts }) => accounts).flat()));
|
||||||
|
dispatch(fetchReactionsSuccess(id, response.data));
|
||||||
|
}).catch(error => {
|
||||||
|
dispatch(fetchReactionsFail(id, error));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const fetchReactionsRequest = (id: string) => ({
|
||||||
|
type: REACTIONS_FETCH_REQUEST,
|
||||||
|
id,
|
||||||
|
});
|
||||||
|
|
||||||
|
const fetchReactionsSuccess = (id: string, reactions: APIEntity[]) => ({
|
||||||
|
type: REACTIONS_FETCH_SUCCESS,
|
||||||
|
id,
|
||||||
|
reactions,
|
||||||
|
});
|
||||||
|
|
||||||
|
const fetchReactionsFail = (id: string, error: AxiosError) => ({
|
||||||
|
type: REACTIONS_FETCH_FAIL,
|
||||||
|
id,
|
||||||
|
error,
|
||||||
|
});
|
||||||
|
|
||||||
|
const pin = (status: StatusEntity) =>
|
||||||
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||||
|
if (!isLoggedIn(getState)) return;
|
||||||
|
|
||||||
|
dispatch(pinRequest(status));
|
||||||
|
|
||||||
|
api(getState).post(`/api/v1/statuses/${status.get('id')}/pin`).then(response => {
|
||||||
|
dispatch(importFetchedStatus(response.data));
|
||||||
|
dispatch(pinSuccess(status));
|
||||||
|
}).catch(error => {
|
||||||
|
dispatch(pinFail(status, error));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const pinRequest = (status: StatusEntity) => ({
|
||||||
|
type: PIN_REQUEST,
|
||||||
|
status,
|
||||||
|
skipLoading: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const pinSuccess = (status: StatusEntity) => ({
|
||||||
|
type: PIN_SUCCESS,
|
||||||
|
status,
|
||||||
|
skipLoading: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const pinFail = (status: StatusEntity, error: AxiosError) => ({
|
||||||
|
type: PIN_FAIL,
|
||||||
|
status,
|
||||||
|
error,
|
||||||
|
skipLoading: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const unpin = (status: StatusEntity) =>
|
||||||
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||||
|
if (!isLoggedIn(getState)) return;
|
||||||
|
|
||||||
|
dispatch(unpinRequest(status));
|
||||||
|
|
||||||
|
api(getState).post(`/api/v1/statuses/${status.get('id')}/unpin`).then(response => {
|
||||||
|
dispatch(importFetchedStatus(response.data));
|
||||||
|
dispatch(unpinSuccess(status));
|
||||||
|
}).catch(error => {
|
||||||
|
dispatch(unpinFail(status, error));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const unpinRequest = (status: StatusEntity) => ({
|
||||||
|
type: UNPIN_REQUEST,
|
||||||
|
status,
|
||||||
|
skipLoading: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const unpinSuccess = (status: StatusEntity) => ({
|
||||||
|
type: UNPIN_SUCCESS,
|
||||||
|
status,
|
||||||
|
skipLoading: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const unpinFail = (status: StatusEntity, error: AxiosError) => ({
|
||||||
|
type: UNPIN_FAIL,
|
||||||
|
status,
|
||||||
|
error,
|
||||||
|
skipLoading: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const remoteInteraction = (ap_id: string, profile: string) =>
|
||||||
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||||
|
dispatch(remoteInteractionRequest(ap_id, profile));
|
||||||
|
|
||||||
|
return api(getState).post('/api/v1/pleroma/remote_interaction', { ap_id, profile }).then(({ data }) => {
|
||||||
|
if (data.error) throw new Error(data.error);
|
||||||
|
|
||||||
|
dispatch(remoteInteractionSuccess(ap_id, profile, data.url));
|
||||||
|
|
||||||
|
return data.url;
|
||||||
|
}).catch(error => {
|
||||||
|
dispatch(remoteInteractionFail(ap_id, profile, error));
|
||||||
|
throw error;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const remoteInteractionRequest = (ap_id: string, profile: string) => ({
|
||||||
|
type: REMOTE_INTERACTION_REQUEST,
|
||||||
|
ap_id,
|
||||||
|
profile,
|
||||||
|
});
|
||||||
|
|
||||||
|
const remoteInteractionSuccess = (ap_id: string, profile: string, url: string) => ({
|
||||||
|
type: REMOTE_INTERACTION_SUCCESS,
|
||||||
|
ap_id,
|
||||||
|
profile,
|
||||||
|
url,
|
||||||
|
});
|
||||||
|
|
||||||
|
const remoteInteractionFail = (ap_id: string, profile: string, error: AxiosError) => ({
|
||||||
|
type: REMOTE_INTERACTION_FAIL,
|
||||||
|
ap_id,
|
||||||
|
profile,
|
||||||
|
error,
|
||||||
|
});
|
||||||
|
|
||||||
|
export {
|
||||||
|
REBLOG_REQUEST,
|
||||||
|
REBLOG_SUCCESS,
|
||||||
|
REBLOG_FAIL,
|
||||||
|
FAVOURITE_REQUEST,
|
||||||
|
FAVOURITE_SUCCESS,
|
||||||
|
FAVOURITE_FAIL,
|
||||||
|
UNREBLOG_REQUEST,
|
||||||
|
UNREBLOG_SUCCESS,
|
||||||
|
UNREBLOG_FAIL,
|
||||||
|
UNFAVOURITE_REQUEST,
|
||||||
|
UNFAVOURITE_SUCCESS,
|
||||||
|
UNFAVOURITE_FAIL,
|
||||||
|
REBLOGS_FETCH_REQUEST,
|
||||||
|
REBLOGS_FETCH_SUCCESS,
|
||||||
|
REBLOGS_FETCH_FAIL,
|
||||||
|
FAVOURITES_FETCH_REQUEST,
|
||||||
|
FAVOURITES_FETCH_SUCCESS,
|
||||||
|
FAVOURITES_FETCH_FAIL,
|
||||||
|
REACTIONS_FETCH_REQUEST,
|
||||||
|
REACTIONS_FETCH_SUCCESS,
|
||||||
|
REACTIONS_FETCH_FAIL,
|
||||||
|
PIN_REQUEST,
|
||||||
|
PIN_SUCCESS,
|
||||||
|
PIN_FAIL,
|
||||||
|
UNPIN_REQUEST,
|
||||||
|
UNPIN_SUCCESS,
|
||||||
|
UNPIN_FAIL,
|
||||||
|
BOOKMARK_REQUEST,
|
||||||
|
BOOKMARK_SUCCESS,
|
||||||
|
BOOKMARK_FAIL,
|
||||||
|
UNBOOKMARK_REQUEST,
|
||||||
|
UNBOOKMARK_SUCCESS,
|
||||||
|
UNBOOKMARK_FAIL,
|
||||||
|
REMOTE_INTERACTION_REQUEST,
|
||||||
|
REMOTE_INTERACTION_SUCCESS,
|
||||||
|
REMOTE_INTERACTION_FAIL,
|
||||||
|
reblog,
|
||||||
|
unreblog,
|
||||||
|
reblogRequest,
|
||||||
|
reblogSuccess,
|
||||||
|
reblogFail,
|
||||||
|
unreblogRequest,
|
||||||
|
unreblogSuccess,
|
||||||
|
unreblogFail,
|
||||||
|
favourite,
|
||||||
|
unfavourite,
|
||||||
|
favouriteRequest,
|
||||||
|
favouriteSuccess,
|
||||||
|
favouriteFail,
|
||||||
|
unfavouriteRequest,
|
||||||
|
unfavouriteSuccess,
|
||||||
|
unfavouriteFail,
|
||||||
|
bookmark,
|
||||||
|
unbookmark,
|
||||||
|
bookmarkRequest,
|
||||||
|
bookmarkSuccess,
|
||||||
|
bookmarkFail,
|
||||||
|
unbookmarkRequest,
|
||||||
|
unbookmarkSuccess,
|
||||||
|
unbookmarkFail,
|
||||||
|
fetchReblogs,
|
||||||
|
fetchReblogsRequest,
|
||||||
|
fetchReblogsSuccess,
|
||||||
|
fetchReblogsFail,
|
||||||
|
fetchFavourites,
|
||||||
|
fetchFavouritesRequest,
|
||||||
|
fetchFavouritesSuccess,
|
||||||
|
fetchFavouritesFail,
|
||||||
|
fetchReactions,
|
||||||
|
fetchReactionsRequest,
|
||||||
|
fetchReactionsSuccess,
|
||||||
|
fetchReactionsFail,
|
||||||
|
pin,
|
||||||
|
pinRequest,
|
||||||
|
pinSuccess,
|
||||||
|
pinFail,
|
||||||
|
unpin,
|
||||||
|
unpinRequest,
|
||||||
|
unpinSuccess,
|
||||||
|
unpinFail,
|
||||||
|
remoteInteraction,
|
||||||
|
remoteInteractionRequest,
|
||||||
|
remoteInteractionSuccess,
|
||||||
|
remoteInteractionFail,
|
||||||
|
};
|
|
@ -9,12 +9,12 @@ type SnackbarMessage = string | MessageDescriptor
|
||||||
export type SnackbarAction = {
|
export type SnackbarAction = {
|
||||||
type: typeof ALERT_SHOW
|
type: typeof ALERT_SHOW
|
||||||
message: SnackbarMessage
|
message: SnackbarMessage
|
||||||
actionLabel?: string
|
actionLabel?: SnackbarMessage
|
||||||
actionLink?: string
|
actionLink?: string
|
||||||
severity: SnackbarActionSeverity
|
severity: SnackbarActionSeverity
|
||||||
}
|
}
|
||||||
|
|
||||||
export const show = (severity: SnackbarActionSeverity, message: SnackbarMessage, actionLabel?: string, actionLink?: string): SnackbarAction => ({
|
export const show = (severity: SnackbarActionSeverity, message: SnackbarMessage, actionLabel?: SnackbarMessage, actionLink?: string): SnackbarAction => ({
|
||||||
type: ALERT_SHOW,
|
type: ALERT_SHOW,
|
||||||
message,
|
message,
|
||||||
actionLabel,
|
actionLabel,
|
||||||
|
@ -22,13 +22,13 @@ export const show = (severity: SnackbarActionSeverity, message: SnackbarMessage,
|
||||||
severity,
|
severity,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const info = (message: SnackbarMessage, actionLabel?: string, actionLink?: string) =>
|
export const info = (message: SnackbarMessage, actionLabel?: SnackbarMessage, actionLink?: string) =>
|
||||||
show('info', message, actionLabel, actionLink);
|
show('info', message, actionLabel, actionLink);
|
||||||
|
|
||||||
export const success = (message: SnackbarMessage, actionLabel?: string, actionLink?: string) =>
|
export const success = (message: SnackbarMessage, actionLabel?: SnackbarMessage, actionLink?: string) =>
|
||||||
show('success', message, actionLabel, actionLink);
|
show('success', message, actionLabel, actionLink);
|
||||||
|
|
||||||
export const error = (message: SnackbarMessage, actionLabel?: string, actionLink?: string) =>
|
export const error = (message: SnackbarMessage, actionLabel?: SnackbarMessage, actionLink?: string) =>
|
||||||
show('error', message, actionLabel, actionLink);
|
show('error', message, actionLabel, actionLink);
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
|
@ -48,7 +48,7 @@ const UnauthorizedModal: React.FC<IUnauthorizedModal> = ({ action, onClose, acco
|
||||||
const onSubmit: React.FormEventHandler = e => {
|
const onSubmit: React.FormEventHandler = e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
dispatch(remoteInteraction(apId, account))
|
dispatch(remoteInteraction(apId!, account))
|
||||||
.then(url => {
|
.then(url => {
|
||||||
window.open(url, '_new', 'noopener,noreferrer');
|
window.open(url, '_new', 'noopener,noreferrer');
|
||||||
onClose('UNAUTHORIZED');
|
onClose('UNAUTHORIZED');
|
||||||
|
|
Ładowanie…
Reference in New Issue