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"