30 seconds limit for dark theme preview
This commit is contained in:
parent
b96300ced0
commit
c691eb8017
@ -1,6 +1,7 @@
|
|||||||
import AnimeNotifier from "../AnimeNotifier"
|
import AnimeNotifier from "../AnimeNotifier"
|
||||||
|
|
||||||
let currentTheme = "light"
|
let currentTheme = "light"
|
||||||
|
let intervalID: number = 0
|
||||||
|
|
||||||
const light = {}
|
const light = {}
|
||||||
const dark = {
|
const dark = {
|
||||||
@ -45,9 +46,11 @@ const dark = {
|
|||||||
|
|
||||||
// Toggle theme
|
// Toggle theme
|
||||||
export function toggleTheme(arn: AnimeNotifier) {
|
export function toggleTheme(arn: AnimeNotifier) {
|
||||||
|
// Clear preview interval
|
||||||
|
clearInterval(intervalID)
|
||||||
|
|
||||||
if(currentTheme === "light") {
|
if(currentTheme === "light") {
|
||||||
darkTheme(arn)
|
darkTheme(arn)
|
||||||
arn.statusMessage.showInfo("Previewing Dark theme. If you would like to use it permanently, please buy a PRO account.", 4000)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,9 +76,17 @@ export function lightTheme(arn: AnimeNotifier) {
|
|||||||
export function darkTheme(arn: AnimeNotifier) {
|
export function darkTheme(arn: AnimeNotifier) {
|
||||||
let root = document.documentElement
|
let root = document.documentElement
|
||||||
|
|
||||||
// if(arn.user.dataset.pro !== "true") {
|
if(arn.user.dataset.pro !== "true") {
|
||||||
// alert("You need a PRO account!")
|
arn.statusMessage.showInfo("Previewing Dark theme for 30 seconds. If you would like to use it permanently, please support us.", 5000)
|
||||||
// }
|
|
||||||
|
// After 30 seconds, switch back to default theme if the user doesn't own a PRO account
|
||||||
|
intervalID = setInterval(() => {
|
||||||
|
if(currentTheme === "dark") {
|
||||||
|
toggleTheme(arn)
|
||||||
|
arn.statusMessage.showInfo("Dark theme preview time has ended. If you would like to use it permanently, please support us.", 5000)
|
||||||
|
}
|
||||||
|
}, 30000)
|
||||||
|
}
|
||||||
|
|
||||||
for(let property in dark) {
|
for(let property in dark) {
|
||||||
if(!dark.hasOwnProperty(property)) {
|
if(!dark.hasOwnProperty(property)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user