Remove Truth Social-specific features
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
@ -50,7 +50,6 @@ const COMPOSE_UPLOAD_FAIL = 'COMPOSE_UPLOAD_FAIL' as const;
|
||||
const COMPOSE_UPLOAD_PROGRESS = 'COMPOSE_UPLOAD_PROGRESS' as const;
|
||||
const COMPOSE_UPLOAD_UNDO = 'COMPOSE_UPLOAD_UNDO' as const;
|
||||
const COMPOSE_GROUP_POST = 'COMPOSE_GROUP_POST' as const;
|
||||
const COMPOSE_SET_GROUP_TIMELINE_VISIBLE = 'COMPOSE_SET_GROUP_TIMELINE_VISIBLE' as const;
|
||||
|
||||
const COMPOSE_SUGGESTIONS_CLEAR = 'COMPOSE_SUGGESTIONS_CLEAR' as const;
|
||||
const COMPOSE_SUGGESTIONS_READY = 'COMPOSE_SUGGESTIONS_READY' as const;
|
||||
@ -366,7 +365,6 @@ const submitCompose = (composeId: string, opts: SubmitComposeOpts = {}) =>
|
||||
|
||||
if (compose.privacy === 'group') {
|
||||
params.group_id = compose.group_id;
|
||||
params.group_timeline_visible = compose.group_timeline_visible; // Truth Social
|
||||
}
|
||||
|
||||
return dispatch(createStatus(params, idempotencyKey, statusId)).then(function(data) {
|
||||
@ -506,12 +504,6 @@ const groupCompose = (composeId: string, groupId: string) => ({
|
||||
group_id: groupId,
|
||||
});
|
||||
|
||||
const setGroupTimelineVisible = (composeId: string, groupTimelineVisible: boolean) => ({
|
||||
type: COMPOSE_SET_GROUP_TIMELINE_VISIBLE,
|
||||
id: composeId,
|
||||
groupTimelineVisible,
|
||||
});
|
||||
|
||||
const clearComposeSuggestions = (composeId: string) => {
|
||||
if (cancelFetchComposeSuggestions) {
|
||||
cancelFetchComposeSuggestions();
|
||||
@ -882,7 +874,6 @@ type ComposeAction =
|
||||
| ReturnType<typeof uploadComposeFail>
|
||||
| ReturnType<typeof undoUploadCompose>
|
||||
| ReturnType<typeof groupCompose>
|
||||
| ReturnType<typeof setGroupTimelineVisible>
|
||||
| ReturnType<typeof clearComposeSuggestions>
|
||||
| ComposeSuggestionsReadyAction
|
||||
| ComposeSuggestionSelectAction
|
||||
@ -954,7 +945,6 @@ export {
|
||||
COMPOSE_REMOVE_FROM_MENTIONS,
|
||||
COMPOSE_SET_STATUS,
|
||||
COMPOSE_EDITOR_STATE_SET,
|
||||
COMPOSE_SET_GROUP_TIMELINE_VISIBLE,
|
||||
COMPOSE_CHANGE_MEDIA_ORDER,
|
||||
setComposeToStatus,
|
||||
changeCompose,
|
||||
@ -984,7 +974,6 @@ export {
|
||||
undoUploadCompose,
|
||||
groupCompose,
|
||||
groupComposeModal,
|
||||
setGroupTimelineVisible,
|
||||
clearComposeSuggestions,
|
||||
fetchComposeSuggestions,
|
||||
readyComposeSuggestionsEmojis,
|
||||
|
||||
@ -89,7 +89,6 @@ const updateNotificationsQueue = (notification: APIEntity, intlMessages: Record<
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
if (!notification.type) return; // drop invalid notifications
|
||||
if (notification.type === 'pleroma:chat_mention') return; // Drop chat notifications, handle them per-chat
|
||||
if (notification.type === 'chat') return; // Drop Truth Social chat notifications.
|
||||
|
||||
const showAlert = getSettings(getState()).getIn(['notifications', 'alerts', notification.type]);
|
||||
const filters = getFilters(getState(), { contextType: 'notifications' });
|
||||
|
||||
@ -22,8 +22,6 @@ const REPORT_RULE_CHANGE = 'REPORT_RULE_CHANGE';
|
||||
|
||||
enum ReportableEntities {
|
||||
ACCOUNT = 'ACCOUNT',
|
||||
CHAT_MESSAGE = 'CHAT_MESSAGE',
|
||||
GROUP = 'GROUP',
|
||||
STATUS = 'STATUS'
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
|
||||
import toast from 'soapbox/toast';
|
||||
import { getLoggedInAccount } from 'soapbox/utils/auth';
|
||||
import { parseVersion, TRUTHSOCIAL } from 'soapbox/utils/features';
|
||||
import { normalizeUsername } from 'soapbox/utils/input';
|
||||
|
||||
import api from '../api';
|
||||
@ -86,8 +85,6 @@ const changePassword = (oldPassword: string, newPassword: string, confirmation:
|
||||
const resetPassword = (usernameOrEmail: string) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
const input = normalizeUsername(usernameOrEmail);
|
||||
const state = getState();
|
||||
const v = parseVersion(state.instance.version);
|
||||
|
||||
dispatch({ type: RESET_PASSWORD_REQUEST });
|
||||
|
||||
@ -96,12 +93,7 @@ const resetPassword = (usernameOrEmail: string) =>
|
||||
? { email: input }
|
||||
: { nickname: input, username: input };
|
||||
|
||||
const endpoint =
|
||||
v.software === TRUTHSOCIAL
|
||||
? '/api/v1/truth/password_reset/request'
|
||||
: '/auth/password';
|
||||
|
||||
return api(getState).post(endpoint, params).then(() => {
|
||||
return api(getState).post('/auth/password', params).then(() => {
|
||||
dispatch({ type: RESET_PASSWORD_SUCCESS });
|
||||
}).catch(error => {
|
||||
dispatch({ type: RESET_PASSWORD_FAIL, error });
|
||||
@ -109,19 +101,6 @@ const resetPassword = (usernameOrEmail: string) =>
|
||||
});
|
||||
};
|
||||
|
||||
const resetPasswordConfirm = (password: string, token: string) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
const params = { password, reset_password_token: token };
|
||||
dispatch({ type: RESET_PASSWORD_CONFIRM_REQUEST });
|
||||
|
||||
return api(getState).post('/api/v1/truth/password_reset/confirm', params).then(() => {
|
||||
dispatch({ type: RESET_PASSWORD_CONFIRM_SUCCESS });
|
||||
}).catch(error => {
|
||||
dispatch({ type: RESET_PASSWORD_CONFIRM_FAIL, error });
|
||||
throw error;
|
||||
});
|
||||
};
|
||||
|
||||
const changeEmail = (email: string, password: string) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
dispatch({ type: CHANGE_EMAIL_REQUEST, email });
|
||||
@ -137,10 +116,6 @@ const changeEmail = (email: string, password: string) =>
|
||||
});
|
||||
};
|
||||
|
||||
const confirmChangedEmail = (token: string) =>
|
||||
(_dispatch: AppDispatch, getState: () => RootState) =>
|
||||
api(getState).get(`/api/v1/truth/email/confirm?confirmation_token=${token}`);
|
||||
|
||||
const deleteAccount = (password: string) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
const account = getLoggedInAccount(getState());
|
||||
@ -203,9 +178,7 @@ export {
|
||||
revokeOAuthTokenById,
|
||||
changePassword,
|
||||
resetPassword,
|
||||
resetPasswordConfirm,
|
||||
changeEmail,
|
||||
confirmChangedEmail,
|
||||
deleteAccount,
|
||||
moveAccount,
|
||||
};
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import { isLoggedIn } from 'soapbox/utils/auth';
|
||||
import { getFeatures } from 'soapbox/utils/features';
|
||||
import { shouldHaveCard } from 'soapbox/utils/status';
|
||||
|
||||
import api, { getNextLink } from '../api';
|
||||
import api from '../api';
|
||||
|
||||
import { setComposeToStatus } from './compose';
|
||||
import { fetchGroupRelationships } from './groups';
|
||||
@ -195,62 +194,13 @@ const fetchContext = (id: string) =>
|
||||
});
|
||||
};
|
||||
|
||||
const fetchNext = (statusId: string, next: string) =>
|
||||
async(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
const response = await api(getState).get(next);
|
||||
dispatch(importFetchedStatuses(response.data));
|
||||
|
||||
dispatch({
|
||||
type: CONTEXT_FETCH_SUCCESS,
|
||||
id: statusId,
|
||||
ancestors: [],
|
||||
descendants: response.data,
|
||||
});
|
||||
|
||||
return { next: getNextLink(response) };
|
||||
};
|
||||
|
||||
const fetchAncestors = (id: string) =>
|
||||
async(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
const response = await api(getState).get(`/api/v1/statuses/${id}/context/ancestors`);
|
||||
dispatch(importFetchedStatuses(response.data));
|
||||
return response;
|
||||
};
|
||||
|
||||
const fetchDescendants = (id: string) =>
|
||||
async(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
const response = await api(getState).get(`/api/v1/statuses/${id}/context/descendants`);
|
||||
dispatch(importFetchedStatuses(response.data));
|
||||
return response;
|
||||
};
|
||||
|
||||
const fetchStatusWithContext = (id: string) =>
|
||||
async(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
const features = getFeatures(getState().instance);
|
||||
|
||||
if (features.paginatedContext) {
|
||||
await dispatch(fetchStatus(id));
|
||||
const responses = await Promise.all([
|
||||
dispatch(fetchAncestors(id)),
|
||||
dispatch(fetchDescendants(id)),
|
||||
]);
|
||||
|
||||
dispatch({
|
||||
type: CONTEXT_FETCH_SUCCESS,
|
||||
id,
|
||||
ancestors: responses[0].data,
|
||||
descendants: responses[1].data,
|
||||
});
|
||||
|
||||
const next = getNextLink(responses[1]);
|
||||
return { next };
|
||||
} else {
|
||||
await Promise.all([
|
||||
dispatch(fetchContext(id)),
|
||||
dispatch(fetchStatus(id)),
|
||||
]);
|
||||
return { next: undefined };
|
||||
}
|
||||
await Promise.all([
|
||||
dispatch(fetchContext(id)),
|
||||
dispatch(fetchStatus(id)),
|
||||
]);
|
||||
return { next: undefined };
|
||||
};
|
||||
|
||||
const muteStatus = (id: string) =>
|
||||
@ -381,9 +331,6 @@ export {
|
||||
deleteStatus,
|
||||
updateStatus,
|
||||
fetchContext,
|
||||
fetchNext,
|
||||
fetchAncestors,
|
||||
fetchDescendants,
|
||||
fetchStatusWithContext,
|
||||
muteStatus,
|
||||
unmuteStatus,
|
||||
|
||||
@ -4,11 +4,9 @@ import { importEntities } from 'soapbox/entity-store/actions';
|
||||
import { Entities } from 'soapbox/entity-store/entities';
|
||||
import { selectEntity } from 'soapbox/entity-store/selectors';
|
||||
import messages from 'soapbox/messages';
|
||||
import { ChatKeys, IChat, isLastMessage } from 'soapbox/queries/chats';
|
||||
import { queryClient } from 'soapbox/queries/client';
|
||||
import { announcementSchema, type Announcement, type Relationship } from 'soapbox/schemas';
|
||||
import { getUnreadChatsCount, updateChatListItem, updateChatMessage } from 'soapbox/utils/chats';
|
||||
import { removePageItem } from 'soapbox/utils/queries';
|
||||
import { getUnreadChatsCount, updateChatListItem } from 'soapbox/utils/chats';
|
||||
import { play, soundCache } from 'soapbox/utils/sounds';
|
||||
|
||||
import { connectStream } from '../stream';
|
||||
@ -27,41 +25,10 @@ import {
|
||||
|
||||
import type { IStatContext } from 'soapbox/contexts/stat-context';
|
||||
import type { AppDispatch, RootState } from 'soapbox/store';
|
||||
import type { APIEntity, Chat } from 'soapbox/types/entities';
|
||||
import type { APIEntity } from 'soapbox/types/entities';
|
||||
|
||||
const STREAMING_CHAT_UPDATE = 'STREAMING_CHAT_UPDATE';
|
||||
|
||||
const removeChatMessage = (payload: string) => {
|
||||
const data = JSON.parse(payload);
|
||||
const chatId = data.chat_id;
|
||||
const chatMessageId = data.deleted_message_id;
|
||||
|
||||
// If the user just deleted the "last_message", then let's invalidate
|
||||
// the Chat Search query so the Chat List will show the new "last_message".
|
||||
if (isLastMessage(chatMessageId)) {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ChatKeys.chatSearch(),
|
||||
});
|
||||
}
|
||||
|
||||
removePageItem(ChatKeys.chatMessages(chatId), chatMessageId, (o: any, n: any) => String(o.id) === String(n));
|
||||
};
|
||||
|
||||
// Update the specific Chat query data.
|
||||
const updateChatQuery = (chat: IChat) => {
|
||||
const cachedChat = queryClient.getQueryData<IChat>(ChatKeys.chat(chat.id));
|
||||
if (!cachedChat) {
|
||||
return;
|
||||
}
|
||||
|
||||
const newChat = {
|
||||
...cachedChat,
|
||||
latest_read_message_by_account: chat.latest_read_message_by_account,
|
||||
latest_read_message_created_at: chat.latest_read_message_created_at,
|
||||
};
|
||||
queryClient.setQueryData<Chat>(ChatKeys.chat(chat.id), newChat as any);
|
||||
};
|
||||
|
||||
const updateAnnouncementReactions = ({ announcement_id: id, name, count }: APIEntity) => {
|
||||
queryClient.setQueryData(['announcements'], (prevResult: Announcement[]) =>
|
||||
prevResult.map(value => {
|
||||
@ -149,7 +116,6 @@ const connectTimelineStream = (
|
||||
dispatch(fetchFilters());
|
||||
break;
|
||||
case 'pleroma:chat_update':
|
||||
case 'chat_message.created': // TruthSocial
|
||||
dispatch((_dispatch: AppDispatch, getState: () => RootState) => {
|
||||
const chat = JSON.parse(data.payload);
|
||||
const me = getState().me;
|
||||
@ -169,22 +135,6 @@ const connectTimelineStream = (
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 'chat_message.deleted': // TruthSocial
|
||||
removeChatMessage(data.payload);
|
||||
break;
|
||||
case 'chat_message.read': // TruthSocial
|
||||
dispatch((_dispatch: AppDispatch, getState: () => RootState) => {
|
||||
const chat = JSON.parse(data.payload);
|
||||
const me = getState().me;
|
||||
const isFromOtherUser = chat.account.id !== me;
|
||||
if (isFromOtherUser) {
|
||||
updateChatQuery(JSON.parse(data.payload));
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 'chat_message.reaction': // TruthSocial
|
||||
updateChatMessage(JSON.parse(data.payload));
|
||||
break;
|
||||
case 'pleroma:follow_relationships_update':
|
||||
dispatch(updateFollowRelationships(JSON.parse(data.payload)));
|
||||
break;
|
||||
|
||||
@ -243,9 +243,6 @@ const expandGroupTimeline = (id: string, { maxId }: Record<string, any> = {}, do
|
||||
const expandGroupFeaturedTimeline = (id: string) =>
|
||||
expandTimeline(`group:${id}:pinned`, `/api/v1/timelines/group/${id}`, { pinned: true });
|
||||
|
||||
const expandGroupTimelineFromTag = (id: string, tagName: string, { maxId }: Record<string, any> = {}, done = noOp) =>
|
||||
expandTimeline(`group:tags:${id}:${tagName}`, `/api/v1/timelines/group/${id}/tags/${tagName}`, { max_id: maxId }, done);
|
||||
|
||||
const expandGroupMediaTimeline = (id: string | number, { maxId }: Record<string, any> = {}) =>
|
||||
expandTimeline(`group:${id}:media`, `/api/v1/timelines/group/${id}`, { max_id: maxId, only_media: true, limit: 40, with_muted: true });
|
||||
|
||||
@ -345,7 +342,6 @@ export {
|
||||
expandListTimeline,
|
||||
expandGroupTimeline,
|
||||
expandGroupFeaturedTimeline,
|
||||
expandGroupTimelineFromTag,
|
||||
expandGroupMediaTimeline,
|
||||
expandHashtagTimeline,
|
||||
expandTimelineRequest,
|
||||
|
||||
Reference in New Issue
Block a user