瀏覽代碼

Revert "Removes unnecessary history.pushState if the welcome page is disabled and the user enter the base URL"

This reverts commit 3d5af92c7a.
j8
yanas 9 年之前
父節點
當前提交
968521ef7c
共有 1 個文件被更改,包括 26 次插入0 次删除
  1. 26
    0
      app.js

+ 26
- 0
app.js 查看文件

@@ -24,6 +24,24 @@ import API from './modules/API/API';
24 24
 
25 25
 import UIEvents from './service/UI/UIEvents';
26 26
 
27
+/**
28
+ * Tries to push history state with the following parameters:
29
+ * 'VideoChat', `Room: ${roomName}`, URL. If fail, prints the error and returns
30
+ * it.
31
+ */
32
+function pushHistoryState(roomName, URL) {
33
+    try {
34
+        window.history.pushState(
35
+            'VideoChat', `Room: ${roomName}`, URL
36
+        );
37
+    } catch (e) {
38
+        console.warn("Push history state failed with parameters:",
39
+            'VideoChat', `Room: ${roomName}`, URL, e);
40
+        return e;
41
+    }
42
+    return null;
43
+}
44
+
27 45
 /**
28 46
  * Builds and returns the room name.
29 47
  */
@@ -33,6 +51,14 @@ function buildRoomName () {
33 51
     if(!roomName) {
34 52
         let word = RoomnameGenerator.generateRoomWithoutSeparator();
35 53
         roomName = word.toLowerCase();
54
+        let historyURL = window.location.pathname + word;
55
+        //Trying to push state with URL "/" + roomName
56
+        var err = pushHistoryState(word, historyURL);
57
+        //If URL "/" + roomName is not good, trying with explicitly adding the
58
+        //domain name.
59
+        if(err && config.hosts.domain) {
60
+            pushHistoryState(word, "//" + config.hosts.domain + historyURL);
61
+        }
36 62
     }
37 63
 
38 64
     return roomName;

Loading…
取消
儲存