-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid svlete error from condition slot.
Error outlined here sveltejs/svelte#3165, and there is no fix, so I just avoided having a conditional slot, and just rerouted to an installMetaMask page instead.
- Loading branch information
1 parent
f247d43
commit 2c8ae61
Showing
2 changed files
with
14 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
<script lang="ts"> | ||
import { goto } from "$app/navigation"; | ||
import { onMount } from "svelte"; | ||
console.log("in layout") | ||
let mounted; | ||
let metamaskInstalled; | ||
onMount(async ()=>{ | ||
if (typeof window.ethereum !== 'undefined' && window.ethereum.isMetaMask) { | ||
metamaskInstalled = true | ||
import { page } from '$app/stores'; | ||
let path; | ||
page.subscribe((pg) => { | ||
path = pg.path | ||
}) | ||
onMount(()=>{ | ||
const installMetaMask = "/installMetaMask" | ||
if ((typeof window.ethereum === 'undefined' || !window.ethereum.isMetaMask) && path !== installMetaMask) { | ||
console.log(path, installMetaMask, path !== installMetaMask) | ||
goto(installMetaMask) | ||
} | ||
mounted = true | ||
}) | ||
</script> | ||
|
||
{#if mounted} | ||
{#if metamaskInstalled} | ||
<slot></slot> | ||
{:else} | ||
<a href="https://metamask.io/">Install MetaMask</a> | ||
{/if} | ||
{/if} | ||
<slot></slot> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<a href="https://metamask.io/">Install MetaMask</a> |