1
0
Fork 0
forked from gitea/nas
nas/app/javascript/mastodon/actions/emoji_reactions.js
S.H 696e4a10d6
独自機能の追加などで他の部分への影響が分かるようにCI周りの修正 (#1)
* Fix EmojiFormatter failure

* Add notification_emails.warning setting default value

* Fix list spec failure and add antennas for spec response

* Fix domain block spec failure to add kb custom response

* Fix SearchQueryTransformer spec failure

* Fix Account#matches_display_name spec failure

* Fix UpdateStatusService changes mentions spec failure

* Fix RuboCop Lint

* Ignore brakeman warning

* Fix CI failure for ignore brakeman warning

* Fix migration failure

* Fix README

* Fix migration CI failure

* Fix some spec failure

* Format code for RuboCop lint failure

* Fix ESlint failure

* Fix haml-lint failure
2023-08-07 21:38:15 +09:00

94 lines
2.8 KiB
JavaScript

import api, { getLinks } from '../api';
import { importFetchedStatuses } from './importer';
export const EMOJI_REACTED_STATUSES_FETCH_REQUEST = 'EMOJI_REACTED_STATUSES_FETCH_REQUEST';
export const EMOJI_REACTED_STATUSES_FETCH_SUCCESS = 'EMOJI_REACTED_STATUSES_FETCH_SUCCESS';
export const EMOJI_REACTED_STATUSES_FETCH_FAIL = 'EMOJI_REACTED_STATUSES_FETCH_FAIL';
export const EMOJI_REACTED_STATUSES_EXPAND_REQUEST = 'EMOJI_REACTED_STATUSES_EXPAND_REQUEST';
export const EMOJI_REACTED_STATUSES_EXPAND_SUCCESS = 'EMOJI_REACTED_STATUSES_EXPAND_SUCCESS';
export const EMOJI_REACTED_STATUSES_EXPAND_FAIL = 'EMOJI_REACTED_STATUSES_EXPAND_FAIL';
export function fetchEmojiReactedStatuses() {
return (dispatch, getState) => {
if (getState().getIn(['status_lists', 'emoji_reactions', 'isLoading'])) {
return;
}
dispatch(fetchEmojiReactedStatusesRequest());
api(getState).get('/api/v1/emoji_reactions').then(response => {
const next = getLinks(response).refs.find(link => link.rel === 'next');
dispatch(importFetchedStatuses(response.data));
dispatch(fetchEmojiReactedStatusesSuccess(response.data, next ? next.uri : null));
}).catch(error => {
dispatch(fetchEmojiReactedStatusesFail(error));
});
};
}
export function fetchEmojiReactedStatusesRequest() {
return {
type: EMOJI_REACTED_STATUSES_FETCH_REQUEST,
skipLoading: true,
};
}
export function fetchEmojiReactedStatusesSuccess(statuses, next) {
return {
type: EMOJI_REACTED_STATUSES_FETCH_SUCCESS,
statuses,
next,
skipLoading: true,
};
}
export function fetchEmojiReactedStatusesFail(error) {
return {
type: EMOJI_REACTED_STATUSES_FETCH_FAIL,
error,
skipLoading: true,
};
}
export function expandEmojiReactedStatuses() {
return (dispatch, getState) => {
const url = getState().getIn(['status_lists', 'emoji_reactions', 'next'], null);
if (url === null || getState().getIn(['status_lists', 'emoji_reactions', 'isLoading'])) {
return;
}
dispatch(expandEmojiReactedStatusesRequest());
api(getState).get(url).then(response => {
const next = getLinks(response).refs.find(link => link.rel === 'next');
dispatch(importFetchedStatuses(response.data));
dispatch(expandEmojiReactedStatusesSuccess(response.data, next ? next.uri : null));
}).catch(error => {
dispatch(expandEmojiReactedStatusesFail(error));
});
};
}
export function expandEmojiReactedStatusesRequest() {
return {
type: EMOJI_REACTED_STATUSES_EXPAND_REQUEST,
};
}
export function expandEmojiReactedStatusesSuccess(statuses, next) {
return {
type: EMOJI_REACTED_STATUSES_EXPAND_SUCCESS,
statuses,
next,
};
}
export function expandEmojiReactedStatusesFail(error) {
return {
type: EMOJI_REACTED_STATUSES_EXPAND_FAIL,
error,
};
}