Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/workspace.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use chrono::{DateTime, Utc};
use serde::Serialize;
use std::collections::HashSet;
use std::fmt::Display;

use super::{
Expand All @@ -17,18 +18,22 @@ pub async fn workspaces() -> Result<Vec<Workspace>> {
let response =
post_graphql::<queries::UserProjects, _>(&client, configs.get_backboard(), vars).await?;

// Member variants are yielded first so that a workspace the user both owns
// and is an external member of keeps the richer Member representation.
let mut seen: HashSet<String> = HashSet::new();
let mut workspaces: Vec<Workspace> = response
.me
.workspaces
.into_iter()
.map(Workspace::Member)
.chain(
response
.external_workspaces
.into_iter()
.map(Workspace::External),
)
.filter(|w| seen.insert(w.id().to_string()))
.collect();
workspaces.extend(
response
.external_workspaces
.into_iter()
.map(Workspace::External),
);
workspaces.sort_by(|a, b| b.id().cmp(a.id()));
Ok(workspaces)
}
Expand Down
Loading