[gnome-maps/wip/mlundblad/es6-modules] 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] utils: Stop using imports.byteArray
- Date: Mon, 23 May 2022 21:35:46 +0000 (UTC)
commit 74721977cc09831e059de856f8adf76b49a6cb4f
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]