Skip to content

🐛 [Story attachments] Fix attachment Firebase demos#37335

Merged
mszylkowski merged 9 commits intoampproject:mainfrom
mszylkowski:fixAttachmentDemos2
Jan 11, 2022
Merged

🐛 [Story attachments] Fix attachment Firebase demos#37335
mszylkowski merged 9 commits intoampproject:mainfrom
mszylkowski:fixAttachmentDemos2

Conversation

@mszylkowski
Copy link
Copy Markdown
Contributor

Allows the page-attachment and share-menus to be imported inline in the document on example stories so that the extensions load on Firebase.

There's a bug where extensionsFor.installExtensionForDoc doesn't point to the right URL for the extension on Firebase demos (it points to a URL with rtv, but it should point to the dist/ url).

Relies on upgradeCallback, which on the documentation says: "This method is called when the element is added to DOM for the first time and before buildCallback to give the element a chance to redirect its implementation to another BaseElement implementation. The returned value can be either null or undefined to indicate that no redirection will take place; BaseElement instance to upgrade immediately; or a promise to upgrade with the resolved BaseElement instance."

Alternatives

An alternative can be to directly change the upgradeCallback of page-attachment and share-menu to return a promise:

// amp-story-page-attachment.js

upgradeCallback() {
    const storyEl = closestAncestorBySelector("amp-story");
    return whenUpgradedToCustomElement(storyEl)
        .then(() => storyEl.getImpl())
        .then(() => null);
}

However, this requires all the different classes to have more repeated code.

Another alternative is to do #37331 but it's harder to follow the promise chains.

@amp-owners-bot
Copy link
Copy Markdown

Hey @gmajoulet, @newmuis! These files were changed:

extensions/amp-story-page-attachment/0.1/amp-story-page-attachment.js
extensions/amp-story-share-menu/0.1/amp-story-share-menu.js
extensions/amp-story/1.0/utils.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants