1
- import "./styles.js"
2
- import "phoenix_html"
3
- import { Socket , LongPoll } from "phoenix"
4
- import topbar from "topbar"
5
- import Hooks from "./_hooks"
6
- import { LiveSocket } from "phoenix_live_view"
7
- import { replaceIcons } from "./_hooks/BanchanWeb.Components.Icon.hooks"
8
-
9
- const csrfToken = document . querySelector ( "meta[name='csrf-token']" ) . getAttribute ( "content" )
10
- const orderSeed = document . querySelector ( "[data-order-seed]" ) ?. dataset . orderSeed
1
+ import "phoenix_html" ;
2
+ import { Socket , LongPoll } from "phoenix" ;
3
+ import topbar from "topbar" ;
4
+ import Hooks from "./_hooks" ;
5
+ import { LiveSocket } from "phoenix_live_view" ;
6
+ import { replaceIcons } from "./_hooks/BanchanWeb.Components.Icon.hooks" ;
7
+
8
+ const csrfToken = document . querySelector ( "meta[name='csrf-token']" ) . getAttribute ( "content" ) ;
9
+ const orderSeed = document . querySelector ( "[data-order-seed]" ) ?. dataset . orderSeed ;
11
10
const liveSocket = new LiveSocket ( '/live' , Socket , {
12
11
params : {
13
12
_csrf_token : csrfToken ,
14
13
order_seed : orderSeed == null ? null : parseInt ( orderSeed )
15
14
} ,
16
15
hooks : Hooks
17
- } )
16
+ } ) ;
18
17
19
18
// liveSocket.socket.onError((_error, transport, establishedConnections) => {
20
19
// liveSocket.socket.connect();
@@ -30,7 +29,7 @@ const liveSocket = new LiveSocket('/live', Socket, {
30
29
// things feel faster.
31
30
//
32
31
// See: https://fly.io/phoenix-files/make-your-liveview-feel-faster/#solution
33
- topbar . config ( { barColors : { 0 : "#29d" } , shadowColor : "rgba(0, 0, 0, .3)" } )
32
+ topbar . config ( { barColors : { 0 : "#29d" } , shadowColor : "rgba(0, 0, 0, .3)" } ) ;
34
33
35
34
let topBarScheduled = undefined ;
36
35
window . addEventListener ( "phx:page-loading-start" , ( ) => {
@@ -45,13 +44,15 @@ window.addEventListener("phx:page-loading-stop", () => {
45
44
} ) ;
46
45
47
46
// connect if there are any LiveViews on the page
48
- liveSocket . connect ( )
49
-
50
- replaceIcons ( ) ;
47
+ liveSocket . connect ( ) ;
51
48
52
49
// expose liveSocket on window for web console debug logs and latency simulation:
53
50
// >> liveSocket.enableDebug()
54
51
// >> liveSocket.enableLatencySim(1000) // enabled for duration of browser session
55
52
// >> liveSocket.disableLatencySim()
56
- window . liveSocket = liveSocket
53
+ window . liveSocket = liveSocket ;
54
+
55
+ replaceIcons ( ) ;
57
56
57
+ // We do this later because problems with this shouldn't crash the entire page.
58
+ import ( './styles.js' ) . then ( ( ) => { } , console . error ) ;
0 commit comments