-
Notifications
You must be signed in to change notification settings - Fork 2
Conversation
Cloud11PL
commented
Apr 12, 2022
•
edited
Loading
edited
- Exposes app ID in state (that is passed as a query param) - used by https://github.com/saleor/saleor-app-marketplace/pull/19
size-limit report 📦
|
aaf241e
to
52db21a
Compare
52db21a
to
b713fa6
Compare
e018fd8
to
42a2617
Compare
7ec8458
to
d4c0483
Compare
src/index.ts
Outdated
@@ -12,7 +12,9 @@ export function createApp(targetDomain?: string) { | |||
domain = url.searchParams.get("domain") || ""; | |||
} | |||
|
|||
app.setState({ domain }); | |||
id = new URL(domain).searchParams.get("id") ?? ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick but it's not changed anywhere
id = new URL(domain).searchParams.get("id") ?? ""; | |
const id = new URL(domain).searchParams.get("id") ?? ""; |
import createApp from "."; | ||
import { AppBridgeState } from "./app"; | ||
|
||
export type App = ReturnType<typeof createApp>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a fan of this, explicitly typing return type by function createApp(): Type
is making breaking api harder. Now it's possible to change function signature and no one will know until consumers start complaining about breaking changes.
@@ -10,7 +10,7 @@ Object.defineProperty(window.document, "referrer", { | |||
import { actions, DispatchResponseEvent, createApp } from "../src"; | |||
|
|||
describe("createApp", () => { | |||
const domain = "test-domain"; | |||
const domain = "http://test-domain.com/?id=appid"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in dashboard we have shop.domain.host
passed here, isn't that just a domain (without schema)? also as you pass src={urlJoin(src, `?domain=${shop.domain.host}&id=${appId}`)}
in dashboard, should that be test-domain.com&id=appid
here?
@@ -12,7 +12,9 @@ export function createApp(targetDomain?: string) { | |||
domain = url.searchParams.get("domain") || ""; | |||
} | |||
|
|||
app.setState({ domain }); | |||
const id = new URL(domain).searchParams.get("id") ?? ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of that should we have id = url.searchParams.get("id")
in else
clause above?