Skip to content

Commit

Permalink
remove lag machine
Browse files Browse the repository at this point in the history
  • Loading branch information
alii committed Jan 11, 2025
1 parent 391701a commit ca7e23c
Showing 1 changed file with 3 additions and 36 deletions.
39 changes: 3 additions & 36 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,42 +40,6 @@ export const getStaticProps: GetStaticProps<Props> = async () => {
};

export default function Home(props: Props) {
useEffect(() => {
if (typeof window === 'undefined') {
return;
}

const getNextTime = () => {
return Math.floor(Math.random() * 1000);
};

const block = () => {
const now = performance.now();
const next = now + 50;

while (performance.now() < next) {
// Block the thread
}
};

let timer: ReturnType<typeof setTimeout> | null = null;

const lagMachine = () => {
timer = setTimeout(() => {
block();
lagMachine();
}, getNextTime());
};

lagMachine();

return () => {
if (timer) {
clearTimeout(timer);
}
};
}, []);

const lanyard = useLanyardWS(discordId, {
initialData: props.lanyard,
})!;
Expand All @@ -98,6 +62,9 @@ export default function Home(props: Props) {
const accessToken = parseAccessTokenFromURL(window.location.href);

if (accessToken) {
// Remove access token from the URL
history.pushState('', document.title, window.location.pathname + window.location.search);

const client = new SpotifyWebAPI();
client.setAccessToken(accessToken);

Expand Down

0 comments on commit ca7e23c

Please sign in to comment.