Skip to content

Commit

Permalink
Avoid svlete error from condition slot.
Browse files Browse the repository at this point in the history
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
BlakeMScurr committed Jul 6, 2021
1 parent f247d43 commit 2c8ae61
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/routes/__layout.svelte
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>
1 change: 1 addition & 0 deletions src/routes/installMetaMask.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<a href="https://metamask.io/">Install MetaMask</a>

0 comments on commit 2c8ae61

Please sign in to comment.