From 44deaa9ed9c797522b3ec46624fe0b4dc22680d4 Mon Sep 17 00:00:00 2001 From: Adrien Date: Fri, 31 May 2024 10:16:01 +0200 Subject: [PATCH] fixs --- Chat.go | 27 +++++++++++++++++++++++- database.go | 1 + login.go | 5 ++--- static/style.css | 4 ---- views/chat.html | 2 +- views/partials/popover-conversation.html | 2 +- 6 files changed, 31 insertions(+), 10 deletions(-) diff --git a/Chat.go b/Chat.go index 622cec5..111b316 100644 --- a/Chat.go +++ b/Chat.go @@ -686,6 +686,7 @@ func GenerateConversationPopoverHTML(isActive bool) string { SELECT Conversation { name, position, + selected, id } FILTER .user = global currentUser @@ -818,7 +819,31 @@ func SelectConversationHandler(c *fiber.Ctx) error { panic(err) } - edgeClient = edgeClient.WithGlobals(map[string]interface{}{"ext::auth::client_token": c.Cookies("jade-edgedb-auth-token"), "currentConversationID": conversationUUID}) + err = edgeClient.Execute(edgeCtx, ` + UPDATE Conversation + FILTER .user = global currentUser + SET { + selected := false + }; + `, conversationUUID) + if err != nil { + fmt.Println("Error unselecting conversations") + panic(err) + } + + err = edgeClient.Execute(edgeCtx, ` + UPDATE Conversation + FILTER .user = global currentUser AND .id = $0 + SET { + selected := true + }; + `, conversationUUID) + if err != nil { + fmt.Println("Error selecting conversations") + panic(err) + } + + edgeClient = edgeClient.WithoutGlobals().WithGlobals(map[string]interface{}{"ext::auth::client_token": c.Cookies("jade-edgedb-auth-token")}) return c.SendString(generateChatHTML()) } diff --git a/database.go b/database.go index 9122841..0902138 100644 --- a/database.go +++ b/database.go @@ -47,6 +47,7 @@ type Setting struct { // Per user type Conversation struct { ID edgedb.UUID `edgedb:"id"` Name string `edgedb:"name"` + Selected bool `edgedb:"selected"` Position int32 `edgedb:"position"` Date time.Time `edgedb:"date"` User User `edgedb:"user"` diff --git a/login.go b/login.go index 6d31823..c99ad00 100644 --- a/login.go +++ b/login.go @@ -78,8 +78,7 @@ func getGoogleUserProfile(providerToken string) (string, string, string) { defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - fmt.Println("Error fetching user profile") - panic(err) + panic("Error fetching user profile") } body, err = io.ReadAll(resp.Body) @@ -101,7 +100,7 @@ func getGitHubUserProfile(providerToken string) (string, string, string) { // Create the request to fetch the user profile req, err := http.NewRequest("GET", "https://api.github.com/user", nil) if err != nil { - fmt.Println("failed to create request: %v", err) + fmt.Println("failed to create request: user profile") panic(err) } req.Header.Set("Authorization", "Bearer "+providerToken) diff --git a/static/style.css b/static/style.css index bfcc4bd..e269352 100644 --- a/static/style.css +++ b/static/style.css @@ -1,7 +1,3 @@ -body { - padding-bottom: 40px; -} - html { height: 100%; margin: 0; diff --git a/views/chat.html b/views/chat.html index f49317e..42f351b 100644 --- a/views/chat.html +++ b/views/chat.html @@ -1,4 +1,4 @@ -
+
{% if IsSubscribed or not IsLimiteReached %} diff --git a/views/partials/popover-conversation.html b/views/partials/popover-conversation.html index 3876657..66c8f10 100644 --- a/views/partials/popover-conversation.html +++ b/views/partials/popover-conversation.html @@ -13,7 +13,7 @@