MisterGuinness / gnome-shell-extension-sensors

Gnome shell extension: Shows CPU temperature, HDD temperature, voltage and fan RPM
0 stars 0 forks source link

Fedora 39: ByteArray is deprecated #93

Closed MisterGuinness closed 5 months ago

MisterGuinness commented 1 year ago

I happened to notice in the GJS documentation

https://gjs.guide/guides/gjs/asynchronous-programming.html#event-sources

the following bit of code:

const stdinDecoder = new TextDecoder('utf-8');
...
    const text = stdinDecoder.decode(data).trim();

So I looked up ByteArray, which I currently use since Issue #10 :

https://github.com/GNOME/gjs/blob/master/doc/ByteArray.md#bytearraytostringbytearray-encoding

ByteArray.toString(byteArray, encoding)

Deprecated: Use TextDecoder.decode() instead

Which is documented here:

https://gjs-docs.gnome.org/gjs/encoding.md#textdecoder-decode

New in GJS 1.70 (GNOME 41)

Oh, that was a while ago.

MisterGuinness commented 1 year ago

1. Extension

$ grep -i bytearray extension.js 
const ByteArray = imports.byteArray;

Oops, not even used, wonder why.

2. Prefs

$ grep -i bytearray prefs.js 
const ByteArray = imports.byteArray;
                let output = ByteArray.toString(sensors_output);
                    ByteArray.toString(hddtemp_output),

3. Utilities

$ grep -i bytearray utilities.js 
const ByteArray = imports.byteArray;
        if(result && ByteArray.toString(activeState).trim() == "ActiveState=active") {
                output=ByteArray.toString(output).trim();
            output=ByteArray.toString(output).trim();
                let text = ByteArray.toString(stream.peek_buffer());
                this._stdoutString = ByteArray.toString(stream.peek_buffer());
        newLocale = ByteArray.toString(contents).substr(0,10);

That last one will be the first one I modify, in the override locale hack.

MisterGuinness commented 1 year ago

The inclusion of byteArray in extension.js was done here: 097fc9c7b5339d57b60f368f9995fd029fa39572

Clearly an oversight