summaryrefslogtreecommitdiffstats
path: root/toolkit/components/satchel/megalist/MegalistViewModel.sys.mjs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
commita90a5cba08fdf6c0ceb95101c275108a152a3aed (patch)
tree532507288f3defd7f4dcf1af49698bcb76034855 /toolkit/components/satchel/megalist/MegalistViewModel.sys.mjs
parentAdding debian version 126.0.1-1. (diff)
downloadfirefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.tar.xz
firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/satchel/megalist/MegalistViewModel.sys.mjs')
-rw-r--r--toolkit/components/satchel/megalist/MegalistViewModel.sys.mjs28
1 files changed, 24 insertions, 4 deletions
diff --git a/toolkit/components/satchel/megalist/MegalistViewModel.sys.mjs b/toolkit/components/satchel/megalist/MegalistViewModel.sys.mjs
index f11a8a3198..66a062fa06 100644
--- a/toolkit/components/satchel/megalist/MegalistViewModel.sys.mjs
+++ b/toolkit/components/satchel/megalist/MegalistViewModel.sys.mjs
@@ -67,6 +67,13 @@ export class MegalistViewModel {
}
}
+ #commandsArray(snapshot) {
+ if (Array.isArray(snapshot.commands)) {
+ return snapshot.commands;
+ }
+ return Array.from(snapshot.commands());
+ }
+
/**
*
* Send snapshot of necessary line data across parent-child boundary.
@@ -95,7 +102,7 @@ export class MegalistViewModel {
snapshot.end = snapshotData.end;
}
if ("commands" in snapshotData) {
- snapshot.commands = snapshotData.commands;
+ snapshot.commands = this.#commandsArray(snapshotData);
}
if ("valueIcon" in snapshotData) {
snapshot.valueIcon = snapshotData.valueIcon;
@@ -104,7 +111,7 @@ export class MegalistViewModel {
snapshot.href = snapshotData.href;
}
if (snapshotData.stickers) {
- for (const sticker of snapshotData.stickers) {
+ for (const sticker of snapshotData.stickers()) {
snapshot.stickers ??= [];
snapshot.stickers.push(sticker);
}
@@ -177,13 +184,22 @@ export class MegalistViewModel {
}
async receiveCommand({ commandId, snapshotId, value } = {}) {
+ const dotIndex = commandId?.indexOf(".");
+ if (dotIndex >= 0) {
+ const dataSourceName = commandId.substring(0, dotIndex);
+ const functionName = commandId.substring(dotIndex + 1);
+ MegalistViewModel.#aggregator.callFunction(dataSourceName, functionName);
+ return;
+ }
+
const index = snapshotId
? snapshotId - this.#firstSnapshotId
: this.#selectedIndex;
const snapshot = this.#snapshots[index];
if (snapshot) {
- commandId = commandId ?? snapshot.commands[0]?.id;
- const mustVerify = snapshot.commands.find(c => c.id == commandId)?.verify;
+ const commands = this.#commandsArray(snapshot);
+ commandId = commandId ?? commands[0]?.id;
+ const mustVerify = commands.find(c => c.id == commandId)?.verify;
if (!mustVerify || (await this.#verifyUser())) {
// TODO:Enter the prompt message and pref for #verifyUser()
await snapshot[`execute${commandId}`]?.(value);
@@ -230,6 +246,10 @@ export class MegalistViewModel {
}
}
+ setLayout(layout) {
+ this.#messageToView("SetLayout", { layout });
+ }
+
async #verifyUser(promptMessage, prefName) {
if (!this.getOSAuthEnabled(prefName)) {
promptMessage = false;