Skip to content

Commit

Permalink
Merge branch 'dragonflight' into chore/knip-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Pewtro authored Apr 12, 2024
2 parents ee93eca + a2464c6 commit a4caefe
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 48 deletions.
1 change: 1 addition & 0 deletions src/CHANGELOG.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import SpellLink from 'interface/SpellLink';
// prettier-ignore
export default [
change(date(2024, 4, 12), 'Clean up dead code using knip', Putro),
change(date(2024, 4, 12), 'Fix mana level chart', emallson),
change(date(2024, 4, 10), 'Update paths used by Sentry.', ToppleTheNun),
change(date(2024, 4, 10), 'Update dependencies.', ToppleTheNun),
change(date(2024, 4, 9), 'Swap to Vite instead of create-react-app and use the WCL V2 API.', [ToppleTheNun, emallson]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ class Mana extends PureComponent {

load() {
const { reportCode, start, end } = this.props;
fetchWcl(`report/tables/resources/${reportCode}`, {
fetchWcl(`report/graph/resources/${reportCode}`, {
start,
end,
sourceclass: 'Boss',
hostility: 1,
hostility: 'Enemies',
abilityid: 1000,
}).then((json) => {
this.setState({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import CastReasonBreakdownTableContents from 'interface/guide/components/CastRea

export { default } from './analyzer';

export function useThreatTable({
function useThreatTable({
reportCode,
fightStart,
fightEnd,
Expand Down
68 changes: 34 additions & 34 deletions src/interface/report/ConfigContext.tsx
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
import Config from 'parser/Config';
import { createContext, useContext, ReactNode } from 'react';
import type Config from 'parser/Config';
import { usePlayer } from 'interface/report/context/PlayerContext';
import { useReport } from 'interface/report/context/ReportContext';
import getConfig from 'parser/getConfig';
import { wclGameVersionToExpansion } from 'game/VERSIONS';

const ConfigContext = createContext<Config | undefined>(undefined);
export const useMaybeConfig = (): Config | undefined => {
// this mess of try/catch papers over some historical choices to throw for these contexts instead of allowing them to return undefined.
// that refactor is...big enough that i'm not doing it today
let report = undefined;
try {
const data = useReport();
report = data.report;
} catch {
/* do nothing */
}
let player = undefined;
let combatant = undefined;

export default ConfigContext;
try {
const playerData = usePlayer();
player = playerData.player;
combatant = playerData.combatant;
} catch {
/* do nothing */
}

export const useConfig = () => {
const ctx = useContext(ConfigContext);
if (ctx === undefined) {
throw new Error('Unable to get Config for selected report/player combination');
if (!report || !player || !combatant) {
return undefined;
}
return ctx;
return getConfig(
wclGameVersionToExpansion(report.gameVersion),
combatant.specID,
player,
combatant,
);
};

interface ConfigProviderProps {
children: ReactNode;
config: Config | undefined;
}
export const ConfigProvider = ({ children, config }: ConfigProviderProps) => (
<ConfigContext.Provider value={config}>{children}</ConfigContext.Provider>
);
export const useConfig = (): Config => {
const config = useMaybeConfig();
if (!config) {
throw new Error('Unable to get Config for selected report/player combination');
}

interface ReportPlayerConfigProviderProps {
children: ReactNode;
}
export const ReportPlayerConfigProvider = ({ children }: ReportPlayerConfigProviderProps) => {
const { combatant, player } = usePlayer();
const { report } = useReport();
return (
<ConfigProvider
config={getConfig(
wclGameVersionToExpansion(report.gameVersion),
combatant.specID,
player,
combatant,
)}
>
{children}
</ConfigProvider>
);
return config;
};
10 changes: 4 additions & 6 deletions src/interface/report/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import NavigationBar from 'interface/NavigationBar';
import { useCallback, useState } from 'react';

import BOSS_PHASES_STATE from './BOSS_PHASES_STATE';
import { ReportPlayerConfigProvider, useConfig } from './ConfigContext';
import { useConfig } from './ConfigContext';
import EVENT_PARSING_STATE from './EVENT_PARSING_STATE';
import { ReportExpansionContextProvider } from './ExpansionContext';
import FightSelection from './FightSelection';
Expand Down Expand Up @@ -214,11 +214,9 @@ const ReportLayout = () => (
<PatchChecker>
<FightSelection>
<PlayerLoader>
<ReportPlayerConfigProvider>
<SupportChecker>
<ResultsLoader />
</SupportChecker>
</ReportPlayerConfigProvider>
<SupportChecker>
<ResultsLoader />
</SupportChecker>
</PlayerLoader>
</FightSelection>
</PatchChecker>
Expand Down
4 changes: 2 additions & 2 deletions src/interface/useGoogleAnalytics.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useContext, useEffect } from 'react';
import ConfigContext from './report/ConfigContext';
import { useMaybeConfig } from './report/ConfigContext';
import FightCtx from './report/context/FightContext';

interface PageViewProperties {
Expand Down Expand Up @@ -27,7 +27,7 @@ declare global {
* to add extra tags to the page view event.
*/
export function usePageView(componentName: string, key?: unknown) {
const config = useContext(ConfigContext);
const config = useMaybeConfig();
const fight = useContext(FightCtx);
useEffect(() => {
const props = {
Expand Down
2 changes: 1 addition & 1 deletion src/parser/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AlertKind } from 'interface/Alert';
import CombatLogParser from 'parser/core/CombatLogParser';
import { ReactNode } from 'react';

import { Stats } from './shared/modules/StatTracker';
import type { Stats } from './shared/modules/StatTracker';

export type Build = {
url: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ class ManaLevelChartComponent extends PureComponent<Props, State> {

load() {
const { reportCode, start, end } = this.props;
fetchWcl(`report/tables/resources/${reportCode}`, {
fetchWcl(`report/graph/resources/${reportCode}`, {
start,
end,
sourceclass: 'Boss',
hostility: 1,
hostility: 'Enemies',
abilityid: 1000,
}).then((json) => {
this.setState({
Expand Down
1 change: 1 addition & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export default defineConfig((env) => ({
},
},
server: {
open: true,
port: 3000,
watch: {
ignored: ['**/.direnv/**'],
Expand Down

0 comments on commit a4caefe

Please sign in to comment.