Skip to content
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

don't duplicate persistent share links when importing #9219

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions webapp/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5387,9 +5387,18 @@ async function importGithubProject(repoid: string, requireSignin?: boolean) {

function loadHeaderBySharedId(id: string) {
core.showLoading("loadingheader", lf("loading project..."));
let previousHeader: pxt.workspace.Header;
if (id.startsWith("S") && auth.hasIdentity() && data.getData<string>(auth.LOGGED_IN)) {
// if loading a persistent url, check for existing headers
previousHeader = workspace.getHeaders().find(h => h.pubPermalink === id);
}

const projHeaderPromise = previousHeader
? Promise.resolve(previousHeader)
: workspace.installByIdAsync(id);

workspace.installByIdAsync(id)
.then(hd => theEditor.loadHeaderAsync(hd, null))
projHeaderPromise
.then(hd => theEditor.loadHeaderAsync(hd, null, !!previousHeader))
.catch(e => {
theEditor.openHome();
core.handleNetworkError(e);
Expand Down