From 1b4c178790151fb4b9a4bd80a76f3dcae58c1da5 Mon Sep 17 00:00:00 2001 From: Cromefire_ Date: Wed, 15 Apr 2020 10:16:41 +0200 Subject: [PATCH] Migrated src/components/backdropscreensaver/plugin.js --- src/plugins/backdropScreensaver/plugin.js | 63 +++++++++++------------ 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/src/plugins/backdropScreensaver/plugin.js b/src/plugins/backdropScreensaver/plugin.js index dc0a906ddb..07b9d6d3b3 100644 --- a/src/plugins/backdropScreensaver/plugin.js +++ b/src/plugins/backdropScreensaver/plugin.js @@ -1,36 +1,32 @@ -define(['connectionManager'], function (connectionManager) { +/* eslint-disable indent */ +import connectionManager from "connectionManager"; - return function () { - - var self = this; - - self.name = 'Backdrop ScreenSaver'; - self.type = 'screensaver'; - self.id = 'backdropscreensaver'; - self.supportsAnonymous = false; - - var currentSlideshow; - - self.show = function () { - - var query = { - ImageTypes: 'Backdrop', - EnableImageTypes: 'Backdrop', - IncludeItemTypes: 'Movie,Series,MusicArtist', - SortBy: 'Random', +class BackdropScreensaver { + constructor() { + this.name = "Backdrop ScreenSaver"; + this.type = "screensaver"; + this.id = "backdropscreensaver"; + this.supportsAnonymous = false; + } + show() { + const query = { + ImageTypes: "Backdrop", + EnableImageTypes: "Backdrop", + IncludeItemTypes: "Movie,Series,MusicArtist", + SortBy: "Random", Recursive: true, - Fields: 'Taglines', + Fields: "Taglines", ImageTypeLimit: 1, StartIndex: 0, Limit: 200 }; - var apiClient = connectionManager.currentApiClient(); + const apiClient = connectionManager.currentApiClient(); apiClient.getItems(apiClient.getCurrentUserId(), query).then(function (result) { if (result.Items.length) { - require(['slideshow'], function (slideshow) { + import("slideshow").then(slideshow => { var newSlideShow = new slideshow({ showTitle: true, @@ -39,18 +35,19 @@ define(['connectionManager'], function (connectionManager) { }); newSlideShow.show(); - currentSlideshow = newSlideShow; - }); + this.currentSlideshow = newSlideShow; + }).catch(console.error); } }); - }; + } - self.hide = function () { - - if (currentSlideshow) { - currentSlideshow.hide(); - currentSlideshow = null; + hide() { + if (this.currentSlideshow) { + this.currentSlideshow.hide(); + this.currentSlideshow = null; } - }; - }; -}); + } + } +/* eslint-enable indent */ + +export default BackdropScreensaver;