Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feat: Save state debug function.

damencho58b73d8dbd31
diff --git a/conference.js b/conference.js
index 1cd0755c5a..753ff41a80 100644
--- a/conference.js
+++ b/conference.js
@@ -1060,6 +1060,14 @@ export default {
downloadJSON(logs, filename);
},
+ /**
+ * Download app state, a function that can be called from console while debugging.
+ * @param filename (optional) specify target filename
+ */
+ saveState(filename = 'meet-state.json') {
+ downloadJSON(APP.store.getState(), filename);
+ },
+
/**
* Exposes a Command(s) API on this instance. It is necessitated by (1) the
* desire to keep room private to this instance and (2) the need of other
diff --git a/react/features/base/util/downloadJSON.web.ts b/react/features/base/util/downloadJSON.web.ts
index d85a101d97..7cb9fc5532 100644
--- a/react/features/base/util/downloadJSON.web.ts
+++ b/react/features/base/util/downloadJSON.web.ts
@@ -5,8 +5,22 @@
* @param {string} filename - The filename to give to the downloaded file.
* @returns {void}
*/
-export function downloadJSON(json: Object, filename: string) {
- const data = encodeURIComponent(JSON.stringify(json, null, ' '));
+export function downloadJSON(json: Object, filename: string): void {
+ const replacer = () => {
+ const seen = new WeakSet();
+
+ return (_: any, value: any) => {
+ if (typeof value === 'object' && value !== null) {
+ if (seen.has(value)) {
+ return '[circular ref]';
+ }
+ seen.add(value);
+ }
+
+ return value;
+ };
+ };
+ const data = encodeURIComponent(JSON.stringify(json, replacer(), ' '));
const elem = document.createElement('a');