Remmi_Jefferson Posted February 14, 2020 Posted February 14, 2020 Hi, the browser is called only once, the second time nothing happens if(notifications) { notifications.destroy(); } else{ var notifications = mp.browsers.new("package://notifications/index.html"); setTimeout(() => { notifications.destroy(); }, 5000) }
MrPancakers Posted February 14, 2020 Posted February 14, 2020 in this instance you'd have to do notifications = null; after the destroy, even if you destroy it, it doesn't turn the variable to nothing, so therefore each time you run it, it's always running 'notifications.destroy() because if(notifications) is true.
Remmi_Jefferson Posted February 14, 2020 Author Posted February 14, 2020 (edited) if(notifications) { notifications = null; } else{ var notifications = mp.browsers.new("package://notifications/index.html"); setTimeout(() => { notifications.destroy(); notifications = null; }, 5000) } So? Edited February 14, 2020 by Remmi_Jefferson
Xabi Posted February 14, 2020 Posted February 14, 2020 (edited) 6 minutes ago, Remmi_Jefferson said: if(notifications) { notifications = null; } else{ var notifications = mp.browsers.new("package://notifications/index.html"); setTimeout(() => { notifications.destroy(); }, 5000) } So? The null should be assigned AFTER the destroy() line, don't just replace it. That's what @MrPancakers told you to do and how it's supposed to work. Edited February 14, 2020 by Xabi
Remmi_Jefferson Posted February 14, 2020 Author Posted February 14, 2020 2 минуты назад, Xabi сказал: The null should be assigned AFTER the destroy() line, don't just replace it. That's what @MrPancakers told you to do and how it's supposed to work. if(notifications) { notifications = null; } else{ var notifications = mp.browsers.new("package://notifications/index.html"); setTimeout(() => { notifications.destroy(); notifications = null; }, 5000) } Does not work
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now