pl-fe: support loading conversation/recent posts on mitra
Signed-off-by: Nicole Mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -906,7 +906,7 @@ class PlApiClient {
|
||||
* Requires features{@link Features.loadActivities}
|
||||
*/
|
||||
loadActivities: async (accountId: string) => {
|
||||
const response = await this.request<{}>(`/api/v1/accounts/${accountId}/load_activities`);
|
||||
const response = await this.request<{}>(`/api/v1/accounts/${accountId}/load_activities`, { method: 'POST' });
|
||||
|
||||
return response.json;
|
||||
},
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pl-api",
|
||||
"version": "1.0.0-rc.53",
|
||||
"version": "1.0.0-rc.54",
|
||||
"type": "module",
|
||||
"homepage": "https://github.com/mkljczk/pl-fe/tree/develop/packages/pl-api",
|
||||
"repository": {
|
||||
|
||||
@ -104,7 +104,7 @@
|
||||
"multiselect-react-dropdown": "^2.0.25",
|
||||
"mutative": "^1.1.0",
|
||||
"path-browserify": "^1.0.1",
|
||||
"pl-api": "^1.0.0-rc.53",
|
||||
"pl-api": "^1.0.0-rc.54",
|
||||
"postcss": "^8.5.3",
|
||||
"process": "^0.11.10",
|
||||
"punycode": "^2.1.1",
|
||||
|
||||
@ -23,6 +23,7 @@ import { languages } from 'pl-fe/features/preferences';
|
||||
import { useAppDispatch } from 'pl-fe/hooks/use-app-dispatch';
|
||||
import { useAppSelector } from 'pl-fe/hooks/use-app-selector';
|
||||
import { useCanInteract } from 'pl-fe/hooks/use-can-interact';
|
||||
import { useClient } from 'pl-fe/hooks/use-client';
|
||||
import { useFeatures } from 'pl-fe/hooks/use-features';
|
||||
import { useInstance } from 'pl-fe/hooks/use-instance';
|
||||
import { useOwnAccount } from 'pl-fe/hooks/use-own-account';
|
||||
@ -83,6 +84,9 @@ const messages = defineMessages({
|
||||
groupModDelete: { id: 'status.group_mod_delete', defaultMessage: 'Delete post from group' },
|
||||
group_remove_account: { id: 'status.remove_account_from_group', defaultMessage: 'Remove account from group' },
|
||||
group_remove_post: { id: 'status.remove_post_from_group', defaultMessage: 'Remove post from group' },
|
||||
loadConversation: { id: 'status.load_conversation', defaultMessage: 'Load conversation from remote server' },
|
||||
loadConversationError: { id: 'status.load_conversation.error', defaultMessage: 'Failed to load conversation from a remote server' },
|
||||
loadConversationSuccess: { id: 'status.load_conversation.success', defaultMessage: 'Scheduled loading conversation from a remote server' },
|
||||
markStatusNotSensitive: { id: 'admin.statuses.actions.mark_status_not_sensitive', defaultMessage: 'Mark post not sensitive' },
|
||||
markStatusSensitive: { id: 'admin.statuses.actions.mark_status_sensitive', defaultMessage: 'Mark post sensitive' },
|
||||
mention: { id: 'status.mention', defaultMessage: 'Mention @{name}' },
|
||||
@ -586,6 +590,7 @@ const MenuButton: React.FC<IMenuButton> = ({
|
||||
const dispatch = useAppDispatch();
|
||||
const match = useRouteMatch<{ groupId: string }>('/groups/:groupId');
|
||||
const { boostModal } = useSettings();
|
||||
const client = useClient();
|
||||
|
||||
const { statuses: statusesMeta, fetchTranslation, hideTranslation } = useStatusMetaStore();
|
||||
const targetLanguage = statusesMeta[status.id]?.targetLanguage;
|
||||
@ -727,6 +732,12 @@ const MenuButton: React.FC<IMenuButton> = ({
|
||||
dispatch(toggleMuteStatus(status));
|
||||
};
|
||||
|
||||
const handleLoadConversationClick = () => {
|
||||
client.statuses.loadConversation(status.id)
|
||||
.then(() => toast.success(messages.loadConversationSuccess))
|
||||
.catch((error) => toast.error(messages.loadConversationError));
|
||||
};
|
||||
|
||||
const handleCopy: React.EventHandler<React.MouseEvent> = (e) => {
|
||||
const { uri } = status;
|
||||
|
||||
@ -864,6 +875,14 @@ const MenuButton: React.FC<IMenuButton> = ({
|
||||
icon: mutingConversation ? require('@tabler/icons/outline/bell.svg') : require('@tabler/icons/outline/bell-off.svg'),
|
||||
});
|
||||
|
||||
if (!status.in_reply_to_id && features.loadConversation) {
|
||||
menu.push({
|
||||
text: intl.formatMessage(messages.loadConversation),
|
||||
action: handleLoadConversationClick,
|
||||
icon: require('@tabler/icons/outline/refresh.svg'),
|
||||
});
|
||||
}
|
||||
|
||||
menu.push(null);
|
||||
|
||||
if (publicStatus && !status.reblogged && features.reblogVisibility) {
|
||||
|
||||
@ -20,7 +20,7 @@ import MovedNote from 'pl-fe/features/account-timeline/components/moved-note';
|
||||
import ActionButton from 'pl-fe/features/ui/components/action-button';
|
||||
import SubscriptionButton from 'pl-fe/features/ui/components/subscription-button';
|
||||
import { useAppDispatch } from 'pl-fe/hooks/use-app-dispatch';
|
||||
import { useAppSelector } from 'pl-fe/hooks/use-app-selector';
|
||||
import { useClient } from 'pl-fe/hooks/use-client';
|
||||
import { useFeatures } from 'pl-fe/hooks/use-features';
|
||||
import { useOwnAccount } from 'pl-fe/hooks/use-own-account';
|
||||
import { useChats } from 'pl-fe/queries/chats';
|
||||
@ -79,6 +79,9 @@ const messages = defineMessages({
|
||||
profileExternal: { id: 'account.profile_external', defaultMessage: 'View profile on {domain}' },
|
||||
header: { id: 'account.header.alt', defaultMessage: 'Profile header' },
|
||||
subscribeFeed: { id: 'account.rss_feed', defaultMessage: 'Subscribe to RSS feed' },
|
||||
loadActivities: { id: 'account.load_activities', defaultMessage: 'Fetch latest posts' },
|
||||
loadActivitiesSuccess: { id: 'account.load_activities.success', defaultMessage: 'Scheduled fetching latest posts' },
|
||||
loadActivitiesFail: { id: 'account.load_activities.fail', defaultMessage: 'Failed to fetch latest posts' },
|
||||
});
|
||||
|
||||
interface IHeader {
|
||||
@ -89,6 +92,7 @@ const Header: React.FC<IHeader> = ({ account }) => {
|
||||
const intl = useIntl();
|
||||
const history = useHistory();
|
||||
const dispatch = useAppDispatch();
|
||||
const client = useClient();
|
||||
|
||||
const features = useFeatures();
|
||||
const { account: ownAccount } = useOwnAccount();
|
||||
@ -96,7 +100,7 @@ const Header: React.FC<IHeader> = ({ account }) => {
|
||||
const { openModal } = useModalsStore();
|
||||
const { settings } = useSettingsStore();
|
||||
|
||||
const { software } = useAppSelector((state) => state.auth.client.features.version);
|
||||
const { software } = features.version;
|
||||
|
||||
const { getOrCreateChatByAccountId } = useChats();
|
||||
|
||||
@ -189,6 +193,12 @@ const Header: React.FC<IHeader> = ({ account }) => {
|
||||
.catch(() => toast.error(intl.formatMessage(messages.userBiteFail, { acct: account.acct })));
|
||||
};
|
||||
|
||||
const onLoadActivities = () => {
|
||||
client.accounts.loadActivities(account.id)
|
||||
.then(() => toast.success(intl.formatMessage(messages.loadActivitiesSuccess)))
|
||||
.catch(() => toast.error(intl.formatMessage(messages.loadActivitiesFail)));
|
||||
};
|
||||
|
||||
const onReport = () => {
|
||||
dispatch(initReport(ReportableEntities.ACCOUNT, account));
|
||||
};
|
||||
@ -423,6 +433,14 @@ const Header: React.FC<IHeader> = ({ account }) => {
|
||||
});
|
||||
}
|
||||
|
||||
if (features.loadActivities && !account.local) {
|
||||
menu.push({
|
||||
text: intl.formatMessage(messages.loadActivities),
|
||||
action: onLoadActivities,
|
||||
icon: require('@tabler/icons/outline/refresh.svg'),
|
||||
});
|
||||
}
|
||||
|
||||
menu.push(null);
|
||||
|
||||
if (features.removeFromFollowers && account.relationship?.followed_by) {
|
||||
|
||||
@ -34,6 +34,9 @@
|
||||
"account.hide_reblogs": "Hide reposts from @{name}",
|
||||
"account.last_status": "Last active",
|
||||
"account.link_verified_on": "Ownership of this link was checked on {date}",
|
||||
"account.load_activities": "Fetch latest posts",
|
||||
"account.load_activities.fail": "Failed to fetch latest posts",
|
||||
"account.load_activities.success": "Scheduled fetching latest posts",
|
||||
"account.locked_info": "This account privacy status is set to locked. The owner manually reviews who can follow them.",
|
||||
"account.login": "Log in",
|
||||
"account.media": "Media",
|
||||
@ -1548,6 +1551,9 @@
|
||||
"status.interactions.quotes": "{count, plural, one {Quote} other {Quotes}}",
|
||||
"status.interactions.reblogs": "{count, plural, one {Repost} other {Reposts}}",
|
||||
"status.language_versions": "The post has multiple language versions.",
|
||||
"status.load_conversation": "Load conversation from remote server",
|
||||
"status.load_conversation.error": "Failed to load conversation from a remote server",
|
||||
"status.load_conversation.success": "Scheduled loading conversation from a remote server",
|
||||
"status.load_more": "Load more",
|
||||
"status.mention": "Mention @{name}",
|
||||
"status.more": "More",
|
||||
|
||||
@ -6858,10 +6858,10 @@ pkg-dir@^4.1.0:
|
||||
dependencies:
|
||||
find-up "^4.0.0"
|
||||
|
||||
pl-api@^1.0.0-rc.53:
|
||||
version "1.0.0-rc.53"
|
||||
resolved "https://registry.yarnpkg.com/pl-api/-/pl-api-1.0.0-rc.53.tgz#a75a3042ee3aa95e471cfc33d10071971dfd8eae"
|
||||
integrity sha512-AOaway8G/S0FNOBrm3yTF6mYnDWOh9vXCynn1HOzTi6ghCC/qS2BA8g1eRENYK9PbsiPCMXQ3YdrI9vuZ62d+Q==
|
||||
pl-api@^1.0.0-rc.54:
|
||||
version "1.0.0-rc.54"
|
||||
resolved "https://registry.yarnpkg.com/pl-api/-/pl-api-1.0.0-rc.54.tgz#458e0404b933048f7be2629b07b7764795b1907d"
|
||||
integrity sha512-ceP1I6zQvlIFqZeqAG8DSsodYwxj4BdMVT6GgZ7amyJVM+6OTHiv/uZT9lltjKxZXWfZZaSV259onsqvwnLw8w==
|
||||
dependencies:
|
||||
blurhash "^2.0.5"
|
||||
http-link-header "^1.1.3"
|
||||
|
||||
Reference in New Issue
Block a user