Skip to content

Commit 14373b6

Browse files
committed
fix ByteArray warning, gnome 42
1 parent aace564 commit 14373b6

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

extension.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ let lastCount = 0, lastSpeed = 0, lastCountUp = 0;
2020
let mode; // 0: kbps 1: K/s 2: U:kbps D:kbps 3: U:K/s D:K/s 4: Total KB
2121
let fontmode;
2222
let resetNextCount = false, resetCount = 0;
23+
let byteArrayToString;
24+
25+
if (global.TextDecoder) {
26+
// available in gjs >= 1.70 (GNOME Shell >= 42)
27+
byteArrayToString = (new TextDecoder().decode);
28+
}
29+
else {
30+
// gjs-specific
31+
byteArrayToString = imports.byteArray.toString;
32+
}
2333

2434
function init() {
2535

@@ -77,8 +87,8 @@ function parseStat() {
7787
let count = 0;
7888
let countUp = 0;
7989
let line;
80-
while (line = dstream.read_line(null)) {
81-
line = String(line);
90+
while (([line, len] = dstream.read_line(null)) != null && line != null) {
91+
line = byteArrayToString(line);
8292
line = line.trim();
8393
let fields = line.split(/\W+/);
8494
if (fields.length<=2) break;

metadata.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
"3.36",
99
"3.38",
1010
"40",
11-
"41"
11+
"41",
12+
"42"
1213
],
1314
"url": "https://github.com/biji/simplenetspeed",
1415
"uuid": "simplenetspeed@biji.extension",
15-
"version": 25
16+
"version": 26
1617
}

0 commit comments

Comments
 (0)