Skip to content

Extension breaks on single file components with commented out script tag #623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
terales opened this issue Jul 14, 2021 · 0 comments
Closed
Labels
bug Something isn't working sp:8

Comments

@terales
Copy link
Collaborator

terales commented Jul 14, 2021

From #621 (comment)

This file breaks with Unexpected token (1:3)
I think caused by the comments <!-- <script su-router:imports:sync> -->

<!-- <script su-router:imports:sync> -->
<script>
  import { onMount } from "svelte";
  import { link, useRouter, useGuard, exists } from "@svelteuse/router";
  import { msalInstance } from "../logic/auth.js";

  // "google",
  // "google-cn",
  // "deepl",
  // "libretranslate"

  let accounts = msalInstance.getAllAccounts();
  console.log("acc", accounts);
  const guardCheck = useGuard(
    { link: "or", redirect: "/login" },
    exists(accounts[0])
  );
  if (!guardCheck) {
    $useRouter.navigate("/login");
    window.location.reload();
  }

  console.log("isAllowed", guardCheck);

  onMount(() => {
    console.log("onMount Default LAYOUT");
    async function init() {
      console.log("init");
      // // await msalInstance.handleRedirectPromise();
      // let accounts = msalInstance.getAllAccounts();
      // console.log("acc", accounts);
      // const guardCheck = useGuard({ link: "or" }, exists(accounts[0]));
      // if (!guardCheck) {
      //   $useRouter.navigate("/login");
      //   window.location.reload();
      // }
      // console.log("isAllowed", guardCheck);
    }
    init();
  });

  // async function handle365Login(event) {
  //   console.log("LOGIN EVENT");

  //   msalInstance
  //     .loginRedirect()
  //     .then((res) => {
  //       console.log(res);
  //     })
  //     .catch((e) => {
  //       console.error(e);
  //     });
  // }

  async function handle365Logout() {
    console.log("LOGOUT EVENT");
    await msalInstance.logoutRedirect();
    window.location.reload();
  }
</script>

<div class="min-h-100vh flex flex-col">
  <header class="flex flex-row place-content-center p-4">
    <div class="flex flex-row gap-2">
      <a href="/farmer1" use:link><f-button>Fendt Farmer 1</f-button></a>
      <a href="/news" use:link><f-button>Neuigkeiten</f-button></a>
      <!-- <f-button on:click={(e) => handle365Login(e)}>LOGIN</f-button> -->
      <f-button on:click={(e) => handle365Logout(e)}>Ausloggen</f-button>
    </div>
  </header>

  <main class="flex-grow grid place-content-center">
    <slot />
  </main>

  <footer class="flex flex-row place-content-center p-6">
    <div class="flex flex-col items-center gap-2">
      <span> REPGUIDE © 2021 </span>
      <div class="flex flex-row gap-2">
        <a href="/">Impressum</a><a href="/">DATENSCHUTZ</a><a href="/">AGB</a>
      </div>
    </div>
  </footer>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working sp:8
Development

No branches or pull requests

2 participants