Skip to content

Commit

Permalink
fix ByteArray warning, gnome 42
Browse files Browse the repository at this point in the history
  • Loading branch information
biji committed Apr 7, 2022
1 parent aace564 commit 14373b6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
14 changes: 12 additions & 2 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ let lastCount = 0, lastSpeed = 0, lastCountUp = 0;
let mode; // 0: kbps 1: K/s 2: U:kbps D:kbps 3: U:K/s D:K/s 4: Total KB
let fontmode;
let resetNextCount = false, resetCount = 0;
let byteArrayToString;

if (global.TextDecoder) {
// available in gjs >= 1.70 (GNOME Shell >= 42)
byteArrayToString = (new TextDecoder().decode);
}
else {
// gjs-specific
byteArrayToString = imports.byteArray.toString;
}

function init() {

Expand Down Expand Up @@ -77,8 +87,8 @@ function parseStat() {
let count = 0;
let countUp = 0;
let line;
while (line = dstream.read_line(null)) {
line = String(line);
while (([line, len] = dstream.read_line(null)) != null && line != null) {
line = byteArrayToString(line);
line = line.trim();
let fields = line.split(/\W+/);
if (fields.length<=2) break;
Expand Down
5 changes: 3 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
"3.36",
"3.38",
"40",
"41"
"41",
"42"
],
"url": "https://github.com/biji/simplenetspeed",
"uuid": "[email protected]",
"version": 25
"version": 26
}

0 comments on commit 14373b6

Please sign in to comment.