[polari] cleanup: Replace non-standard ByteArray module
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] cleanup: Replace non-standard ByteArray module
- Date: Mon, 16 Aug 2021 22:18:14 +0000 (UTC)
commit b16eb6804305f842379debfaa584681c9c741e5b
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Aug 12 16:42:53 2021 +0200
cleanup: Replace non-standard ByteArray module
gjs landed support for TextDecoder/TextEncoder. Use those instead
of gjs' own ByteArray module.
https://gitlab.gnome.org/GNOME/polari/-/merge_requests/210
src/networksManager.js | 3 +--
src/utils.js | 8 +++-----
2 files changed, 4 insertions(+), 7 deletions(-)
---
diff --git a/src/networksManager.js b/src/networksManager.js
index 6561a804..4417b0b1 100644
--- a/src/networksManager.js
+++ b/src/networksManager.js
@@ -1,7 +1,6 @@
import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
-const ByteArray = imports.byteArray;
const Signals = imports.signals;
export default class NetworksManager {
@@ -20,7 +19,7 @@ export default class NetworksManager {
let data;
try {
[, data] = file.load_contents(null);
- this._parseNetworks(ByteArray.toString(data));
+ this._parseNetworks(new TextDecoder().decode(data));
} catch (e) {
log(`Failed to load network list: ${e.message}`);
}
diff --git a/src/utils.js b/src/utils.js
index e2ab02f7..b38f87d8 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -20,8 +20,6 @@
*
*/
-const ByteArray = imports.byteArray;
-
import Gdk from 'gi://Gdk';
import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
@@ -345,7 +343,7 @@ async function _getGpasteExpire() {
GLib.PRIORITY_DEFAULT,
null);
checkResponse(message);
- const json = ByteArray.toString(bytes.get_data());
+ const json = new TextDecoder().decode(bytes.get_data());
const info = JSON.parse(json);
const values = info.result?.values;
@@ -388,7 +386,7 @@ export async function gpaste(text, title) {
GLib.PRIORITY_DEFAULT,
null);
checkResponse(message);
- const json = ByteArray.toString(bytes.get_data());
+ const json = new TextDecoder().decode(bytes.get_data());
const info = JSON.parse(json);
if (!info.result?.id)
@@ -425,7 +423,7 @@ export async function imgurPaste(pixbuf, title) {
GLib.PRIORITY_DEFAULT,
null);
checkResponse(message);
- const json = ByteArray.toString(bytes.get_data());
+ const json = new TextDecoder().decode(bytes.get_data());
const info = JSON.parse(json);
if (!info.success)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]