mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(challenge-utils): format challenge errors with board identifier
This commit is contained in:
@@ -1,4 +1,15 @@
|
|||||||
import { ChallengeVerification } from '@plebbit/plebbit-react-hooks';
|
import { ChallengeVerification } from '@plebbit/plebbit-react-hooks';
|
||||||
|
import directoriesData from '../../data/5chan-directories.json';
|
||||||
|
import { getBoardPath } from './route-utils';
|
||||||
|
|
||||||
|
const resolveBoardIdentifier = (subplebbitAddress: unknown): string => {
|
||||||
|
if (typeof subplebbitAddress !== 'string' || !subplebbitAddress) {
|
||||||
|
return 'unknown board';
|
||||||
|
}
|
||||||
|
|
||||||
|
const boardPath = getBoardPath(subplebbitAddress, directoriesData.communities);
|
||||||
|
return boardPath === subplebbitAddress ? subplebbitAddress : `/${boardPath}/`;
|
||||||
|
};
|
||||||
|
|
||||||
export const alertChallengeVerificationFailed = (challengeVerification: ChallengeVerification, publication: any) => {
|
export const alertChallengeVerificationFailed = (challengeVerification: ChallengeVerification, publication: any) => {
|
||||||
if (challengeVerification?.challengeSuccess === false) {
|
if (challengeVerification?.challengeSuccess === false) {
|
||||||
@@ -25,7 +36,7 @@ export const alertChallengeVerificationFailed = (challengeVerification: Challeng
|
|||||||
|
|
||||||
const finalMessage = errorMessages.filter(Boolean).join(' ');
|
const finalMessage = errorMessages.filter(Boolean).join(' ');
|
||||||
|
|
||||||
alert(`p/${publication?.subplebbitAddress} error: ${finalMessage || 'unknown error'}`);
|
alert(`Error from ${resolveBoardIdentifier(publication?.subplebbitAddress)}: ${finalMessage || 'unknown error'}`);
|
||||||
} else {
|
} else {
|
||||||
console.warn('Challenge verification succeeded but no action taken:', challengeVerification);
|
console.warn('Challenge verification succeeded but no action taken:', challengeVerification);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user