Skip to content

Commit

Permalink
Try to restore target from URL before resorting to localStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
Gowee committed Mar 23, 2023
1 parent 5eea765 commit caf78fa
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ class App extends Component<Props, State> {

this.input = localStorage.getItem(`${PACKAGE.name}-code`) ?? this.input

let target = (
localStorage.getItem(`${PACKAGE.name}-target`) ?? window.location.hash.slice(1)
) as TargetType
if (!TARGET_OPTIONS.includes(target)) {
let targetCandidates = [window.location.hash.slice(1),
localStorage.getItem(`${PACKAGE.name}-target`)] as TargetType[]
let target = targetCandidates.find((t) => TARGET_OPTIONS.includes(t))
if (!target) {
target = TARGET_OPTIONS[0]
updateTargetInHash(target)
}
updateTargetInHash(target)

this.state = {
targetMenu: null,
Expand Down

0 comments on commit caf78fa

Please sign in to comment.