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

kiosk: persist built game js in local storage #9726

Merged
merged 2 commits into from
Oct 18, 2023

Conversation

eanders-ms
Copy link
Contributor

No description provided.

@eanders-ms eanders-ms requested a review from a team October 17, 2023 23:24
@@ -14,6 +14,17 @@ function delValue(key: string) {
localStorage.removeItem(key);
}

function matchingKeys(pattern: RegExp): string[] {
const keys: string[] = [];
for (let i = 0; i < localStorage.length; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't clear to me what this function is used for, could you clarify?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function returns all local storage keys matching a regex pattern. It is called by the clearBuiltJsInfo method (later in this file) to get all the keys it should delete.

: "&sendBuilt=1";
return playUrlBase + playQueryParam;
const builtGame = Storage.getBuiltJsInfo(gameId);
return stringifyQueryString(configData.PlayUrlRoot, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I like this change! It makes it a lot clearer what the url is doing.

export {
getValue,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these no longer used anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to restrict the use of these calls to only this file, to ensure that new code would follow the pattern of adding bespoke apis for the specific fields being persisted. Exposing the low-level apis can lead to unnecessarily complicated code elsewhere.

@@ -70,3 +70,18 @@ export function nodeListToArray<U extends Node>(list: NodeListOf<U>): U[] {
}
return out;
}

// Copied from pxt.Utils, modified to skip undefined values.
export function stringifyQueryString(url: string, qs: any) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is more work and may not be needed, but I'm just wondering if there's benefit to defining a type for the object that is passed in for the query strings instead of just using any?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just copied this from pxt.Util in order to fix what seemed like a bug. Given that we use this function in so many places, I felt it too risky to fix it in place without causing a regression somewhere. The testing surface is quite large. The bug is that when undefined is passed as a param value, it gets written to the url as key=undefined. The correct behavior, in my view, is to not include that param on the url at all.

I'll file an issue to track it.

Copy link
Contributor

@srietkerk srietkerk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@eanders-ms eanders-ms merged commit cd04849 into master Oct 18, 2023
6 checks passed
@eanders-ms eanders-ms deleted the eanders-ms/kiosk-persist-built-games branch October 18, 2023 16:46
eanders-ms added a commit that referenced this pull request Oct 24, 2023
* kiosk: persist built game js in local storage

* better null check
eanders-ms added a commit that referenced this pull request Oct 24, 2023
* Add `--no-webapps` gulp option (#9622)

* Add `--no-webapps' gulp option

* Fix function declaration inconsistency

* docs

* Move kiosk project to pxt repo (#9624)

* Move kiosk to pxt repo

* sync latest kiosk changes from arcade repo

* Move kiosk config files to arcade docs

* kiosk updates

* update GameDataUrl

* comment missing icon resources

* disable eslint, for now

* fix code scan warning

* Include kiosk build in npm package contents (#9631)

* Sync kiosk changes (#9645)

* Restore absolute url on kiosk qr code (#9660)

* Add prettier to kiosk (#9667)

* kiosk: increase gamepad polling frequency (#9668)

* Kiosk navigation improvements (#9669)

* Navigation improvements

* add return types

* sound effect tweak

* Add switch sound to Adding Game screen

* New UI effects for Kiosk, authored in Arcade (#9671)

* New UI effects authored in Arcade

* Update readme

* Clarify readme

* Moving kiosk sfx to arcade repo (#9672)

* Remove unused components from kiosk (#9678)

* disable app insights correlation headers (#9679)

* load pxtlib into kiosk (#9680)

* Made a few small navigation improvements (#9686)

* Kiosk: Use pxt.tickEvent (#9687)

* Kiosk: Use pxt.tickEvent

* remove localhost special case

* Refactor kiosk state management (#9689)

* kiosk: refactor add game polling (#9691)

* kiosk: refactor add game polling

* show toast on game delete

* poll for games even while playing a game

* Kiosk: Remove direct dom manipulation (#9692)

* Remove direct dom manipulation

* tweak adding game css

* prettier

* Removed unneeded css attribute

* update readme

* Remove unwanted memo dependency

* Kiosk: Support event-based navigation (#9700)

* Kiosk: Support event-based navigation

* remove unused packages

* Add spacer to add game layout to keep it centered at wide resolutions

* Restore link border on scan qr page

* Shortened background transition time

* Better focus trapping. Fix tab nav on ScanQR page.

* pr feedback

* prettier

* lf all the strings (#9710)

* kiosk: support gamepad dpad for navigation (#9712)

* Identify kiosk uwp app in telemetry (#9714)

* kiosk: setup react-common dependency (#9717)

* react-common: support for button children (#9719)

* kiosk: use button control from react common (#9720)

* css fix for "press start" label on safari (#9722)

* kiosk: download targetconfig.json at startup (#9723)

* kiosk: download targetconfig.json at startup

* update cli crowdin thing

* Update cli/cli.ts

Co-authored-by: Joey Wunderlich <[email protected]>

---------

Co-authored-by: Joey Wunderlich <[email protected]>

* Add `--noauth` option to `pxt serve` (#9725)

* kiosk: persist built game js in local storage (#9726)

* kiosk: persist built game js in local storage

* better null check

* kiosk: fixes for carousel touch nav, storage exceptions (#9731)

Pushing this through in time for testing today.

* fixes for carousel touch nav, storage exceptions

* don't save compiled js in local storage.

* Log gamepad type to telemetry (#9739)

* support setting color of "loading" text in run.html (#9738)

* fix for shoebox controller (#9737)

* kiosk: remap esc to the controller's back button (#9735)

* kiosk: fix for skipped letters when entering high score (#9734)

* kiosk: fix for skipping letters when entering high score

* whitespace

* kiosk: store built js in indexeddb, not local storage (#9736)

* kiosk: map controller Y to escapebutton functionality (#9741)

---------

Co-authored-by: Joey Wunderlich <[email protected]>
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