maunium / stickerpicker

A fast and simple Matrix sticker picker widget
GNU Affero General Public License v3.0
312 stars 592 forks source link

fails loading, if a pack has zero stickers #64

Open LuckyTurtleDev opened 1 year ago

LuckyTurtleDev commented 1 year ago

Stickerpicker fails loading, if a pack has zero stickers:

Uncaught (in promise) TypeError: pack.stickers[0] is undefined
    NavBarItem https://ptphoenix.github.io/stickerpicker/web/src/index.js:339
    Preact 16
    _loadPacks https://ptphoenix.github.io/stickerpicker/web/src/index.js:179
    _loadPacks https://ptphoenix.github.io/stickerpicker/web/src/index.js:157
    componentDidMount https://ptphoenix.github.io/stickerpicker/web/src/index.js:190
    Preact 4
    <anonymous> https://ptphoenix.github.io/stickerpicker/web/src/index.js:363
index.js:339:1
<img src=${makeThumbnailURL(pack.stickers[0].url)}
                    alt=${pack.stickers[0].body} class="visible" />

This caused also that the picker stop loading the remain packs.

I would recommend using the java script version of:

pack.stickers.first().unwrap_or("not_found.png")

However assuming that a pack is not empty is justify, but it should not effect the other stickerpacks.