This commit is contained in:
Adrien Bouvais 2024-05-11 12:24:50 +02:00
parent 3061bf7837
commit 541cfa45a3

View File

@ -126,17 +126,19 @@ func insertNewConversation() edgedb.UUID {
func insertArea() edgedb.UUID {
// If the Default conversation doesn't exist, create it.
err := edgeClient.QuerySingle(edgeCtx, `
SELECT Conversation
FILTER .name = 'Default' AND .user = global currentUser
LIMIT 1
`, nil)
if err != nil {
var convExists bool
edgeClient.QuerySingle(edgeCtx, `
select exists (
select Conversation
filter .name = 'Default' AND .user = global currentUser
);
`, &convExists)
if !convExists {
insertNewConversation()
}
// Insert a new area.
var inserted struct{ id edgedb.UUID }
err = edgeClient.QuerySingle(edgeCtx, `
err := edgeClient.QuerySingle(edgeCtx, `
WITH
positionVar := count((SELECT Area FILTER .conversation.name = 'Default' AND .conversation.user = global currentUser)) + 1
INSERT Area {
@ -249,5 +251,5 @@ func getCurrentUserKeys() []Key {
func checkIfHaveKey() bool {
keys := getCurrentUserKeys()
return keys != nil && len(keys) > 0
return len(keys) > 0
}