Merge remote-tracking branch 'origin/main' into dashboard
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
34
src/features/nostr/Bech32Redirect.tsx
Normal file
34
src/features/nostr/Bech32Redirect.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
import { nip19 } from 'nostr-tools';
|
||||
import React from 'react';
|
||||
import { Redirect } from 'react-router-dom';
|
||||
|
||||
import MissingIndicator from 'soapbox/components/missing-indicator';
|
||||
|
||||
interface INIP19Redirect {
|
||||
params: {
|
||||
bech32: string;
|
||||
};
|
||||
}
|
||||
|
||||
const Bech32Redirect: React.FC<INIP19Redirect> = ({ params }) => {
|
||||
try {
|
||||
const result = nip19.decode(params.bech32);
|
||||
|
||||
switch (result.type) {
|
||||
case 'npub':
|
||||
case 'nprofile':
|
||||
return <Redirect to={`/@${params.bech32}`} />;
|
||||
case 'note':
|
||||
return <Redirect to={`/posts/${result.data}`} />;
|
||||
case 'nevent':
|
||||
return <Redirect to={`/posts/${result.data.id}`} />;
|
||||
default:
|
||||
return <MissingIndicator />;
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
return <MissingIndicator />;
|
||||
}
|
||||
};
|
||||
|
||||
export default Bech32Redirect;
|
||||
@@ -11,7 +11,7 @@ import List, { ListItem } from 'soapbox/components/list';
|
||||
import StatusContent from 'soapbox/components/status-content';
|
||||
import { Avatar, HStack, Icon, Modal, ProgressBar, Stack, Text } from 'soapbox/components/ui';
|
||||
import AccountContainer from 'soapbox/containers/account-container';
|
||||
import { useAppDispatch, useAppSelector } from 'soapbox/hooks';
|
||||
import { useAppDispatch, useAppSelector, useInstance } from 'soapbox/hooks';
|
||||
|
||||
import ConfirmationStep from './steps/confirmation-step';
|
||||
import OtherActionsStep from './steps/other-actions-step';
|
||||
@@ -104,7 +104,7 @@ const ReportModal = ({ onClose }: IReportModal) => {
|
||||
const entityType = useAppSelector((state) => state.reports.new.entityType);
|
||||
const isBlocked = useAppSelector((state) => state.reports.new.block);
|
||||
const isSubmitting = useAppSelector((state) => state.reports.new.isSubmitting);
|
||||
const rules = useAppSelector((state) => state.rules.items);
|
||||
const { rules } = useInstance();
|
||||
const ruleIds = useAppSelector((state) => state.reports.new.rule_ids);
|
||||
const selectedStatusIds = useAppSelector((state) => state.reports.new.status_ids);
|
||||
const selectedChatMessage = useAppSelector((state) => state.reports.new.chat_message);
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { OrderedSet } from 'immutable';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import React, { useState } from 'react';
|
||||
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
||||
|
||||
import { changeReportBlock, changeReportForward } from 'soapbox/actions/reports';
|
||||
import { fetchRules } from 'soapbox/actions/rules';
|
||||
import { Button, FormGroup, HStack, Stack, Text, Toggle } from 'soapbox/components/ui';
|
||||
import StatusCheckBox from 'soapbox/features/report/components/status-check-box';
|
||||
import { useAppDispatch, useAppSelector, useFeatures } from 'soapbox/hooks';
|
||||
@@ -44,10 +43,6 @@ const OtherActionsStep = ({ account }: IOtherActionsStep) => {
|
||||
dispatch(changeReportForward(event.target.checked));
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(fetchRules());
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Stack space={4}>
|
||||
{features.reportMultipleStatuses && (
|
||||
|
||||
@@ -3,11 +3,11 @@ import React, { useEffect, useRef, useState } from 'react';
|
||||
import { defineMessages, useIntl } from 'react-intl';
|
||||
|
||||
import { changeReportComment, changeReportRule, ReportableEntities } from 'soapbox/actions/reports';
|
||||
import { fetchRules } from 'soapbox/actions/rules';
|
||||
import { FormGroup, Stack, Text, Textarea } from 'soapbox/components/ui';
|
||||
import { useAppDispatch, useAppSelector } from 'soapbox/hooks';
|
||||
import { useAppDispatch, useAppSelector, useInstance } from 'soapbox/hooks';
|
||||
|
||||
import type { Account } from 'soapbox/schemas';
|
||||
import type { Rule } from 'soapbox/schemas/rule';
|
||||
|
||||
const messages = defineMessages({
|
||||
placeholder: { id: 'report.placeholder', defaultMessage: 'Additional comments' },
|
||||
@@ -31,7 +31,7 @@ const ReasonStep: React.FC<IReasonStep> = () => {
|
||||
|
||||
const entityType = useAppSelector((state) => state.reports.new.entityType);
|
||||
const comment = useAppSelector((state) => state.reports.new.comment);
|
||||
const rules = useAppSelector((state) => state.rules.items);
|
||||
const { rules } = useInstance();
|
||||
const ruleIds = useAppSelector((state) => state.reports.new.rule_ids);
|
||||
const shouldRequireRule = rules.length > 0;
|
||||
|
||||
@@ -57,7 +57,7 @@ const ReasonStep: React.FC<IReasonStep> = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const filterRuleType = (rule: any) => {
|
||||
const filterRuleType = (rule: Rule) => {
|
||||
let ruleTypeToFilter = 'content';
|
||||
|
||||
switch (entityType) {
|
||||
@@ -83,10 +83,6 @@ const ReasonStep: React.FC<IReasonStep> = () => {
|
||||
return true;
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(fetchRules());
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (rules.length > 0 && rulesListRef.current) {
|
||||
const { clientHeight } = rulesListRef.current;
|
||||
@@ -136,7 +132,7 @@ const ReasonStep: React.FC<IReasonStep> = () => {
|
||||
>
|
||||
{rule.text}
|
||||
</Text>
|
||||
<Text tag='span' theme='muted' size='sm'>{rule.subtext}</Text>
|
||||
<Text tag='span' theme='muted' size='sm'>{rule.hint}</Text>
|
||||
</Stack>
|
||||
|
||||
<input
|
||||
|
||||
@@ -140,6 +140,7 @@ import {
|
||||
EditIdentity,
|
||||
Domains,
|
||||
NostrRelays,
|
||||
Bech32Redirect,
|
||||
Relays,
|
||||
} from './util/async-components';
|
||||
import GlobalHotkeys from './util/global-hotkeys';
|
||||
@@ -285,6 +286,7 @@ const SwitchingColumnsArea: React.FC<ISwitchingColumnsArea> = ({ children }) =>
|
||||
{features.events && <WrappedRoute path='/@:username/events/:statusId' publicRoute exact page={EventPage} component={EventInformation} content={children} />}
|
||||
{features.events && <WrappedRoute path='/@:username/events/:statusId/discussion' publicRoute exact page={EventPage} component={EventDiscussion} content={children} />}
|
||||
<Redirect from='/@:username/:statusId' to='/@:username/posts/:statusId' />
|
||||
<WrappedRoute path='/posts/:statusId' publicRoute exact page={DefaultPage} component={Status} content={children} />
|
||||
|
||||
{features.groups && <WrappedRoute path='/groups' exact page={GroupsPage} component={Groups} content={children} />}
|
||||
{features.groupsDiscovery && <WrappedRoute path='/groups/discover' exact page={GroupsPage} component={GroupsDiscover} content={children} />}
|
||||
@@ -363,6 +365,8 @@ const SwitchingColumnsArea: React.FC<ISwitchingColumnsArea> = ({ children }) =>
|
||||
<Redirect from='/auth/password/new' to='/reset-password' />
|
||||
<Redirect from='/auth/password/edit' to={`/edit-password${search}`} />
|
||||
|
||||
<WrappedRoute path='/:bech32([\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,})' publicRoute page={EmptyPage} component={Bech32Redirect} content={children} />
|
||||
|
||||
<WrappedRoute page={EmptyPage} component={GenericNotFound} content={children} />
|
||||
</Switch>
|
||||
);
|
||||
|
||||
@@ -171,4 +171,5 @@ export const EditIdentity = lazy(() => import('soapbox/features/edit-identity'))
|
||||
export const Domains = lazy(() => import('soapbox/features/admin/domains'));
|
||||
export const EditDomainModal = lazy(() => import('soapbox/features/ui/components/modals/edit-domain-modal'));
|
||||
export const NostrRelays = lazy(() => import('soapbox/features/nostr-relays'));
|
||||
export const Bech32Redirect = lazy(() => import('soapbox/features/nostr/Bech32Redirect'));
|
||||
export const Relays = lazy(() => import('soapbox/features/admin/relays'));
|
||||
|
||||
Reference in New Issue
Block a user