File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { assert } from "@ember/debug" ;
12import { trackedObject } from "@ember/reactive/collections" ;
23
4+ const HasQuery = new Set < string > ( ) ;
35const MediaQueries : Record < string , boolean > = trackedObject ( { } ) ;
46function addMediaQueryListener ( query : string ) : boolean {
7+ assert ( `matchMedia query must be a non-empty string` , typeof query === 'string' && query . length > 0 ) ;
58 // Initialize on first access
6- if ( MediaQueries [ query ] === undefined ) {
9+ if ( ! HasQuery . has ( query ) ) {
10+ HasQuery . add ( query ) ;
711 const mediaQueryList = window . matchMedia ( query ) ;
812 MediaQueries [ query ] = mediaQueryList . matches ;
913
@@ -15,8 +19,10 @@ function addMediaQueryListener(query: string): boolean {
1519 mediaQueryList . addEventListener ( 'change' , listener ) ;
1620 return mediaQueryList . matches ;
1721 }
18- return MediaQueries [ query ] ;
22+
23+ return MediaQueries [ query ] ! ;
1924}
25+
2026/**
2127 * Decorator which marks a field as being populated via `window.matchMedia`.
2228 *
Original file line number Diff line number Diff line change @@ -23,6 +23,21 @@ class SiteTheme {
2323 @matchMedia ( '(prefers-color-scheme: dark)' )
2424 systemPrefersDarkMode : boolean = false ;
2525
26+ @matchMedia ( '(display-mode: minimal-ui)' )
27+ isMinimalUI : boolean = false ;
28+
29+ @matchMedia ( '(display-mode: standalone)' )
30+ isStandalone : boolean = false ;
31+
32+ @matchMedia ( '(display-mode: fullscreen)' )
33+ isFullscreen : boolean = false ;
34+
35+ isIOSStandalone : boolean = Boolean ( 'standalone' in navigator && navigator . standalone ) ;
36+
37+ get isRunningAsInstalledApp ( ) : boolean {
38+ return this . isIOSStandalone || this . isMinimalUI || this . isStandalone ;
39+ }
40+
2641 get isDarkMode ( ) : boolean {
2742 if ( this . explicitThemePreference === 'dark' ) {
2843 return true ;
Original file line number Diff line number Diff line change 1+ import Service , { service } from '@ember/service' ;
2+ import type RouterService from '@ember/routing/router-service' ;
3+ import { field , PersistedResource } from '#app/core/persisted-resource.ts' ;
4+ import { getTheme } from '#app/core/site-theme.ts' ;
5+
6+ @PersistedResource ( 'route-history' )
7+ class HistoryService extends Service {
8+ @service declare router : RouterService ;
9+
10+ @field
11+ latestRoute : string | null = null ;
12+
13+ track ( ) {
14+ if ( getTheme ( ) . isRunningAsInstalledApp ) {
15+ if ( this . latestRoute ) {
16+ // Navigate to the last route
17+ this . router . replaceWith ( this . latestRoute ) ;
18+ }
19+ }
20+
21+ // Listen to Ember's route changes and read from window
22+ this . router . on ( 'routeDidChange' , ( ) => {
23+ // store the url minus the hostname
24+ const url = location . pathname + location . search + location . hash ;
25+ this . latestRoute = url ;
26+ } ) ;
27+ }
28+ }
29+
30+ export default HistoryService ;
Original file line number Diff line number Diff line change @@ -3,11 +3,19 @@ import Component from '@glimmer/component';
33import { checkServiceWorker } from ' #app/core/preferences.ts' ;
44import { service } from ' @ember/service' ;
55import type PortalsService from ' #app/services/ux/portals.ts' ;
6+ import type HistoryService from ' #app/services/history.ts' ;
7+ import type Owner from ' @ember/owner' ;
68
79void checkServiceWorker ();
810
911export default class Application extends Component {
1012 @service (' ux/portals' ) portals! : PortalsService ;
13+ @service history! : HistoryService ;
14+
15+ constructor (owner : Owner , args : object ) {
16+ super (owner , args );
17+ this .history .track ();
18+ }
1119
1220 <template >
1321 {{this .portals.takeover }}
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ export default defineConfig({
4444 description : 'Find Your Trail Friends! The Bandits are a Trail Running Community based in the SF Bay Area.' ,
4545 theme_color : '#000000' ,
4646 background_color : '#000000' ,
47- display : 'standalone ' ,
47+ display : 'minimal-ui ' ,
4848 start_url : '/' ,
4949 icons : [
5050 {
You can’t perform that action at this time.
0 commit comments