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

Only download zips if you have file access #10257

Merged
merged 2 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 1 addition & 3 deletions pxtblocks/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,7 @@ export function flow(ws: Blockly.WorkspaceSvg, opts?: FlowOptions) {
}

export function screenshotEnabled(): boolean {
const disableForMacIos = pxt.appTarget.appTheme.disableFileAccessinMaciOs && (pxt.BrowserUtils.isMac() || pxt.BrowserUtils.isIOS());
const disableForAndriod = pxt.appTarget.appTheme.disableFileAccessinAndroid && pxt.BrowserUtils.isAndroid();
return !disableForMacIos && !pxt.BrowserUtils.isIE() && !disableForAndriod;
return pxt.BrowserUtils.hasFileAccess() && !pxt.BrowserUtils.isIE();
}

export function screenshotAsync(ws: Blockly.WorkspaceSvg, pixelDensity?: number, encodeBlocks?: boolean): Promise<string> {
Expand Down
11 changes: 11 additions & 0 deletions pxtlib/browserutils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,17 @@ namespace pxt.BrowserUtils {
return window?.innerWidth > pxt.BREAKPOINT_TABLET;
}

export function isInGame(): boolean {
const inGame = /inGame=1/i.exec(window.location.href);
return !!inGame;
}

export function hasFileAccess(): boolean {
const disableForMacIos = pxt.appTarget.appTheme.disableFileAccessinMaciOs && (pxt.BrowserUtils.isMac() || pxt.BrowserUtils.isIOS());
const disableForAndroid = pxt.appTarget.appTheme.disableFileAccessinAndroid && pxt.BrowserUtils.isAndroid();
return !disableForMacIos && !disableForAndroid;

}
export function noSharedLocalStorage(): boolean {
try {
return /nosharedlocalstorage/i.test(window.location.href);
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/scriptmanager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ export class ScriptManagerDialog extends data.Component<ScriptManagerDialogProps
this.setState({
download: null
});

}

handleDownloadProgressClose = () => {
Expand Down Expand Up @@ -529,7 +530,7 @@ export class ScriptManagerDialog extends data.Component<ScriptManagerDialogProps
}
headerActions.push(<sui.Button key="delete" icon="trash" className="icon red"
text={lf("Delete")} textClass="landscape only" title={lf("Delete Project")} onClick={this.handleDelete} />);
if (numSelected > 1) {
if (numSelected > 1 && pxt.BrowserUtils.hasFileAccess()) {
headerActions.push(<sui.Button key="download-zip" icon="download" className="icon"
text={lf("Download Zip")} textClass="landscape only" title={lf("Download Zip")} onClick={this.handleDownloadAsync} />);
}
Expand Down