This commit is contained in:
Adrien Bouvais 2024-05-31 10:16:01 +02:00
parent 381262b121
commit 44deaa9ed9
6 changed files with 31 additions and 10 deletions

27
Chat.go
View File

@ -686,6 +686,7 @@ func GenerateConversationPopoverHTML(isActive bool) string {
SELECT Conversation { SELECT Conversation {
name, name,
position, position,
selected,
id id
} }
FILTER .user = global currentUser FILTER .user = global currentUser
@ -818,7 +819,31 @@ func SelectConversationHandler(c *fiber.Ctx) error {
panic(err) 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 = <uuid>$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()) return c.SendString(generateChatHTML())
} }

View File

@ -47,6 +47,7 @@ type Setting struct { // Per user
type Conversation struct { type Conversation struct {
ID edgedb.UUID `edgedb:"id"` ID edgedb.UUID `edgedb:"id"`
Name string `edgedb:"name"` Name string `edgedb:"name"`
Selected bool `edgedb:"selected"`
Position int32 `edgedb:"position"` Position int32 `edgedb:"position"`
Date time.Time `edgedb:"date"` Date time.Time `edgedb:"date"`
User User `edgedb:"user"` User User `edgedb:"user"`

View File

@ -78,8 +78,7 @@ func getGoogleUserProfile(providerToken string) (string, string, string) {
defer resp.Body.Close() defer resp.Body.Close()
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
fmt.Println("Error fetching user profile") panic("Error fetching user profile")
panic(err)
} }
body, err = io.ReadAll(resp.Body) 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 // Create the request to fetch the user profile
req, err := http.NewRequest("GET", "https://api.github.com/user", nil) req, err := http.NewRequest("GET", "https://api.github.com/user", nil)
if err != nil { if err != nil {
fmt.Println("failed to create request: %v", err) fmt.Println("failed to create request: user profile")
panic(err) panic(err)
} }
req.Header.Set("Authorization", "Bearer "+providerToken) req.Header.Set("Authorization", "Bearer "+providerToken)

View File

@ -1,7 +1,3 @@
body {
padding-bottom: 40px;
}
html { html {
height: 100%; height: 100%;
margin: 0; margin: 0;

View File

@ -1,4 +1,4 @@
<div class="chat-container mt-5"> <div class="chat-container mt-5" style="padding-bottom: 155px;">
<hx hx-get="/loadChat" hx-trigger="load once" hx-swap="outerHTML"></hx> <hx hx-get="/loadChat" hx-trigger="load once" hx-swap="outerHTML"></hx>
{% if IsSubscribed or not IsLimiteReached %} {% if IsSubscribed or not IsLimiteReached %}

View File

@ -13,7 +13,7 @@
<div class="dropdown-item"> <div class="dropdown-item">
<div id="conversation-list"> <div id="conversation-list">
{% for Conversation in Conversations %} {% for Conversation in Conversations %}
<div class="icon-text has-text unselected icon-conv {% if Conversation.Name == 'Default' %} selected {% endif %}" <div class="icon-text has-text unselected icon-conv {% if Conversation.Selected %} selected {% endif %}"
data-id="{{ Conversation.ID.String() }}" style="cursor: pointer;" data-id="{{ Conversation.ID.String() }}" style="cursor: pointer;"
onclick="toggleConversationSelection(this)" onclick="toggleConversationSelection(this)"
hx-get="/selectConversation?conversation-id={{ Conversation.ID.String() }}" hx-swap="outerHTML" hx-get="/selectConversation?conversation-id={{ Conversation.ID.String() }}" hx-swap="outerHTML"