mirror of
https://github.com/PrimalHQ/primal-web-app.git
synced 2024-09-29 00:10:50 +00:00
Add caption on profile page if it's filtered
This commit is contained in:
parent
014aac2219
commit
f2229e033c
@ -71,7 +71,7 @@ export type AccountContextStore = {
|
||||
addFilterList: (pubkey: string | undefined) => void,
|
||||
removeFilterList: (pubkey: string | undefined) => void,
|
||||
updateFilterList: (pubkey: string | undefined, content?: boolean, trending?: boolean) => void,
|
||||
addToAllowlist: (pubkey: string | undefined) => void,
|
||||
addToAllowlist: (pubkey: string | undefined, then?: () => void) => void,
|
||||
removeFromAllowlist: (pubkey: string | undefined) => void,
|
||||
},
|
||||
}
|
||||
@ -881,7 +881,7 @@ export function AccountProvider(props: { children: number | boolean | Node | JSX
|
||||
getAllowlist(pubkey, subId);
|
||||
};
|
||||
|
||||
const addToAllowlist = async (pubkey: string | undefined) => {
|
||||
const addToAllowlist = async (pubkey: string | undefined, then?: () => void) => {
|
||||
if (!pubkey) {
|
||||
return;
|
||||
}
|
||||
@ -903,9 +903,9 @@ export function AccountProvider(props: { children: number | boolean | Node | JSX
|
||||
|
||||
if (success) {
|
||||
note && triggerImportEvents([note], `import_allowlist_event_add_${APP_ID}`)
|
||||
return;
|
||||
}
|
||||
|
||||
then && then();
|
||||
unsub();
|
||||
return;
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ export type ProfileContextStore = {
|
||||
lastNote: PrimalNote | undefined,
|
||||
following: string[],
|
||||
sidebar: FeedPage & { notes: PrimalNote[] },
|
||||
filterReason: { action: 'block' | 'allow', pubkey?: string, group?: string } | null,
|
||||
actions: {
|
||||
saveNotes: (newNotes: PrimalNote[]) => void,
|
||||
clearNotes: () => void,
|
||||
@ -96,6 +97,7 @@ export const initialData = {
|
||||
reposts: {},
|
||||
lastNote: undefined,
|
||||
following: [],
|
||||
filterReason: null,
|
||||
sidebar: {
|
||||
messages: [],
|
||||
users: {},
|
||||
@ -402,9 +404,10 @@ export const ProfileProvider = (props: { children: ContextChildren }) => {
|
||||
updateStore('profileKey', () => profileKey);
|
||||
|
||||
if (profileKey) {
|
||||
updateStore('filterReason', () => null);
|
||||
updateStore('userProfile', () => undefined);
|
||||
updateStore('userStats', () => ({ ...emptyStats }));
|
||||
getUserProfileInfo(profileKey, `profile_info_${APP_ID}`);
|
||||
getUserProfileInfo(profileKey, account?.publicKey, `profile_info_${APP_ID}`);
|
||||
getProfileScoredNotes(profileKey, account?.publicKey, `profile_scored_${APP_ID}`, 10);
|
||||
|
||||
isUserFollowing(profileKey, account?.publicKey, `is_profile_following_${APP_ID}`);
|
||||
@ -444,6 +447,14 @@ export const ProfileProvider = (props: { children: ContextChildren }) => {
|
||||
}
|
||||
|
||||
if (subId === `profile_info_${APP_ID}`) {
|
||||
if (content?.kind === Kind.FilteringReason) {
|
||||
const reason: { action: 'block' | 'allow', pubkey?: string, group?: string } | null =
|
||||
JSON.parse(content.content) || null;
|
||||
|
||||
if (reason?.action === 'block') {
|
||||
updateStore('filterReason', () => ({ ...reason }));
|
||||
}
|
||||
}
|
||||
|
||||
if (content?.kind === Kind.Metadata) {
|
||||
let user = JSON.parse(content.content);
|
||||
|
@ -16,14 +16,23 @@ export const getUserProfiles = (pubkeys: string[], subid: string) => {
|
||||
]));
|
||||
}
|
||||
|
||||
export const getUserProfileInfo = (pubkey: string | undefined, subid: string) => {
|
||||
export const getUserProfileInfo = (pubkey: string | undefined, user_pubkey: string | undefined, subid: string) => {
|
||||
if (!pubkey) {
|
||||
return;
|
||||
}
|
||||
|
||||
let payload: any = {
|
||||
pubkey,
|
||||
};
|
||||
|
||||
if (user_pubkey) {
|
||||
payload.user_pubkey = user_pubkey;
|
||||
}
|
||||
|
||||
sendMessage(JSON.stringify([
|
||||
"REQ",
|
||||
subid,
|
||||
{cache: ["user_profile", { pubkey }]},
|
||||
{cache: ["user_profile", payload]},
|
||||
]));
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ const Mutelist: Component = () => {
|
||||
}
|
||||
});
|
||||
|
||||
getUserProfileInfo(pubkey, subId);
|
||||
getUserProfileInfo(pubkey, undefined, subId);
|
||||
};
|
||||
|
||||
const user = (pubkey: string) => mutedUsers[pubkey];
|
||||
|
@ -6,8 +6,10 @@ import {
|
||||
createMemo,
|
||||
createSignal,
|
||||
For,
|
||||
Match,
|
||||
Resource,
|
||||
Show
|
||||
Show,
|
||||
Switch
|
||||
} from 'solid-js';
|
||||
import Avatar from '../components/Avatar/Avatar';
|
||||
import Branding from '../components/Branding/Branding';
|
||||
@ -197,10 +199,8 @@ const Profile: Component = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isMuted(pk)) {
|
||||
setTimeout(() => {
|
||||
profile?.actions.fetchNotes(pk);
|
||||
}, 500);
|
||||
if (!isMuted(pk) && account?.isKeyLookupDone) {
|
||||
profile?.actions.fetchNotes(pk);
|
||||
}
|
||||
});
|
||||
|
||||
@ -224,6 +224,10 @@ const Profile: Component = () => {
|
||||
(ignoreContentCheck ? true : isContentMuted);
|
||||
};
|
||||
|
||||
const isFiltered = () => {
|
||||
return profile?.filterReason !== null;
|
||||
};
|
||||
|
||||
const unMuteProfile = () => {
|
||||
if (!account || !profile?.profileKey) {
|
||||
return;
|
||||
@ -376,6 +380,14 @@ const Profile: Component = () => {
|
||||
toaster?.sendSuccess(intl.formatMessage(tToast.noteAuthorReported, { name: userName(profile?.userProfile)}));
|
||||
};
|
||||
|
||||
|
||||
const addToAllowlist = async () => {
|
||||
const pk = getHex();
|
||||
if (pk) {
|
||||
account?.actions.addToAllowlist(pk, () => { setProfile(pk) });
|
||||
}
|
||||
};
|
||||
|
||||
const copyProfileLink = () => {
|
||||
navigator.clipboard.writeText(`${window.location.href}`);
|
||||
setContext(false);
|
||||
@ -598,9 +610,13 @@ const Profile: Component = () => {
|
||||
</div>
|
||||
|
||||
<div class={styles.userFeed}>
|
||||
<Show
|
||||
when={!isMuted(profile?.profileKey)}
|
||||
<Switch
|
||||
fallback={
|
||||
<div style="margin-top: 40px;">
|
||||
<Loader />
|
||||
</div>
|
||||
}>
|
||||
<Match when={isMuted(profile?.profileKey)}>
|
||||
<div class={styles.mutedProfile}>
|
||||
{intl.formatMessage(
|
||||
t.isMuted,
|
||||
@ -612,24 +628,26 @@ const Profile: Component = () => {
|
||||
{intl.formatMessage(tActions.unmute)}
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<Show
|
||||
when={profile && profile.notes.length > 0}
|
||||
fallback={
|
||||
<div style="margin-top: 40px;">
|
||||
<Loader />
|
||||
</div>}
|
||||
>
|
||||
</Match>
|
||||
<Match when={isFiltered()}>
|
||||
<div class={styles.mutedProfile}>
|
||||
{intl.formatMessage(t.isFiltered)}
|
||||
<button
|
||||
onClick={addToAllowlist}
|
||||
>
|
||||
{intl.formatMessage(tActions.addToAllowlist)}
|
||||
</button>
|
||||
</div>
|
||||
</Match>
|
||||
<Match when={profile && profile.notes.length > 0}>
|
||||
<For each={profile?.notes}>
|
||||
{note => (
|
||||
<Note note={note} />
|
||||
)}
|
||||
</For>
|
||||
<Paginator loadNextPage={profile?.actions.fetchNextPage}/>
|
||||
</Show>
|
||||
</Show>
|
||||
|
||||
</Match>
|
||||
</Switch>
|
||||
</div>
|
||||
|
||||
<ConfirmModal
|
||||
|
@ -97,6 +97,11 @@ export const actions = {
|
||||
defaultMessage: 'unmute',
|
||||
description: 'Label un-mute button',
|
||||
},
|
||||
addToAllowlist: {
|
||||
id: 'actions.addToAllowlist',
|
||||
defaultMessage: 'Add to allowlist',
|
||||
description: 'Label add-to-allowlist button',
|
||||
},
|
||||
addRelay: {
|
||||
id: 'actions.addRelay',
|
||||
defaultMessage: 'add',
|
||||
@ -827,6 +832,11 @@ export const profile = {
|
||||
defaultMessage: '{name} is muted',
|
||||
description: 'Label indicating that the profile is muted',
|
||||
},
|
||||
isFiltered: {
|
||||
id: 'profile.isFiltered',
|
||||
defaultMessage: 'This account is hidden per your filter settings.',
|
||||
description: 'Label indicating that the profile is filtered',
|
||||
},
|
||||
};
|
||||
|
||||
export const search = {
|
||||
|
Loading…
Reference in New Issue
Block a user