From 01a7a6987ec708b75152fb0d0ca26e24d51528b5 Mon Sep 17 00:00:00 2001
From: Travis Ralston
Date: Wed, 15 Jan 2020 23:22:31 -0700
Subject: [PATCH 1/9] Add a rageshake function to download the logs locally
For https://github.com/vector-im/riot-web/issues/3304
This generates something similar to what the rageshake server does, just in an easy package for people to use. tar-js was chosen over zip or anything else because it's small, simple, and stable.
Note: this doesn't work in Chrome, but firefox seems to be okay with it. Chrome appears to be blocking the download for some reason - the very first download was fine, but none afterwards
---
package.json | 1 +
src/i18n/strings/en_EN.json | 1 +
src/rageshake/submit-rageshake.js | 108 ++++++++++++++++++++++++------
yarn.lock | 5 ++
4 files changed, 95 insertions(+), 20 deletions(-)
diff --git a/package.json b/package.json
index 16e7f943f1..b6ec44ebd0 100644
--- a/package.json
+++ b/package.json
@@ -97,6 +97,7 @@
"react-gemini-scrollbar": "github:matrix-org/react-gemini-scrollbar#9cf17f63b7c0b0ec5f31df27da0f82f7238dc594",
"resize-observer-polyfill": "^1.5.0",
"sanitize-html": "^1.18.4",
+ "tar-js": "^0.3.0",
"text-encoding-utf-8": "^1.0.1",
"url": "^0.11.0",
"velocity-animate": "^1.5.2",
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json
index 42c87172b8..9b08e41a8c 100644
--- a/src/i18n/strings/en_EN.json
+++ b/src/i18n/strings/en_EN.json
@@ -418,6 +418,7 @@
"Collecting app version information": "Collecting app version information",
"Collecting logs": "Collecting logs",
"Uploading report": "Uploading report",
+ "Downloading report": "Downloading report",
"Waiting for response from server": "Waiting for response from server",
"Messages containing my display name": "Messages containing my display name",
"Messages containing my username": "Messages containing my username",
diff --git a/src/rageshake/submit-rageshake.js b/src/rageshake/submit-rageshake.js
index ed5a9e5946..1d765dd273 100644
--- a/src/rageshake/submit-rageshake.js
+++ b/src/rageshake/submit-rageshake.js
@@ -21,6 +21,7 @@ import pako from 'pako';
import {MatrixClientPeg} from '../MatrixClientPeg';
import PlatformPeg from '../PlatformPeg';
import { _t } from '../languageHandler';
+import Tar from "tar-js";
import * as rageshake from './rageshake';
@@ -33,26 +34,7 @@ if (!TextEncoder) {
TextEncoder = TextEncodingUtf8.TextEncoder;
}
-/**
- * Send a bug report.
- *
- * @param {string} bugReportEndpoint HTTP url to send the report to
- *
- * @param {object} opts optional dictionary of options
- *
- * @param {string} opts.userText Any additional user input.
- *
- * @param {boolean} opts.sendLogs True to send logs
- *
- * @param {function(string)} opts.progressCallback Callback to call with progress updates
- *
- * @return {Promise} Resolved when the bug report is sent.
- */
-export default async function sendBugReport(bugReportEndpoint, opts) {
- if (!bugReportEndpoint) {
- throw new Error("No bug report endpoint has been set.");
- }
-
+async function collectBugReport(opts) {
opts = opts || {};
const progressCallback = opts.progressCallback || (() => {});
@@ -106,10 +88,96 @@ export default async function sendBugReport(bugReportEndpoint, opts) {
}
}
+ return body;
+}
+
+/**
+ * Send a bug report.
+ *
+ * @param {string} bugReportEndpoint HTTP url to send the report to
+ *
+ * @param {object} opts optional dictionary of options
+ *
+ * @param {string} opts.userText Any additional user input.
+ *
+ * @param {boolean} opts.sendLogs True to send logs
+ *
+ * @param {function(string)} opts.progressCallback Callback to call with progress updates
+ *
+ * @return {Promise} Resolved when the bug report is sent.
+ */
+export default async function sendBugReport(bugReportEndpoint, opts) {
+ if (!bugReportEndpoint) {
+ throw new Error("No bug report endpoint has been set.");
+ }
+
+ opts = opts || {};
+ const progressCallback = opts.progressCallback || (() => {});
+ const body = await collectBugReport(opts);
+
progressCallback(_t("Uploading report"));
await _submitReport(bugReportEndpoint, body, progressCallback);
}
+/**
+ * Downloads the files from a bug report. This is the same as sendBugReport,
+ * but instead causes the browser to download the files locally.
+ *
+ * @param {object} opts optional dictionary of options
+ *
+ * @param {string} opts.userText Any additional user input.
+ *
+ * @param {boolean} opts.sendLogs True to send logs
+ *
+ * @param {function(string)} opts.progressCallback Callback to call with progress updates
+ *
+ * @return {Promise} Resolved when the bug report is downloaded (or started).
+ */
+export async function downloadBugReport(opts) {
+ opts = opts || {};
+ const progressCallback = opts.progressCallback || (() => {});
+ const body = await collectBugReport(opts);
+
+ progressCallback(_t("Downloading report"));
+ let metadata = "";
+ const tape = new Tar();
+ let i = 0;
+ for (const e of body.entries()) {
+ if (e[0] === 'compressed-log') {
+ await new Promise((resolve => {
+ const reader = new FileReader();
+ reader.addEventListener('loadend', ev => {
+ tape.append(`log-${i++}.log`, pako.ungzip(ev.target.result));
+ resolve();
+ });
+ reader.readAsArrayBuffer(e[1]);
+ }))
+ } else {
+ metadata += `${e[0]} = ${e[1]}\n`;
+ }
+ }
+ tape.append('issue.txt', metadata);
+
+ // We have to create a new anchor to download if we want a filename. Otherwise we could
+ // just use window.open.
+ const dl = document.createElement('a');
+ dl.href = `data:application/octet-stream;base64,${btoa(uint8ToString(tape.out))}`;
+ dl.download = 'rageshake.tar';
+ document.body.appendChild(dl);
+ dl.click();
+ document.body.removeChild(dl);
+}
+
+// Source: https://github.com/beatgammit/tar-js/blob/master/examples/main.js
+function uint8ToString(buf) {
+ let i, length, out = '';
+ for (i = 0, length = buf.length; i < length; i += 1) {
+ out += String.fromCharCode(buf[i]);
+ }
+
+ return out;
+}
+
function _submitReport(endpoint, body, progressCallback) {
return new Promise((resolve, reject) => {
const req = new XMLHttpRequest();
diff --git a/yarn.lock b/yarn.lock
index d2135f7aa6..18bbf44f4d 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -8251,6 +8251,11 @@ tapable@^1.0.0, tapable@^1.1.3:
resolved "https://registry.yarnpkg.com/tapable/-/tapable-1.1.3.tgz#a1fccc06b58db61fd7a45da2da44f5f3a3e67ba2"
integrity sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==
+tar-js@^0.3.0:
+ version "0.3.0"
+ resolved "https://registry.yarnpkg.com/tar-js/-/tar-js-0.3.0.tgz#6949aabfb0ba18bb1562ae51a439fd0f30183a17"
+ integrity sha1-aUmqv7C6GLsVYq5RpDn9DzAYOhc=
+
tar@^4:
version "4.4.13"
resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.13.tgz#43b364bc52888d555298637b10d60790254ab525"
From 63853d9de19fc45f8253fb41c465f8924c19008b Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Mon, 30 Mar 2020 16:12:28 +0100
Subject: [PATCH 2/9] Add download logs button to BugReportDialog
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
.../views/dialogs/BugReportDialog.js | 34 ++++++++++++++++++-
src/i18n/strings/en_EN.json | 2 ++
src/rageshake/submit-rageshake.js | 2 +-
yarn.lock | 5 +++
4 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/src/components/views/dialogs/BugReportDialog.js b/src/components/views/dialogs/BugReportDialog.js
index 6e337d53dc..0916e680e0 100644
--- a/src/components/views/dialogs/BugReportDialog.js
+++ b/src/components/views/dialogs/BugReportDialog.js
@@ -23,7 +23,8 @@ import * as sdk from '../../../index';
import SdkConfig from '../../../SdkConfig';
import Modal from '../../../Modal';
import { _t } from '../../../languageHandler';
-import sendBugReport from '../../../rageshake/submit-rageshake';
+import sendBugReport, {downloadBugReport} from '../../../rageshake/submit-rageshake';
+import AccessibleButton from "../elements/AccessibleButton";
export default class BugReportDialog extends React.Component {
constructor(props) {
@@ -95,6 +96,32 @@ export default class BugReportDialog extends React.Component {
});
}
+ _onDownload = async (ev) => {
+ this.setState({ busy: true, progress: null, err: null });
+ this._sendProgressCallback(_t("Preparing to download logs"));
+
+ try {
+ await downloadBugReport({
+ sendLogs: true,
+ progressCallback: this._sendProgressCallback,
+ label: this.props.label,
+ });
+
+ this.setState({
+ busy: false,
+ progress: null,
+ });
+ } catch (err) {
+ if (!this._unmounted) {
+ this.setState({
+ busy: false,
+ progress: null,
+ err: _t("Failed to send logs: ") + `${err.message}`,
+ });
+ }
+ }
+ };
+
_onTextChange(ev) {
this.setState({ text: ev.target.value });
}
@@ -165,6 +192,11 @@ export default class BugReportDialog extends React.Component {
},
) }
+
+
+ { _t("Click here to download your logs.") }
+
+
create a GitHub issue to describe your problem.": "Before submitting logs, you must create a GitHub issue to describe your problem.",
+ "Click here to download your logs.": "Click here to download your logs.",
"GitHub issue": "GitHub issue",
"Notes": "Notes",
"If there is additional context that would help in analysing the issue, such as what you were doing at the time, room IDs, user IDs, etc., please include those things here.": "If there is additional context that would help in analysing the issue, such as what you were doing at the time, room IDs, user IDs, etc., please include those things here.",
diff --git a/src/rageshake/submit-rageshake.js b/src/rageshake/submit-rageshake.js
index 1500130ffd..3e83cafbcd 100644
--- a/src/rageshake/submit-rageshake.js
+++ b/src/rageshake/submit-rageshake.js
@@ -195,7 +195,7 @@ export async function downloadBugReport(opts) {
resolve();
});
reader.readAsArrayBuffer(e[1]);
- }))
+ }));
} else {
metadata += `${e[0]} = ${e[1]}\n`;
}
diff --git a/yarn.lock b/yarn.lock
index c5fc8268a1..6451879a5b 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -8189,6 +8189,11 @@ tapable@^1.0.0, tapable@^1.1.3:
resolved "https://registry.yarnpkg.com/tapable/-/tapable-1.1.3.tgz#a1fccc06b58db61fd7a45da2da44f5f3a3e67ba2"
integrity sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==
+tar-js@^0.3.0:
+ version "0.3.0"
+ resolved "https://registry.yarnpkg.com/tar-js/-/tar-js-0.3.0.tgz#6949aabfb0ba18bb1562ae51a439fd0f30183a17"
+ integrity sha1-aUmqv7C6GLsVYq5RpDn9DzAYOhc=
+
terser-webpack-plugin@^1.4.3:
version "1.4.3"
resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-1.4.3.tgz#5ecaf2dbdc5fb99745fd06791f46fc9ddb1c9a7c"
From c4fc70b9be5c0d0276fa948f560c3d4034bd1f1e Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Tue, 21 Jul 2020 22:28:36 +0100
Subject: [PATCH 3/9] Post-merge fix
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
package.json | 1 +
src/i18n/strings/en_EN.json | 3 +++
src/rageshake/submit-rageshake.ts | 13 ++++++-------
yarn.lock | 5 +++++
4 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/package.json b/package.json
index 4b9d612444..c4b4b3cb07 100644
--- a/package.json
+++ b/package.json
@@ -126,6 +126,7 @@
"@types/lodash": "^4.14.152",
"@types/modernizr": "^3.5.3",
"@types/node": "^12.12.41",
+ "@types/pako": "^1.0.1",
"@types/qrcode": "^1.3.4",
"@types/react": "^16.9",
"@types/react-dom": "^16.9.8",
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json
index 1b508feb19..442de94f77 100644
--- a/src/i18n/strings/en_EN.json
+++ b/src/i18n/strings/en_EN.json
@@ -543,6 +543,7 @@
"Collecting app version information": "Collecting app version information",
"Collecting logs": "Collecting logs",
"Uploading report": "Uploading report",
+ "Downloading report": "Downloading report",
"Waiting for response from server": "Waiting for response from server",
"Messages containing my display name": "Messages containing my display name",
"Messages containing my username": "Messages containing my username",
@@ -1615,9 +1616,11 @@
"Please tell us what went wrong or, better, create a GitHub issue that describes the problem.": "Please tell us what went wrong or, better, create a GitHub issue that describes the problem.",
"Preparing to send logs": "Preparing to send logs",
"Failed to send logs: ": "Failed to send logs: ",
+ "Preparing to download logs": "Preparing to download logs",
"Reminder: Your browser is unsupported, so your experience may be unpredictable.": "Reminder: Your browser is unsupported, so your experience may be unpredictable.",
"Debug logs contain application usage data including your username, the IDs or aliases of the rooms or groups you have visited and the usernames of other users. They do not contain messages.": "Debug logs contain application usage data including your username, the IDs or aliases of the rooms or groups you have visited and the usernames of other users. They do not contain messages.",
"Before submitting logs, you must create a GitHub issue to describe your problem.": "Before submitting logs, you must create a GitHub issue to describe your problem.",
+ "Click here to download your logs.": "Click here to download your logs.",
"GitHub issue": "GitHub issue",
"Notes": "Notes",
"If there is additional context that would help in analysing the issue, such as what you were doing at the time, room IDs, user IDs, etc., please include those things here.": "If there is additional context that would help in analysing the issue, such as what you were doing at the time, room IDs, user IDs, etc., please include those things here.",
diff --git a/src/rageshake/submit-rageshake.ts b/src/rageshake/submit-rageshake.ts
index 697b0dfc45..7d5bd535d2 100644
--- a/src/rageshake/submit-rageshake.ts
+++ b/src/rageshake/submit-rageshake.ts
@@ -25,7 +25,6 @@ import Tar from "tar-js";
import * as rageshake from './rageshake';
-
// polyfill textencoder if necessary
import * as TextEncodingUtf8 from 'text-encoding-utf-8';
import SettingsStore from "../settings/SettingsStore";
@@ -41,7 +40,7 @@ interface IOpts {
progressCallback?: (string) => void;
}
-async function collectBugReport(opts) {
+async function collectBugReport(opts: IOpts) {
opts = opts || {};
const progressCallback = opts.progressCallback || (() => {});
@@ -230,18 +229,18 @@ export async function downloadBugReport(opts) {
let metadata = "";
const tape = new Tar();
let i = 0;
- for (const e of body.entries()) {
- if (e[0] === 'compressed-log') {
+ for (const [key, value] of body.entries()) {
+ if (key === 'compressed-log') {
await new Promise((resolve => {
const reader = new FileReader();
reader.addEventListener('loadend', ev => {
tape.append(`log-${i++}.log`, pako.ungzip(ev.target.result));
resolve();
});
- reader.readAsArrayBuffer(e[1]);
+ reader.readAsArrayBuffer(value as Blob);
}));
} else {
- metadata += `${e[0]} = ${e[1]}\n`;
+ metadata += `${key} = ${value}\n`;
}
}
tape.append('issue.txt', metadata);
@@ -257,7 +256,7 @@ export async function downloadBugReport(opts) {
}
// Source: https://github.com/beatgammit/tar-js/blob/master/examples/main.js
-function uint8ToString(buf) {
+function uint8ToString(buf: Buffer) {
let i, length, out = '';
for (i = 0, length = buf.length; i < length; i += 1) {
out += String.fromCharCode(buf[i]);
diff --git a/yarn.lock b/yarn.lock
index 9f7188f276..5987cb6dfb 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1362,6 +1362,11 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.12.44.tgz#0d400a1453adcb359b133acceae4dd8bb0e0a159"
integrity sha512-jM6QVv0Sm5d3nW+nUD5jSzPcO6oPqboitSNcwgBay9hifVq/Rauq1PYnROnsmuw45JMBiTnsPAno0bKu2e2xrg==
+"@types/pako@^1.0.1":
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/@types/pako/-/pako-1.0.1.tgz#33b237f3c9aff44d0f82fe63acffa4a365ef4a61"
+ integrity sha512-GdZbRSJ3Cv5fiwT6I0SQ3ckeN2PWNqxd26W9Z2fCK1tGrrasGy4puvNFtnddqH9UJFMQYXxEuuB7B8UK+LLwSg==
+
"@types/prop-types@*":
version "15.7.3"
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.3.tgz#2ab0d5da2e5815f94b0b9d4b95d1e5f243ab2ca7"
From fd869b20fa6e4674d53361b3eeff9d78970376cc Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Tue, 21 Jul 2020 22:33:01 +0100
Subject: [PATCH 4/9] type coerce
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
src/rageshake/submit-rageshake.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rageshake/submit-rageshake.ts b/src/rageshake/submit-rageshake.ts
index 7d5bd535d2..2762c21dff 100644
--- a/src/rageshake/submit-rageshake.ts
+++ b/src/rageshake/submit-rageshake.ts
@@ -234,7 +234,7 @@ export async function downloadBugReport(opts) {
await new Promise((resolve => {
const reader = new FileReader();
reader.addEventListener('loadend', ev => {
- tape.append(`log-${i++}.log`, pako.ungzip(ev.target.result));
+ tape.append(`log-${i++}.log`, pako.ungzip(ev.target.result as string));
resolve();
});
reader.readAsArrayBuffer(value as Blob);
From a0e7efd7d5ca20e5ba6b904aa6fa19b3aedc2424 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Tue, 21 Jul 2020 22:50:39 +0100
Subject: [PATCH 5/9] delint
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
src/rageshake/submit-rageshake.ts | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/rageshake/submit-rageshake.ts b/src/rageshake/submit-rageshake.ts
index 2762c21dff..6e49149621 100644
--- a/src/rageshake/submit-rageshake.ts
+++ b/src/rageshake/submit-rageshake.ts
@@ -257,11 +257,10 @@ export async function downloadBugReport(opts) {
// Source: https://github.com/beatgammit/tar-js/blob/master/examples/main.js
function uint8ToString(buf: Buffer) {
- let i, length, out = '';
- for (i = 0, length = buf.length; i < length; i += 1) {
+ let out = '';
+ for (let i = 0; i < buf.length; i += 1) {
out += String.fromCharCode(buf[i]);
}
-
return out;
}
From 0a700bc8e438722fe117e05689620cb1121fe75d Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Mon, 3 Aug 2020 13:21:04 +0100
Subject: [PATCH 6/9] Iterate copy on download logs button
---
src/components/views/dialogs/BugReportDialog.js | 2 +-
src/i18n/strings/en_EN.json | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/components/views/dialogs/BugReportDialog.js b/src/components/views/dialogs/BugReportDialog.js
index 4c146ebed8..53dfb5d62e 100644
--- a/src/components/views/dialogs/BugReportDialog.js
+++ b/src/components/views/dialogs/BugReportDialog.js
@@ -202,7 +202,7 @@ export default class BugReportDialog extends React.Component {
- { _t("Click here to download your logs.") }
+ { _t("Download logs") }
create a GitHub issue to describe your problem.": "Before submitting logs, you must create a GitHub issue to describe your problem.",
- "Click here to download your logs.": "Click here to download your logs.",
+ "Download logs": "Download logs",
"GitHub issue": "GitHub issue",
"Notes": "Notes",
"If there is additional context that would help in analysing the issue, such as what you were doing at the time, room IDs, user IDs, etc., please include those things here.": "If there is additional context that would help in analysing the issue, such as what you were doing at the time, room IDs, user IDs, etc., please include those things here.",
From 70b5e5b470e596779568abb7c8e545a4d7dce9a5 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Mon, 3 Aug 2020 13:42:01 +0100
Subject: [PATCH 7/9] skip gzipping for downloading
---
src/rageshake/submit-rageshake.ts | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/src/rageshake/submit-rageshake.ts b/src/rageshake/submit-rageshake.ts
index 092f33acab..e0e5570d99 100644
--- a/src/rageshake/submit-rageshake.ts
+++ b/src/rageshake/submit-rageshake.ts
@@ -40,8 +40,7 @@ interface IOpts {
progressCallback?: (string) => void;
}
-async function collectBugReport(opts: IOpts) {
- opts = opts || {};
+async function collectBugReport(opts: IOpts = {}, gzipLogs = true) {
const progressCallback = opts.progressCallback || (() => {});
progressCallback(_t("Collecting app version information"));
@@ -166,12 +165,14 @@ async function collectBugReport(opts: IOpts) {
const logs = await rageshake.getLogsForReport();
for (const entry of logs) {
// encode as UTF-8
- const buf = new TextEncoder().encode(entry.lines);
+ let buf = new TextEncoder().encode(entry.lines);
// compress
- const compressed = pako.gzip(buf);
+ if (gzipLogs) {
+ buf = pako.gzip(buf);
+ }
- body.append('compressed-log', new Blob([compressed]), entry.id);
+ body.append('compressed-log', new Blob([buf]), entry.id);
}
}
@@ -193,12 +194,11 @@ async function collectBugReport(opts: IOpts) {
*
* @return {Promise} Resolved when the bug report is sent.
*/
-export default async function sendBugReport(bugReportEndpoint: string, opts: IOpts) {
+export default async function sendBugReport(bugReportEndpoint: string, opts: IOpts = {}) {
if (!bugReportEndpoint) {
throw new Error("No bug report endpoint has been set.");
}
- opts = opts || {};
const progressCallback = opts.progressCallback || (() => {});
const body = await collectBugReport(opts);
@@ -220,10 +220,9 @@ export default async function sendBugReport(bugReportEndpoint: string, opts: IOp
*
* @return {Promise} Resolved when the bug report is downloaded (or started).
*/
-export async function downloadBugReport(opts) {
- opts = opts || {};
+export async function downloadBugReport(opts: IOpts = {}) {
const progressCallback = opts.progressCallback || (() => {});
- const body = await collectBugReport(opts);
+ const body = await collectBugReport(opts, false);
progressCallback(_t("Downloading report"));
let metadata = "";
@@ -234,7 +233,7 @@ export async function downloadBugReport(opts) {
await new Promise((resolve => {
const reader = new FileReader();
reader.addEventListener('loadend', ev => {
- tape.append(`log-${i++}.log`, pako.ungzip(ev.target.result as string));
+ tape.append(`log-${i++}.log`, new TextDecoder().decode(ev.target.result as ArrayBuffer));
resolve();
});
reader.readAsArrayBuffer(value as Blob);
From 8aa50ecb599ad69ff8038dc7c2e3239dde0a3f60 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Thu, 13 Aug 2020 13:08:07 +0100
Subject: [PATCH 8/9] Iterate rageshake download styling
---
res/css/_components.scss | 1 +
res/css/views/dialogs/_BugReportDialog.scss | 23 +++++++++++++
.../views/dialogs/BugReportDialog.js | 34 +++++++++++++------
3 files changed, 47 insertions(+), 11 deletions(-)
create mode 100644 res/css/views/dialogs/_BugReportDialog.scss
diff --git a/res/css/_components.scss b/res/css/_components.scss
index 7dd8a2034d..6808953e4f 100644
--- a/res/css/_components.scss
+++ b/res/css/_components.scss
@@ -59,6 +59,7 @@
@import "./views/context_menus/_WidgetContextMenu.scss";
@import "./views/dialogs/_AddressPickerDialog.scss";
@import "./views/dialogs/_Analytics.scss";
+@import "./views/dialogs/_BugReportDialog.scss";
@import "./views/dialogs/_ChangelogDialog.scss";
@import "./views/dialogs/_ChatCreateOrReuseChatDialog.scss";
@import "./views/dialogs/_ConfirmUserActionDialog.scss";
diff --git a/res/css/views/dialogs/_BugReportDialog.scss b/res/css/views/dialogs/_BugReportDialog.scss
new file mode 100644
index 0000000000..1920ac33ea
--- /dev/null
+++ b/res/css/views/dialogs/_BugReportDialog.scss
@@ -0,0 +1,23 @@
+/*
+Copyright 2020 The Matrix.org Foundation C.I.C.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+.mx_BugReportDialog {
+ .mx_BugReportDialog_download {
+ .mx_AccessibleButton_kind_link {
+ padding-left: 0;
+ }
+ }
+}
diff --git a/src/components/views/dialogs/BugReportDialog.js b/src/components/views/dialogs/BugReportDialog.js
index ffef88e8be..d001d3993d 100644
--- a/src/components/views/dialogs/BugReportDialog.js
+++ b/src/components/views/dialogs/BugReportDialog.js
@@ -36,6 +36,8 @@ export default class BugReportDialog extends React.Component {
issueUrl: "",
text: "",
progress: null,
+ downloadBusy: false,
+ downloadProgress: null,
};
this._unmounted = false;
this._onSubmit = this._onSubmit.bind(this);
@@ -44,6 +46,7 @@ export default class BugReportDialog extends React.Component {
this._onIssueUrlChange = this._onIssueUrlChange.bind(this);
this._onSendLogsChange = this._onSendLogsChange.bind(this);
this._sendProgressCallback = this._sendProgressCallback.bind(this);
+ this._downloadProgressCallback = this._downloadProgressCallback.bind(this);
}
componentWillUnmount() {
@@ -97,26 +100,25 @@ export default class BugReportDialog extends React.Component {
}
_onDownload = async (ev) => {
- this.setState({ busy: true, progress: null, err: null });
- this._sendProgressCallback(_t("Preparing to download logs"));
+ this.setState({ downloadBusy: true });
+ this._downloadProgressCallback(_t("Preparing to download logs"));
try {
await downloadBugReport({
sendLogs: true,
- progressCallback: this._sendProgressCallback,
+ progressCallback: this._downloadProgressCallback,
label: this.props.label,
});
this.setState({
- busy: false,
- progress: null,
+ downloadBusy: false,
+ downloadProgress: null,
});
} catch (err) {
if (!this._unmounted) {
this.setState({
- busy: false,
- progress: null,
- err: _t("Failed to send logs: ") + `${err.message}`,
+ downloadBusy: false,
+ downloadProgress: _t("Failed to send logs: ") + `${err.message}`,
});
}
}
@@ -141,6 +143,13 @@ export default class BugReportDialog extends React.Component {
this.setState({progress: progress});
}
+ _downloadProgressCallback(downloadProgress) {
+ if (this._unmounted) {
+ return;
+ }
+ this.setState({ downloadProgress });
+ }
+
render() {
const Loader = sdk.getComponent("elements.Spinner");
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
@@ -201,9 +210,12 @@ export default class BugReportDialog extends React.Component {
) }
-
- { _t("Download logs") }
-
+
+
+ { _t("Download logs") }
+
+ {this.state.downloadProgress &&
{this.state.downloadProgress} ...}
+
Date: Tue, 18 Aug 2020 17:38:10 +0100
Subject: [PATCH 9/9] Update copy
---
src/i18n/strings/en_EN.json | 4 ++--
src/rageshake/submit-rageshake.ts | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json
index 964317d2c9..8bfc3ed703 100644
--- a/src/i18n/strings/en_EN.json
+++ b/src/i18n/strings/en_EN.json
@@ -503,8 +503,8 @@
"Enable experimental, compact IRC style layout": "Enable experimental, compact IRC style layout",
"Collecting app version information": "Collecting app version information",
"Collecting logs": "Collecting logs",
- "Uploading report": "Uploading report",
- "Downloading report": "Downloading report",
+ "Uploading logs": "Uploading logs",
+ "Downloading logs": "Downloading logs",
"Waiting for response from server": "Waiting for response from server",
"Messages containing my display name": "Messages containing my display name",
"Messages containing my username": "Messages containing my username",
diff --git a/src/rageshake/submit-rageshake.ts b/src/rageshake/submit-rageshake.ts
index fbcce4cef9..cc512bdfc7 100644
--- a/src/rageshake/submit-rageshake.ts
+++ b/src/rageshake/submit-rageshake.ts
@@ -204,7 +204,7 @@ export default async function sendBugReport(bugReportEndpoint: string, opts: IOp
const progressCallback = opts.progressCallback || (() => {});
const body = await collectBugReport(opts);
- progressCallback(_t("Uploading report"));
+ progressCallback(_t("Uploading logs"));
await _submitReport(bugReportEndpoint, body, progressCallback);
}
@@ -226,7 +226,7 @@ export async function downloadBugReport(opts: IOpts = {}) {
const progressCallback = opts.progressCallback || (() => {});
const body = await collectBugReport(opts, false);
- progressCallback(_t("Downloading report"));
+ progressCallback(_t("Downloading logs"));
let metadata = "";
const tape = new Tar();
let i = 0;