From a12b749ee9aa1b63983f8ab4b0885c2309c023d4 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Thu, 15 Nov 2018 13:04:14 +0900 Subject: [PATCH] Fixed missing input check --- .../notification-delete-old.go | 25 +++++++++++++++++++ scripts/AnimeNotifier.ts | 5 +++- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 patches/notification-delete-old/notification-delete-old.go diff --git a/patches/notification-delete-old/notification-delete-old.go b/patches/notification-delete-old/notification-delete-old.go new file mode 100644 index 00000000..04026e1c --- /dev/null +++ b/patches/notification-delete-old/notification-delete-old.go @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + + "github.com/animenotifier/arn" + "github.com/fatih/color" +) + +const maxNotificationsPerUser = 80 + +func main() { + color.Yellow("Deleting old notifications") + + defer color.Green("Finished") + defer arn.Node.Close() + + for user := range arn.StreamUsers() { + notificationCount := len(user.Notifications().Items) + + if notificationCount > maxNotificationsPerUser { + fmt.Println(user.Nick, notificationCount) + } + } +} diff --git a/scripts/AnimeNotifier.ts b/scripts/AnimeNotifier.ts index 903bdd11..1a2b721d 100644 --- a/scripts/AnimeNotifier.ts +++ b/scripts/AnimeNotifier.ts @@ -175,7 +175,10 @@ export default class AnimeNotifier { // Auto-focus first input element on welcome page. if(location.pathname === "/welcome") { let firstInput = this.app.content.getElementsByTagName("input")[0] as HTMLInputElement - firstInput.focus() + + if(firstInput) { + firstInput.focus() + } } }