StreamElements / widgets

283 stars 119 forks source link

onSessionUpdate wont load donation name #23

Closed Kraantje85 closed 10 months ago

Kraantje85 commented 2 years ago

Hi,

I am building a widget but i getting something not right. With this code everything is working and getting updated except for one value and thats the name of the "tip-session-top-donation". Everything loads fine with the "onWidgetLoad" but when i send a simulation donation i get the text "tip-session-top-donation" as name, the amount is updating fine.

Does somebody know what i do wrong?

window.addEventListener('onWidgetLoad', function (obj) {
    let data = obj["detail"]["session"]["data"];

    $("#top-dono .name").text(data["tip-session-top-donation"]["name"]);
    $("#top-dono .amount").text("€" + data["tip-session-top-donation"]["amount"]);
    $("#sub .name").text(data["subscriber-latest"]["name"]);
});

window.addEventListener('onSessionUpdate', function (obj) {
    const data = obj.detail.session;

    $("#top-dono .name").text(data["tip-session-top-donation"]["name"]);
    $("#top-dono .amount").text("€" + data["tip-session-top-donation"]["amount"]);
    $("#sub .name").text(data["subscriber-latest"]["name"]);

    updateEvent(data);
});
nmynarcik commented 2 years ago

~Hey there! If you want to snag the top donator's name, you can get it from tip-session-top-donator. You can see more with an example here.~

Actually, to test the session top-donation, you can change the widget data in the dashboard. When you save, the session object should come in with the new data.

See if that helps you get what you are looking for.