added dialog informing browser tab closing

This commit is contained in:
2024-08-13 20:05:25 -04:00
parent a0e193e343
commit 0f647e85cb
3 changed files with 30 additions and 9 deletions

View File

@ -57,7 +57,7 @@ func (a *App) AniListLogin() {
serverDone := &sync.WaitGroup{}
serverDone.Add(1)
handleAniListCallback(serverDone)
a.handleAniListCallback(serverDone)
serverDone.Wait()
} else {
aniListJwt.TokenType = string(tokenType.Data)
@ -68,7 +68,7 @@ func (a *App) AniListLogin() {
}
}
func handleAniListCallback(wg *sync.WaitGroup) {
func (a *App) handleAniListCallback(wg *sync.WaitGroup) {
mux := http.NewServeMux()
srv := &http.Server{Addr: ":6734", Handler: mux}
mux.HandleFunc("/callback", func(w http.ResponseWriter, r *http.Request) {
@ -98,9 +98,16 @@ func handleAniListCallback(wg *sync.WaitGroup) {
Key: "anilistRefreshToken",
Data: []byte(aniListJwt.RefreshToken),
})
_, err := runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
Title: "AniList Authorization",
Message: "It is now safe to close your browser tab",
})
if err != nil {
log.Println(err)
}
fmt.Println("Shutting down...")
aniCancel()
err := srv.Shutdown(context.Background())
err = srv.Shutdown(context.Background())
if err != nil {
log.Println("server.Shutdown:", err)
}