link to profile when member/group is not from own system

This commit is contained in:
Fulmine 2022-03-19 17:22:50 +01:00
parent e6752e8568
commit 8eaa66e7f7
2 changed files with 22 additions and 10 deletions

View File

@ -23,6 +23,7 @@
let systemMembers: Group[] = []; let systemMembers: Group[] = [];
let isMainDash = false; let isMainDash = false;
let isDeleted = false; let isDeleted = false;
let notOwnSystem = false;
const isPage = true; const isPage = true;
export let isPublic = true; export let isPublic = true;
@ -45,7 +46,10 @@
async function fetchGroup() { async function fetchGroup() {
try { try {
group = await api().groups($params.id).get({auth: !isPublic}); group = await api().groups($params.id).get({auth: !isPublic});
if (!isPublic && !group.privacy) throw new Error("This group does not belong to your system, did you mean to look up their public page?") if (!isPublic && !group.privacy) {
notOwnSystem = true;
throw new Error("Group is not from own system.");
}
err = ""; err = "";
loading = false; loading = false;
memberLoading = true; memberLoading = true;
@ -101,10 +105,10 @@
} }
</script> </script>
{#if settings && settings.appearance.color_background} {#if settings && settings.appearance.color_background && !notOwnSystem}
<div class="background" style="background-color: {group && `#${group.color}`}"></div> <div class="background" style="background-color: {group && `#${group.color}`}"></div>
{/if} {/if}
{#if group && group.banner && ((settings && settings.appearance.banner_top))} {#if group && group.banner && settings && settings.appearance.banner_top && !notOwnSystem}
<div class="banner" style="background-image: url({group.banner})" /> <div class="banner" style="background-image: url({group.banner})" />
{/if} {/if}
<Container> <Container>
@ -116,8 +120,10 @@
{#if isPublic} {#if isPublic}
<Alert color="info">You are currently <b>viewing</b> a group.</Alert> <Alert color="info">You are currently <b>viewing</b> a group.</Alert>
{/if} {/if}
{#if err} {#if notOwnSystem}
<Alert color="danger">{err}</Alert> <Alert color="danger">This group does not belong to your system, did you mean to look up <Link to={`/profile/g/${group.id}`}>it's public page</Link>?</Alert>
{:else if err}
<Alert color="danger">{@html err}</Alert>
{:else if loading} {:else if loading}
<Spinner/> <Spinner/>
{:else if group && group.id} {:else if group && group.id}

View File

@ -24,6 +24,7 @@
let systemMembers: Member[] = []; let systemMembers: Member[] = [];
let isMainDash = false; let isMainDash = false;
let isDeleted = false; let isDeleted = false;
let notOwnSystem = false;
const isPage = true; const isPage = true;
export let isPublic = true; export let isPublic = true;
@ -46,7 +47,10 @@
async function fetchMember() { async function fetchMember() {
try { try {
member = await api().members($params.id).get({auth: !isPublic}); member = await api().members($params.id).get({auth: !isPublic});
if (!isPublic && !member.privacy) throw new Error("This member does not belong to your system, did you mean to look up their public page?") if (!isPublic && !member.privacy) {
notOwnSystem = true;
throw new Error("Member is not from own system.");
}
err = ""; err = "";
loading = false; loading = false;
groupLoading = true; groupLoading = true;
@ -102,10 +106,10 @@
} }
</script> </script>
{#if settings && settings.appearance.color_background} {#if settings && settings.appearance.color_background && !notOwnSystem}
<div class="background" style="background-color: {member && `#${member.color}`}"></div> <div class="background" style="background-color: {member && `#${member.color}`}"></div>
{/if} {/if}
{#if member && member.banner && ((settings && settings.appearance.banner_top))} {#if member && member.banner && settings && settings.appearance.banner_top && !notOwnSystem}
<div class="banner" style="background-image: url({member.banner})" /> <div class="banner" style="background-image: url({member.banner})" />
{/if} {/if}
<Container> <Container>
@ -117,8 +121,10 @@
{#if isPublic} {#if isPublic}
<Alert color="info">You are currently <b>viewing</b> a member.</Alert> <Alert color="info">You are currently <b>viewing</b> a member.</Alert>
{/if} {/if}
{#if err} {#if notOwnSystem}
<Alert color="danger">{err}</Alert> <Alert color="danger">This member does not belong to your system, did you mean to look up <Link to={`/profile/m/${member.id}`}>their public page</Link>?</Alert>
{:else if err}
<Alert color="danger">{@html err}</Alert>
{:else if loading} {:else if loading}
<Spinner/> <Spinner/>
{:else if member && member.id} {:else if member && member.id}