[gnome-maps/wip/mlundblad/es6-modules: 10/22] utils: Stop using imports.byteArray
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/es6-modules: 10/22] utils: Stop using imports.byteArray
- Date: Sun, 5 Jun 2022 20:37:33 +0000 (UTC)
commit c5de38684172ee16a8f600d67a789caf80573966
Author: Marcus Lundblad <ml dfupdate se>
Date: Mon May 23 23:30:26 2022 +0200
utils: Stop using imports.byteArray
Replace usage with ES TextDecoder.
src/utils.js | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
---
diff --git a/src/utils.js b/src/utils.js
index 91f88937..2cf6920b 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -34,8 +34,6 @@ import Soup from 'gi://Soup';
const _ = gettext.gettext;
const ngettext = gettext.ngettext;
-const ByteArray = imports.byteArray;
-
export const METRIC_SYSTEM = 1;
export const IMPERIAL_SYSTEM = 2;
@@ -465,15 +463,13 @@ export function showDialog(msg, type, transientFor) {
messageDialog.show_all();
}
+let decoder = new TextDecoder('utf-8');
+
/* Gets a string from either a ByteArray or Uint8Array. This is for
compatibility between two different Gjs versions, see discussion at
https://gitlab.gnome.org/GNOME/gnome-maps/merge_requests/19 */
export function getBufferText(buffer) {
- if (buffer instanceof Uint8Array) {
- return ByteArray.toString(buffer);
- } else {
- return buffer.toString();
- }
+ return decoder.decode(buffer);
}
export function getCountryCodeForCoordinates(lat, lon) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]