From 48aff1d364f5e64a968016b938662e1aec4f8970 Mon Sep 17 00:00:00 2001 From: Hermes Date: Sat, 8 Aug 2026 12:43:22 +0200 Subject: [PATCH] fix: register components as constructor functions (not object literals) - fixes 'not a constructor' crash --- plugin.js | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/plugin.js b/plugin.js index f88e017..5abdc03 100644 --- a/plugin.js +++ b/plugin.js @@ -21,14 +21,11 @@ } // ---------- Компонент: список фильмов ---------- - // Паттерн из официального iptv-плагина Lampa: - // create() возвращает this.render(); render() строит html и выводит через Lampa.Layer. - Lampa.Component.add(PLUGIN.name, { - create: function () { - return this.render(); - }, - render: function () { - var comp = this; + // Регистрируется как функция-конструктор (как iptv), иначе Lampa падает: + // "component is not a constructor" + function MyMovies() { + var comp = this; + this.create = function () { var html = $('
'); comp.activity.loader(true); @@ -54,8 +51,9 @@ }); return html; - } - }); + }; + } + Lampa.Component.add(PLUGIN.name, MyMovies); function renderMovies(grid, movies) { grid.empty(); @@ -77,12 +75,9 @@ // ---------- Компонент: детали фильма ---------- var selected = null; - Lampa.Component.add(PLUGIN.name + '_detail', { - create: function () { - return this.render(); - }, - render: function () { - var comp = this; + function MyMoviesDetail() { + var comp = this; + this.create = function () { var m = selected; if (!m) { Lampa.Activity.back(); return $('
'); } @@ -105,8 +100,9 @@ Lampa.Layer.update(html); Lampa.Layer.visible(html); return html; - } - }); + }; + } + Lampa.Component.add(PLUGIN.name + '_detail', MyMoviesDetail); function openMovie(m) { selected = m;