Skip to content

Commit

Permalink
Migration hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
kognise committed Mar 11, 2023
1 parent ce9c02e commit 40e6143
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/big-interactive-pages/migrate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { IoArrowForward, IoCheckmark } from 'react-icons/io5'
import Input from '../design-system/input'
import { getPuzzleLabFromLocalStorage } from '../../lib/game-saving/legacy-migration'
import { SessionInfo } from '../../lib/game-saving/account'
import { isValidEmail } from '../../lib/game-saving/email'

interface LegacyGame {
name: string
Expand Down Expand Up @@ -184,7 +185,7 @@ export default function Migrate({ session, intitialEmail }: MigrateProps) {
accent
icon={IoCheckmark}
class={styles.migrateButton}
disabled={migratingGames.value.length === 0}
disabled={migratingGames.value.length === 0 || (!session?.session.full && !isValidEmail(email.value))}
loading={state.value === 'loading'}
type='submit'
>
Expand Down
3 changes: 3 additions & 0 deletions src/lib/game-saving/legacy-migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { useEffect } from 'preact/hooks'
const helperUrl = 'https://editor.sprig.hackclub.com/migration-helper.html'

export const getPuzzleLabFromLocalStorage = (allowRedirect: boolean): Promise<string> => new Promise((resolve) => {
if (localStorage.getItem('puzzleLabHotfix') !== null)
return resolve(localStorage.getItem('puzzleLabHotfix')!)

const params = new URLSearchParams(window.location.search)
if (params.get('puzzleLab') !== null) {
// Remove the query param, it's cleaner for the user and means
Expand Down

0 comments on commit 40e6143

Please sign in to comment.