Skip to content

Commit 6619ee2

Browse files
committed
bump build
1 parent 74ba07a commit 6619ee2

File tree

6 files changed

+75
-9
lines changed

6 files changed

+75
-9
lines changed

priv/static/phoenix.cjs.js

Lines changed: 23 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

priv/static/phoenix.cjs.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

priv/static/phoenix.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,7 @@ var Phoenix = (() => {
10541054
this.channels = [];
10551055
this.sendBuffer = [];
10561056
this.ref = 0;
1057+
this.fallbackRef = null;
10571058
this.timeout = opts.timeout || DEFAULT_TIMEOUT;
10581059
this.transport = opts.transport || global.WebSocket || LongPoll;
10591060
this.primaryPassedHealthCheck = false;
@@ -1067,6 +1068,7 @@ var Phoenix = (() => {
10671068
this.disconnecting = false;
10681069
this.binaryType = opts.binaryType || "arraybuffer";
10691070
this.connectClock = 1;
1071+
this.pageHidden = false;
10701072
if (this.transport !== LongPoll) {
10711073
this.encode = opts.encode || this.defaultEncoder;
10721074
this.decode = opts.decode || this.defaultDecoder;
@@ -1088,6 +1090,16 @@ var Phoenix = (() => {
10881090
this.connect();
10891091
}
10901092
});
1093+
phxWindow.addEventListener("visibilitychange", () => {
1094+
if (document.visibilityState === "hidden") {
1095+
this.pageHidden = true;
1096+
} else {
1097+
this.pageHidden = false;
1098+
if (!this.isConnected()) {
1099+
this.teardown(() => this.connect());
1100+
}
1101+
}
1102+
});
10911103
}
10921104
this.heartbeatIntervalMs = opts.heartbeatIntervalMs || 3e4;
10931105
this.rejoinAfterMs = (tries) => {
@@ -1118,6 +1130,11 @@ var Phoenix = (() => {
11181130
this.heartbeatTimer = null;
11191131
this.pendingHeartbeatRef = null;
11201132
this.reconnectTimer = new Timer(() => {
1133+
if (this.pageHidden) {
1134+
this.log("Not reconnecting as page is hidden!");
1135+
this.teardown();
1136+
return;
1137+
}
11211138
this.teardown(() => this.connect());
11221139
}, this.reconnectAfterMs);
11231140
this.authToken = opts.authToken;
@@ -1337,7 +1354,10 @@ var Phoenix = (() => {
13371354
fallback(reason);
13381355
}
13391356
});
1340-
this.onOpen(() => {
1357+
if (this.fallbackRef) {
1358+
this.off([this.fallbackRef]);
1359+
}
1360+
this.fallbackRef = this.onOpen(() => {
13411361
established = true;
13421362
if (!primaryTransport) {
13431363
if (!this.primaryPassedHealthCheck) {
@@ -1445,6 +1465,8 @@ var Phoenix = (() => {
14451465
}, 150 * tries);
14461466
}
14471467
onConnClose(event) {
1468+
this.conn.onclose = () => {
1469+
};
14481470
let closeCode = event && event.code;
14491471
if (this.hasLogger()) this.log("transport", "close", event);
14501472
this.triggerChanError();

priv/static/phoenix.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

priv/static/phoenix.mjs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,7 @@ var Socket = class {
10251025
this.channels = [];
10261026
this.sendBuffer = [];
10271027
this.ref = 0;
1028+
this.fallbackRef = null;
10281029
this.timeout = opts.timeout || DEFAULT_TIMEOUT;
10291030
this.transport = opts.transport || global.WebSocket || LongPoll;
10301031
this.primaryPassedHealthCheck = false;
@@ -1038,6 +1039,7 @@ var Socket = class {
10381039
this.disconnecting = false;
10391040
this.binaryType = opts.binaryType || "arraybuffer";
10401041
this.connectClock = 1;
1042+
this.pageHidden = false;
10411043
if (this.transport !== LongPoll) {
10421044
this.encode = opts.encode || this.defaultEncoder;
10431045
this.decode = opts.decode || this.defaultDecoder;
@@ -1059,6 +1061,16 @@ var Socket = class {
10591061
this.connect();
10601062
}
10611063
});
1064+
phxWindow.addEventListener("visibilitychange", () => {
1065+
if (document.visibilityState === "hidden") {
1066+
this.pageHidden = true;
1067+
} else {
1068+
this.pageHidden = false;
1069+
if (!this.isConnected()) {
1070+
this.teardown(() => this.connect());
1071+
}
1072+
}
1073+
});
10621074
}
10631075
this.heartbeatIntervalMs = opts.heartbeatIntervalMs || 3e4;
10641076
this.rejoinAfterMs = (tries) => {
@@ -1089,6 +1101,11 @@ var Socket = class {
10891101
this.heartbeatTimer = null;
10901102
this.pendingHeartbeatRef = null;
10911103
this.reconnectTimer = new Timer(() => {
1104+
if (this.pageHidden) {
1105+
this.log("Not reconnecting as page is hidden!");
1106+
this.teardown();
1107+
return;
1108+
}
10921109
this.teardown(() => this.connect());
10931110
}, this.reconnectAfterMs);
10941111
this.authToken = opts.authToken;
@@ -1308,7 +1325,10 @@ var Socket = class {
13081325
fallback(reason);
13091326
}
13101327
});
1311-
this.onOpen(() => {
1328+
if (this.fallbackRef) {
1329+
this.off([this.fallbackRef]);
1330+
}
1331+
this.fallbackRef = this.onOpen(() => {
13121332
established = true;
13131333
if (!primaryTransport) {
13141334
if (!this.primaryPassedHealthCheck) {
@@ -1416,6 +1436,8 @@ var Socket = class {
14161436
}, 150 * tries);
14171437
}
14181438
onConnClose(event) {
1439+
this.conn.onclose = () => {
1440+
};
14191441
let closeCode = event && event.code;
14201442
if (this.hasLogger()) this.log("transport", "close", event);
14211443
this.triggerChanError();

priv/static/phoenix.mjs.map

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)