Skip to content

Commit

Permalink
Merge pull request #1850 from GW2Treasures/feature/wintersday-wizards…
Browse files Browse the repository at this point in the history
…vault-login-notice

Hide repeated login notifications on wintersday wizards vault page
  • Loading branch information
darthmaim authored Dec 10, 2024
2 parents 065f40e + 84ee44f commit c20e943
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const loadData = cache(async function loadData() {
export default async function WintersdayAchievementsPage({ params }: PageProps) {
const { language } = await params;
const { objectives } = await loadData();
await pageView('festival/wintersday/wizwards-vault');
await pageView('festival/wintersday/wizards-vault');

return (
<PageLayout>
Expand All @@ -43,7 +43,7 @@ export default async function WintersdayAchievementsPage({ params }: PageProps)
<p><Trans id="festival.wintersday.wizards-vault.description"/></p>

{objectives.length > 0 ? objectives.map((objective) => (
<WizardsVaultObjective key={objective.id} objective={objective} language={language}/>
<WizardsVaultObjective key={objective.id} objective={objective} language={language} disabledLoginNotification/>
)) : (
<Notice>No Wizard&apos;s Vault objectives for wintersday are available in the Guild Wars 2 API yet.</Notice>
)}
Expand Down
4 changes: 2 additions & 2 deletions apps/web/components/Gw2Api/Gw2Accounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const Gw2AccountsInternal: FC<Gw2AccountsProps> = ({ children, requiredScopes, o
}

if(!user) {
return (
return loginMessage === null ? null : (
<Gw2AccountLoginNotice requiredScopes={requiredScopes} optionalScopes={optionalScopes}>
{loginMessage ?? authorizationMessage}
</Gw2AccountLoginNotice>
Expand All @@ -51,7 +51,7 @@ const Gw2AccountsInternal: FC<Gw2AccountsProps> = ({ children, requiredScopes, o
}

if(requiredScopes.some((scope) => !accounts.scopes.includes(scope))) {
return (
return authorizationMessage === null ? null : (
<Gw2AccountAuthorizationNotice scopes={accounts.scopes} requiredScopes={requiredScopes} optionalScopes={optionalScopes}>
{authorizationMessage ?? loginMessage}
</Gw2AccountAuthorizationNotice>
Expand Down
7 changes: 4 additions & 3 deletions apps/web/components/WizardsVault/WizardsVaultObjective.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import { Waypoint } from '../Waypoint/Waypoint';

interface WizardsVaultObjectiveProps {
objective: Objective,
language: Language;
language: Language,
disabledLoginNotification?: boolean,
}

export const WizardsVaultObjective: FC<WizardsVaultObjectiveProps> = ({ objective, language }) => {
export const WizardsVaultObjective: FC<WizardsVaultObjectiveProps> = ({ objective, language, disabledLoginNotification }) => {
return (
<div className={styles.wrapper}>
<div className={styles.objective}>
Expand All @@ -22,7 +23,7 @@ export const WizardsVaultObjective: FC<WizardsVaultObjectiveProps> = ({ objectiv
<div className={styles.aa}><AstralAcclaim value={objective.acclaim}/></div>
</div>

<WizardsVaultObjectiveTable objectiveId={objective.id}/>
<WizardsVaultObjectiveTable objectiveId={objective.id} disabledLoginNotification={disabledLoginNotification}/>
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@ import { Gw2Accounts } from '../Gw2Api/Gw2Accounts';
import { SkeletonTable } from '../Skeleton/SkeletonTable';

interface WizardsVaultObjectiveTableProps {
objectiveId: number
objectiveId: number,
disabledLoginNotification?: boolean,
}

const requiredScopes = [Scope.GW2_Account, Scope.GW2_Progression];

export const WizardsVaultObjectiveTable: FC<WizardsVaultObjectiveTableProps> = ({ objectiveId }) => {
export const WizardsVaultObjectiveTable: FC<WizardsVaultObjectiveTableProps> = ({ objectiveId, disabledLoginNotification }) => {
return (
<Gw2Accounts
requiredScopes={requiredScopes}
loading={<SkeletonTable columns={['Account', 'Progress']} rows={1}/>}
authorizationMessage="gw2treasures.com needs additional permissions to display your Wizard's Vault progress."
loginMessage="Login to show your Wizard's Vault progress."
authorizationMessage={disabledLoginNotification ? null : 'gw2treasures.com needs additional permissions to display your Wizard\'s Vault progress.'}
loginMessage={disabledLoginNotification ? null : 'Login to show your Wizard\'s Vault progress.'}
>
{(accounts) => (
<Table>
Expand Down

0 comments on commit c20e943

Please sign in to comment.