diff --git a/ConnectorDynamo/ConnectorDynamo/ReceiveNode/Receive.cs b/ConnectorDynamo/ConnectorDynamo/ReceiveNode/Receive.cs index ddeeba7815..a3544486f6 100644 --- a/ConnectorDynamo/ConnectorDynamo/ReceiveNode/Receive.cs +++ b/ConnectorDynamo/ConnectorDynamo/ReceiveNode/Receive.cs @@ -12,7 +12,8 @@ using ProtoCore.AST.AssociativeAST; using Speckle.ConnectorDynamo.Functions; using Speckle.Core.Api; -using Speckle.Core.Api.SubscriptionModels; +using Speckle.Core.Api.GraphQL.Enums; +using Speckle.Core.Api.GraphQL.Models; using Speckle.Core.Credentials; using Speckle.Core.Logging; using Speckle.Core.Models.Extensions; @@ -456,8 +457,7 @@ internal void InitializeReceiver() { var account = Stream.GetAccount().Result; Client = new Client(account); - Client.SubscribeCommitCreated(Stream.StreamId); - Client.OnCommitCreated += OnCommitChange; + Client.Subscription.CreateProjectVersionsUpdatedSubscription(Stream.StreamId).Listeners += OnVersionChange; CheckIfBehind(); } @@ -597,14 +597,20 @@ protected virtual void RequestNewInputs() OnInputsChanged?.Invoke(); } - private void OnCommitChange(object sender, CommitInfo e) + private void OnVersionChange(object sender, ProjectVersionsUpdatedMessage e) { - if (e.branchName != (Stream.BranchName ?? "main")) + if (e.type != ProjectVersionsUpdatedMessageType.CREATED) { return; } - Task.Run(async () => GetExpiredObjectCount(e.objectId)); + var isSameBranch = e.version.model.name == (Stream.BranchName ?? "main") || e.version.model.id == Stream.BranchName; + if (!isSameBranch) + { + return; + } + + Task.Run(async () => GetExpiredObjectCount(e.version.referencedObject)); if (AutoUpdate) { OnNewDataAvail?.Invoke(); diff --git a/ConnectorGrasshopper/ConnectorGrasshopperShared/Ops/Operations.SyncReceiveComponent.cs b/ConnectorGrasshopper/ConnectorGrasshopperShared/Ops/Operations.SyncReceiveComponent.cs index 3912966101..d2b2bdd78e 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopperShared/Ops/Operations.SyncReceiveComponent.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopperShared/Ops/Operations.SyncReceiveComponent.cs @@ -9,7 +9,8 @@ using Grasshopper.Kernel.Types; using Rhino; using Speckle.Core.Api; -using Speckle.Core.Api.SubscriptionModels; +using Speckle.Core.Api.GraphQL.Enums; +using Speckle.Core.Api.GraphQL.Models; using Speckle.Core.Credentials; using Speckle.Core.Logging; using Speckle.Core.Models; @@ -112,14 +113,19 @@ private async Task ResetApiClient(StreamWrapper wrapper) ApiClient?.Dispose(); var acc = await wrapper.GetAccount(); ApiClient = new Client(acc); - ApiClient.SubscribeCommitCreated(StreamWrapper.StreamId); - ApiClient.OnCommitCreated += ApiClient_OnCommitCreated; + ApiClient.Subscription.CreateProjectVersionsUpdatedSubscription(StreamWrapper.StreamId).Listeners += + ApiClient_OnVersionUpdate; } - private void ApiClient_OnCommitCreated(object sender, CommitInfo e) + private void ApiClient_OnVersionUpdate(object sender, ProjectVersionsUpdatedMessage e) { // Break if wrapper is branch type and branch name is not equal. - if (StreamWrapper.Type == StreamWrapperType.Branch && e.branchName != StreamWrapper.BranchName) + if (StreamWrapper.Type == StreamWrapperType.Branch && e.modelId != StreamWrapper.BranchName) + { + return; + } + + if (e.type != ProjectVersionsUpdatedMessageType.CREATED) { return; } diff --git a/ConnectorGrasshopper/ConnectorGrasshopperShared/Ops/Operations.VariableInputReceiveComponent.cs b/ConnectorGrasshopper/ConnectorGrasshopperShared/Ops/Operations.VariableInputReceiveComponent.cs index 9b5b7d4190..7b9aca80d5 100644 --- a/ConnectorGrasshopper/ConnectorGrasshopperShared/Ops/Operations.VariableInputReceiveComponent.cs +++ b/ConnectorGrasshopper/ConnectorGrasshopperShared/Ops/Operations.VariableInputReceiveComponent.cs @@ -21,7 +21,8 @@ using GrasshopperAsyncComponent; using Rhino; using Speckle.Core.Api; -using Speckle.Core.Api.SubscriptionModels; +using Speckle.Core.Api.GraphQL.Enums; +using Speckle.Core.Api.GraphQL.Models; using Speckle.Core.Credentials; using Speckle.Core.Helpers; using Speckle.Core.Logging; @@ -577,8 +578,8 @@ public async Task ResetApiClient(StreamWrapper wrapper) ApiClient?.Dispose(); ApiClient = new Client(account); - ApiClient.SubscribeCommitCreated(StreamWrapper.StreamId); - ApiClient.OnCommitCreated += ApiClient_OnCommitCreated; + ApiClient.Subscription.CreateProjectVersionsUpdatedSubscription(StreamWrapper.StreamId).Listeners += + ApiClient_OnVersionUpdate; } catch (Exception e) when (!e.IsFatal()) { @@ -587,10 +588,18 @@ public async Task ResetApiClient(StreamWrapper wrapper) } } - private void ApiClient_OnCommitCreated(object sender, CommitInfo e) + private void ApiClient_OnVersionUpdate(object sender, ProjectVersionsUpdatedMessage e) { + if (e.type != ProjectVersionsUpdatedMessageType.CREATED) + { + return; + } + // Break if wrapper is branch type and branch name is not equal. - if (StreamWrapper.Type == StreamWrapperType.Branch && e.branchName != StreamWrapper.BranchName) + bool isCurrentBranch = + StreamWrapper.Type == StreamWrapperType.Branch + && (e.version?.model.name == StreamWrapper.BranchName || e.version?.model.id == StreamWrapper.BranchName); + if (!isCurrentBranch) { return; } diff --git a/ConnectorRevit/RevitSharedResources/Helpers/Extensions.cs b/ConnectorRevit/RevitSharedResources/Helpers/Extensions.cs index 7854aff3d1..4d57b80145 100644 --- a/ConnectorRevit/RevitSharedResources/Helpers/Extensions.cs +++ b/ConnectorRevit/RevitSharedResources/Helpers/Extensions.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Linq; using Autodesk.Revit.DB; diff --git a/Core/Core/Api/GraphQL/Legacy/Client.GraphqlCleintOperations/Client.ActivityOperations.cs b/Core/Core/Api/GraphQL/Legacy/Client.GraphqlCleintOperations/Client.ActivityOperations.cs index df43029474..d755e3e398 100644 --- a/Core/Core/Api/GraphQL/Legacy/Client.GraphqlCleintOperations/Client.ActivityOperations.cs +++ b/Core/Core/Api/GraphQL/Legacy/Client.GraphqlCleintOperations/Client.ActivityOperations.cs @@ -20,6 +20,7 @@ public partial class Client /// Max number of activity items to get /// /// + [Obsolete("Activity is no longer supported", true)] public async Task> StreamGetActivity( string id, DateTime? after = null, diff --git a/Core/Core/Api/GraphQL/Legacy/Client.GraphqlCleintOperations/Client.CommentOperations.cs b/Core/Core/Api/GraphQL/Legacy/Client.GraphqlCleintOperations/Client.CommentOperations.cs index aebce10af3..98f879e5f7 100644 --- a/Core/Core/Api/GraphQL/Legacy/Client.GraphqlCleintOperations/Client.CommentOperations.cs +++ b/Core/Core/Api/GraphQL/Legacy/Client.GraphqlCleintOperations/Client.CommentOperations.cs @@ -17,7 +17,7 @@ public partial class Client /// /// /// - [Obsolete($"Use client.{nameof(CommentResource)}.{nameof(CommentResource.GetProjectComments)}")] + [Obsolete($"Use client.{nameof(CommentResource)}.{nameof(CommentResource.GetProjectComments)}", true)] public async Task StreamGetComments( string streamId, int limit = 25, @@ -83,7 +83,7 @@ public async Task StreamGetComments( /// /// /// - [Obsolete($"Use client.{nameof(CommentResource)}.{nameof(CommentResource.GetProjectComments)}")] + [Obsolete($"Use client.{nameof(CommentResource)}.{nameof(CommentResource.GetProjectComments)}", true)] public async Task StreamGetCommentScreenshot( string id, string streamId, diff --git a/Core/Core/Api/GraphQL/Legacy/Client.GraphqlCleintOperations/Client.StreamOperations.cs b/Core/Core/Api/GraphQL/Legacy/Client.GraphqlCleintOperations/Client.StreamOperations.cs index dd7be354a3..257e0c0deb 100644 --- a/Core/Core/Api/GraphQL/Legacy/Client.GraphqlCleintOperations/Client.StreamOperations.cs +++ b/Core/Core/Api/GraphQL/Legacy/Client.GraphqlCleintOperations/Client.StreamOperations.cs @@ -162,13 +162,16 @@ public async Task> StreamsGet(int limit = 10, CancellationToken can return res.activeUser.streams.items; } - //TODO: API GAP /// /// Gets all favorite streams for the current user /// /// Max number of streams to return /// + /// + /// Favourite streams is no longer a feature + /// /// + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public async Task> FavoriteStreamsGet(int limit = 10, CancellationToken cancellationToken = default) { var request = new GraphQLRequest @@ -328,6 +331,7 @@ public async Task StreamDelete(string id, CancellationToken cancellationTo /// /// /// + [Obsolete($"Use client.{nameof(Project)}.{nameof(ProjectResource.UpdateRole)}", true)] public async Task StreamRevokePermission( StreamRevokePermissionInput permissionInput, CancellationToken cancellationToken = default @@ -354,7 +358,7 @@ public async Task StreamRevokePermission( /// /// /// - [Obsolete($"Use client.{nameof(Project)}.{nameof(ProjectResource.UpdateRole)}")] + [Obsolete($"Use client.{nameof(Project)}.{nameof(ProjectResource.UpdateRole)}", true)] public async Task StreamUpdatePermission( StreamPermissionInput updatePermissionInput, CancellationToken cancellationToken = default @@ -418,7 +422,7 @@ public async Task StreamGetPendingCollaborators( /// /// /// - [Obsolete($"Use client.{nameof(ProjectInvite)}.{nameof(ProjectInviteResource.Create)}")] + [Obsolete($"Use client.{nameof(ProjectInvite)}.{nameof(ProjectInviteResource.Create)}", true)] public async Task StreamInviteCreate( StreamInviteCreateInput inviteCreateInput, CancellationToken cancellationToken = default @@ -451,7 +455,7 @@ mutation streamInviteCreate($input: StreamInviteCreateInput!) { /// /// /// - [Obsolete($"Use client.{nameof(ProjectInvite)}.{nameof(ProjectInviteResource.Cancel)}")] + [Obsolete($"Use client.{nameof(ProjectInvite)}.{nameof(ProjectInviteResource.Cancel)}", true)] public async Task StreamInviteCancel( string streamId, string inviteId, @@ -482,7 +486,7 @@ mutation streamInviteCancel( $streamId: String!, $inviteId: String! ) { /// /// /// - [Obsolete($"Use client.{nameof(ProjectInvite)}.{nameof(ProjectInviteResource.Use)}")] + [Obsolete($"Use client.{nameof(ProjectInvite)}.{nameof(ProjectInviteResource.Use)}", true)] public async Task StreamInviteUse( string streamId, string token, @@ -515,7 +519,7 @@ mutation streamInviteUse( $accept: Boolean!, $streamId: String!, $token: String! /// /// /// - [Obsolete($"Use client.{nameof(ActiveUser)}.{nameof(ActiveUserResource.ProjectInvites)}")] + [Obsolete($"Use client.{nameof(ActiveUser)}.{nameof(ActiveUserResource.ProjectInvites)}", true)] public async Task> GetAllPendingInvites(CancellationToken cancellationToken = default) { var request = new GraphQLRequest diff --git a/Core/Core/Api/GraphQL/Legacy/Client.Subscriptions/Client.Subscriptions.Branch.cs b/Core/Core/Api/GraphQL/Legacy/Client.Subscriptions/Client.Subscriptions.Branch.cs index a27910a071..5c49475491 100644 --- a/Core/Core/Api/GraphQL/Legacy/Client.Subscriptions/Client.Subscriptions.Branch.cs +++ b/Core/Core/Api/GraphQL/Legacy/Client.Subscriptions/Client.Subscriptions.Branch.cs @@ -9,15 +9,20 @@ public partial class Client { #region BranchCreated + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public delegate void BranchCreatedHandler(object sender, BranchInfo e); + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public event BranchCreatedHandler OnBranchCreated; + + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public IDisposable BranchCreatedSubscription { get; private set; } /// /// Subscribe to events of branch created for a stream /// /// + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public void SubscribeBranchCreated(string streamId) { var request = new GraphQLRequest { Query = $@"subscription {{ branchCreated (streamId: ""{streamId}"") }}" }; @@ -28,22 +33,27 @@ public void SubscribeBranchCreated(string streamId) ); } + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public bool HasSubscribedBranchCreated => BranchCreatedSubscription != null; #endregion #region BranchUpdated - + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public delegate void BranchUpdatedHandler(object sender, BranchInfo e); + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public event BranchUpdatedHandler OnBranchUpdated; + + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public IDisposable BranchUpdatedSubscription { get; private set; } /// /// Subscribe to events of branch updated for a stream /// /// + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public void SubscribeBranchUpdated(string streamId, string branchId = null) { var request = new GraphQLRequest @@ -56,21 +66,26 @@ public void SubscribeBranchUpdated(string streamId, string branchId = null) ); } + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public bool HasSubscribedBranchUpdated => BranchUpdatedSubscription != null; #endregion #region BranchDeleted - + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public delegate void BranchDeletedHandler(object sender, BranchInfo e); + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public event BranchDeletedHandler OnBranchDeleted; + + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public IDisposable BranchDeletedSubscription { get; private set; } /// /// Subscribe to events of branch deleted for a stream /// /// + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public void SubscribeBranchDeleted(string streamId) { var request = new GraphQLRequest { Query = $@"subscription {{ branchDeleted (streamId: ""{streamId}"") }}" }; @@ -81,6 +96,7 @@ public void SubscribeBranchDeleted(string streamId) ); } + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public bool HasSubscribedBranchDeleted => BranchDeletedSubscription != null; #endregion diff --git a/Core/Core/Api/GraphQL/Legacy/Client.Subscriptions/Client.Subscriptions.Commit.cs b/Core/Core/Api/GraphQL/Legacy/Client.Subscriptions/Client.Subscriptions.Commit.cs index a3614ae68a..880de3df28 100644 --- a/Core/Core/Api/GraphQL/Legacy/Client.Subscriptions/Client.Subscriptions.Commit.cs +++ b/Core/Core/Api/GraphQL/Legacy/Client.Subscriptions/Client.Subscriptions.Commit.cs @@ -8,16 +8,20 @@ namespace Speckle.Core.Api; public partial class Client { #region CommitCreated - + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public delegate void CommitCreatedHandler(object sender, CommitInfo e); + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public event CommitCreatedHandler OnCommitCreated; + + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public IDisposable CommitCreatedSubscription; /// /// Subscribe to events of commit created for a stream /// /// + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public void SubscribeCommitCreated(string streamId) { var request = new GraphQLRequest { Query = $@"subscription {{ commitCreated (streamId: ""{streamId}"") }}" }; @@ -28,21 +32,26 @@ public void SubscribeCommitCreated(string streamId) ); } + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public bool HasSubscribedCommitCreated => CommitCreatedSubscription != null; #endregion #region CommitUpdated - + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public delegate void CommitUpdatedHandler(object sender, CommitInfo e); + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public event CommitUpdatedHandler OnCommitUpdated; + + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public IDisposable CommitUpdatedSubscription; /// /// Subscribe to events of commit updated for a stream /// /// + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public void SubscribeCommitUpdated(string streamId, string commitId = null) { var request = new GraphQLRequest @@ -57,21 +66,27 @@ public void SubscribeCommitUpdated(string streamId, string commitId = null) ); } + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public bool HasSubscribedCommitUpdated => CommitUpdatedSubscription != null; #endregion #region CommitDeleted - + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public delegate void CommitDeletedHandler(object sender, CommitInfo e); + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public event CommitDeletedHandler OnCommitDeleted; + + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public IDisposable CommitDeletedSubscription; /// /// Subscribe to events of commit updated for a stream /// + /// + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public void SubscribeCommitDeleted(string streamId) { var request = new GraphQLRequest { Query = $@"subscription {{ commitDeleted (streamId: ""{streamId}"") }}" }; @@ -81,6 +96,7 @@ public void SubscribeCommitDeleted(string streamId) ); } + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public bool HasSubscribedCommitDeleted => CommitDeletedSubscription != null; #endregion diff --git a/Core/Core/Api/GraphQL/Legacy/Client.Subscriptions/Client.Subscriptions.Stream.cs b/Core/Core/Api/GraphQL/Legacy/Client.Subscriptions/Client.Subscriptions.Stream.cs index a62e757fd6..328fc8ec76 100644 --- a/Core/Core/Api/GraphQL/Legacy/Client.Subscriptions/Client.Subscriptions.Stream.cs +++ b/Core/Core/Api/GraphQL/Legacy/Client.Subscriptions/Client.Subscriptions.Stream.cs @@ -8,16 +8,20 @@ namespace Speckle.Core.Api; public partial class Client { #region UserStreamAdded - + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public delegate void UserStreamAddedHandler(object sender, StreamInfo e); + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public event UserStreamAddedHandler OnUserStreamAdded; + + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public IDisposable UserStreamAddedSubscription; /// /// Subscribe to events of streams added for the current user /// /// + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public void SubscribeUserStreamAdded() { var request = new GraphQLRequest { Query = @"subscription { userStreamAdded }" }; @@ -28,21 +32,26 @@ public void SubscribeUserStreamAdded() ); } + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public bool HasSubscribedUserStreamAdded => UserStreamAddedSubscription != null; #endregion #region StreamUpdated - + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public delegate void StreamUpdatedHandler(object sender, StreamInfo e); + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public event StreamUpdatedHandler OnStreamUpdated; + + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public IDisposable StreamUpdatedSubscription; /// /// Subscribe to events of streams updated for a specific streamId /// /// streamId + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public void SubscribeStreamUpdated(string id) { var request = new GraphQLRequest { Query = $@"subscription {{ streamUpdated( streamId: ""{id}"") }}" }; @@ -52,20 +61,25 @@ public void SubscribeStreamUpdated(string id) ); } + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public bool HasSubscribedStreamUpdated => StreamUpdatedSubscription != null; #endregion #region StreamRemoved - + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public delegate void UserStreamRemovedHandler(object sender, StreamInfo e); + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public event UserStreamRemovedHandler OnUserStreamRemoved; + + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public IDisposable UserStreamRemovedSubscription; /// /// Subscribe to events of streams removed for the current user /// + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public void SubscribeUserStreamRemoved() { var request = new GraphQLRequest { Query = @"subscription { userStreamRemoved }" }; @@ -76,21 +90,26 @@ public void SubscribeUserStreamRemoved() ); } + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public bool HasSubscribedUserStreamRemoved => UserStreamRemovedSubscription != null; #endregion #region CommentActivity - + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public delegate void CommentActivityHandler(object sender, CommentItem e); + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public event CommentActivityHandler OnCommentActivity; + + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public IDisposable CommentActivitySubscription; /// /// Subscribe to new comment events /// /// + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public void SubscribeCommentActivity(string streamId) { var request = new GraphQLRequest @@ -104,6 +123,7 @@ public void SubscribeCommentActivity(string streamId) ); } + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE, true)] public bool HasSubscribedCommentActivity => CommentActivitySubscription != null; #endregion diff --git a/Core/Core/Api/GraphQL/Legacy/LegacyGraphQLModels.cs b/Core/Core/Api/GraphQL/Legacy/LegacyGraphQLModels.cs index 5dcff259f6..97db9ded75 100644 --- a/Core/Core/Api/GraphQL/Legacy/LegacyGraphQLModels.cs +++ b/Core/Core/Api/GraphQL/Legacy/LegacyGraphQLModels.cs @@ -10,11 +10,11 @@ namespace Speckle.Core.Api; internal static class DeprecationMessages { - public const string FE2_DEPRECATION_MESSAGE = + public const string FE1_DEPRECATION_MESSAGE = $"Stream/Branch/Commit API is now deprecated, Use the new Project/Model/Version API functions in {nameof(Client)}"; } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class StreamCreateInput { public string name { get; set; } @@ -22,7 +22,7 @@ public class StreamCreateInput public bool isPublic { get; set; } = true; } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class StreamUpdateInput { public string id { get; set; } @@ -31,7 +31,7 @@ public class StreamUpdateInput public bool isPublic { get; set; } = true; } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class StreamPermissionInput { public string streamId { get; set; } @@ -39,14 +39,14 @@ public class StreamPermissionInput public string role { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class StreamRevokePermissionInput { public string streamId { get; set; } public string userId { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class StreamInviteCreateInput { public string streamId { get; set; } @@ -56,7 +56,7 @@ public class StreamInviteCreateInput public string role { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class BranchCreateInput { public string streamId { get; set; } @@ -64,7 +64,7 @@ public class BranchCreateInput public string description { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class BranchUpdateInput { public string streamId { get; set; } @@ -73,7 +73,7 @@ public class BranchUpdateInput public string description { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class BranchDeleteInput { public string streamId { get; set; } @@ -94,7 +94,7 @@ public class CommitCreateInput public List previousCommitIds { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class CommitUpdateInput { public string streamId { get; set; } @@ -102,14 +102,14 @@ public class CommitUpdateInput public string message { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class CommitDeleteInput { public string streamId { get; set; } public string id { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class CommitReceivedInput { public string streamId { get; set; } @@ -120,7 +120,7 @@ public class CommitReceivedInput #endregion -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class Stream { public string id { get; set; } @@ -165,7 +165,7 @@ public override string ToString() } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class Collaborator { public string id { get; set; } @@ -179,13 +179,13 @@ public override string ToString() } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class StreamInvitesResponse { public List streamInvites { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class Branches { public int totalCount { get; set; } @@ -193,7 +193,7 @@ public class Branches public List items { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class Commits { public int totalCount { get; set; } @@ -201,7 +201,7 @@ public class Commits public List items { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class Commit { public string id { get; set; } @@ -257,7 +257,7 @@ public class InfoCommit public string branchName { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class SpeckleObject { public string id { get; set; } @@ -267,7 +267,7 @@ public class SpeckleObject public DateTime createdAt { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class Branch { public string id { get; set; } @@ -281,7 +281,7 @@ public override string ToString() } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class Streams { public int totalCount { get; set; } @@ -289,14 +289,14 @@ public class Streams public List items { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class Resource { public string resourceId { get; set; } public ResourceType resourceType { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class Location { public double x { get; set; } @@ -304,33 +304,33 @@ public class Location public double z { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class UserSearchData { public UserSearch userSearch { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class UserSearch { public string cursor { get; set; } public List items { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class StreamData { public Stream stream { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class StreamsData { public Streams streams { get; set; } } #region comments -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class Comments { public int totalCount { get; set; } @@ -338,7 +338,7 @@ public class Comments public List items { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public sealed class CommentData { public Comments comments { get; init; } @@ -349,7 +349,7 @@ public sealed class CommentData public object sectionBox { get; init; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class CommentItem { public string id { get; set; } @@ -366,7 +366,7 @@ public class CommentItem public List resources { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class ContentContent { public string Type { get; set; } @@ -375,26 +375,26 @@ public class ContentContent public string Text { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class CommentsData { public Comments comments { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class CommentItemData { public CommentItem comment { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class CommentActivityMessage { public string type { get; set; } public CommentItem comment { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class CommentActivityResponse { public CommentActivityMessage commentActivity { get; set; } diff --git a/Core/Core/Api/GraphQL/Legacy/SubscriptionModels.cs b/Core/Core/Api/GraphQL/Legacy/SubscriptionModels.cs index f330899f23..1594b44f6b 100644 --- a/Core/Core/Api/GraphQL/Legacy/SubscriptionModels.cs +++ b/Core/Core/Api/GraphQL/Legacy/SubscriptionModels.cs @@ -5,7 +5,7 @@ namespace Speckle.Core.Api.SubscriptionModels; #region streams -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class StreamInfo { public string id { get; set; } @@ -14,19 +14,19 @@ public class StreamInfo public string sharedBy { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class UserStreamAddedResult { public StreamInfo userStreamAdded { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class StreamUpdatedResult { public StreamInfo streamUpdated { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class UserStreamRemovedResult { public StreamInfo userStreamRemoved { get; set; } @@ -35,7 +35,7 @@ public class UserStreamRemovedResult #region branches -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class BranchInfo { public string id { get; set; } @@ -45,19 +45,19 @@ public class BranchInfo public string authorId { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class BranchCreatedResult { public BranchInfo branchCreated { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class BranchUpdatedResult { public BranchInfo branchUpdated { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class BranchDeletedResult { public BranchInfo branchDeleted { get; set; } @@ -66,7 +66,7 @@ public class BranchDeletedResult #region commits -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class CommitInfo { public string id { get; set; } @@ -83,19 +83,19 @@ public class CommitInfo public IList previousCommitIds { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class CommitCreatedResult { public CommitInfo commitCreated { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class CommitUpdatedResult { public CommitInfo commitUpdated { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class CommitDeletedResult { public CommitInfo commitDeleted { get; set; } diff --git a/Core/Core/Api/GraphQL/Models/Comment.cs b/Core/Core/Api/GraphQL/Models/Comment.cs index 75da443dd3..96db9c9db6 100644 --- a/Core/Core/Api/GraphQL/Models/Comment.cs +++ b/Core/Core/Api/GraphQL/Models/Comment.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; +using Speckle.Newtonsoft.Json; namespace Speckle.Core.Api.GraphQL.Models; @@ -22,4 +23,33 @@ public sealed class Comment public DateTime updatedAt { get; init; } public DateTime? viewedAt { get; init; } public List viewerResources { get; init; } + public ViewerState viewerState { get; init; } +} + +/// +/// See SerializedViewerState in /shared/src/viewer/helpers/state.ts +/// +/// +/// Note, there are many FE/Viewer specific properties on this object that are not reflected here (hence the override) +/// We can add them as needed, keeping in mind flexiblity for breaking changes (these classes are intentionally not documented in our schema!) +/// +[JsonObject(MissingMemberHandling = MissingMemberHandling.Ignore)] +public sealed class ViewerState +{ + public ViewerStateUI ui { get; init; } +} + +[JsonObject(MissingMemberHandling = MissingMemberHandling.Ignore)] +public sealed class ViewerStateUI +{ + public ViewerStateCamera camera { get; init; } +} + +[JsonObject(MissingMemberHandling = MissingMemberHandling.Ignore)] +public sealed class ViewerStateCamera +{ + public List position { get; init; } + public List target { get; init; } + public bool isOrthoProjection { get; init; } + public double zoom { get; init; } } diff --git a/Core/Core/Api/GraphQL/Models/FileUpload.cs b/Core/Core/Api/GraphQL/Models/FileUpload.cs index 8327e24817..eb27a765d4 100644 --- a/Core/Core/Api/GraphQL/Models/FileUpload.cs +++ b/Core/Core/Api/GraphQL/Models/FileUpload.cs @@ -22,9 +22,9 @@ public sealed class FileUpload public DateTime uploadDate { get; init; } public string userId { get; init; } - [Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public string branchName { get; init; } - [Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public string streamId { get; init; } } diff --git a/Core/Core/Api/GraphQL/Models/PendingStreamCollaborator.cs b/Core/Core/Api/GraphQL/Models/PendingStreamCollaborator.cs index 805c0231ba..2fee670570 100644 --- a/Core/Core/Api/GraphQL/Models/PendingStreamCollaborator.cs +++ b/Core/Core/Api/GraphQL/Models/PendingStreamCollaborator.cs @@ -17,9 +17,9 @@ public sealed class PendingStreamCollaborator public LimitedUser user { get; init; } public string token { get; init; } - [Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public string streamId { get; init; } - [Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public string streamName { get; init; } } diff --git a/Core/Core/Api/GraphQL/Models/User.cs b/Core/Core/Api/GraphQL/Models/User.cs index f3d6b26863..349d026c71 100644 --- a/Core/Core/Api/GraphQL/Models/User.cs +++ b/Core/Core/Api/GraphQL/Models/User.cs @@ -18,10 +18,10 @@ public abstract class UserBase public int totalOwnedStreamsFavorites { get; init; } public bool? verified { get; init; } - [Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public ResourceCollection commits { get; init; } - [Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public ResourceCollection streams { get; init; } } @@ -42,7 +42,7 @@ public sealed class User : UserBase public List projectInvites { get; init; } public ResourceCollection projects { get; init; } - [Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public ResourceCollection favoriteStreams { get; init; } public override string ToString() diff --git a/Core/Core/Api/GraphQL/Resources/CommentResource.cs b/Core/Core/Api/GraphQL/Resources/CommentResource.cs index 72722468f4..1e078e204c 100644 --- a/Core/Core/Api/GraphQL/Resources/CommentResource.cs +++ b/Core/Core/Api/GraphQL/Resources/CommentResource.cs @@ -79,6 +79,7 @@ query CommentThreads($projectId: String!, $cursor: String, $limit: Int!, $filter objectId versionId } + viewerState data } } diff --git a/Core/Core/Api/GraphQL/Resources/SubscriptionResource.cs b/Core/Core/Api/GraphQL/Resources/SubscriptionResource.cs index d476ae71e0..fded4aba95 100644 --- a/Core/Core/Api/GraphQL/Resources/SubscriptionResource.cs +++ b/Core/Core/Api/GraphQL/Resources/SubscriptionResource.cs @@ -195,6 +195,14 @@ subscription ProjectVersionsUpdated($id: String!) { role avatar } + model{ + id + name + description + displayName + updatedAt + createdAt + } } } } diff --git a/Core/Core/Credentials/Responses.cs b/Core/Core/Credentials/Responses.cs index 212173f6bd..5e6b29d7e7 100644 --- a/Core/Core/Credentials/Responses.cs +++ b/Core/Core/Credentials/Responses.cs @@ -24,20 +24,20 @@ public sealed class UserInfo public string? company { get; init; } public string? avatar { get; init; } - [Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public Streams streams { get; init; } - [Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] + [Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public Commits commits { get; init; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class Streams { public int totalCount { get; set; } } -[Obsolete(DeprecationMessages.FE2_DEPRECATION_MESSAGE)] +[Obsolete(DeprecationMessages.FE1_DEPRECATION_MESSAGE)] public class Commits { public int totalCount { get; set; } diff --git a/Core/Tests/Speckle.Core.Tests.Integration/Api/GraphQL/Legacy/LegacyAPITests.cs b/Core/Tests/Speckle.Core.Tests.Integration/Api/GraphQL/Legacy/LegacyAPITests.cs index 46b87d799d..94df6d9a18 100644 --- a/Core/Tests/Speckle.Core.Tests.Integration/Api/GraphQL/Legacy/LegacyAPITests.cs +++ b/Core/Tests/Speckle.Core.Tests.Integration/Api/GraphQL/Legacy/LegacyAPITests.cs @@ -1,5 +1,4 @@ using Speckle.Core.Api; -using Speckle.Core.Api.GraphQL; using Speckle.Core.Credentials; using Speckle.Core.Models; using Speckle.Core.Tests.Unit.Kits; @@ -135,91 +134,91 @@ public async Task StreamUpdate() Assert.That(res, Is.True); } - [Test, Order(31)] - public async Task StreamInviteCreate() - { - var res = await _myClient.StreamInviteCreate( - new StreamInviteCreateInput - { - streamId = _streamId, - email = _secondUserAccount.userInfo.email, - message = "Whasssup!" - } - ); - - Assert.That(res, Is.True); - - Assert.ThrowsAsync( - async () => await _myClient.StreamInviteCreate(new StreamInviteCreateInput { streamId = _streamId }) - ); - } - - [Test, Order(32)] - public async Task StreamInviteGet() - { - var invites = await _secondClient.GetAllPendingInvites(); - - Assert.That(invites, Is.Not.Null); - } - - [Test, Order(33)] - public async Task StreamInviteUse() - { - var invites = await _secondClient.GetAllPendingInvites(); - - var res = await _secondClient.StreamInviteUse(invites[0].streamId, invites[0].token); - - Assert.That(res, Is.True); - } - - [Test, Order(34)] - public async Task StreamUpdatePermission() - { - var res = await _myClient.StreamUpdatePermission( - new StreamPermissionInput - { - role = StreamRoles.STREAM_REVIEWER, - streamId = _streamId, - userId = _secondUserAccount.userInfo.id - } - ); - - Assert.That(res, Is.True); - } - - [Test, Order(40)] - public async Task StreamRevokePermission() - { - var res = await _myClient.StreamRevokePermission( - new StreamRevokePermissionInput { streamId = _streamId, userId = _secondUserAccount.userInfo.id } - ); - - Assert.That(res, Is.True); - } - - #region activity - - [Test, Order(51)] - public async Task StreamGetActivity() - { - var res = await _myClient.StreamGetActivity(_streamId); - - Assert.That(res, Is.Not.Null); - //Assert.AreEqual(commitId, res[0].); - } - - #endregion + // [Test, Order(31)] + // public async Task StreamInviteCreate() + // { + // var res = await _myClient.StreamInviteCreate( + // new StreamInviteCreateInput + // { + // streamId = _streamId, + // email = _secondUserAccount.userInfo.email, + // message = "Whasssup!" + // } + // ); + // + // Assert.That(res, Is.True); + // + // Assert.ThrowsAsync( + // async () => await _myClient.StreamInviteCreate(new StreamInviteCreateInput { streamId = _streamId }) + // ); + // } + + // [Test, Order(32)] + // public async Task StreamInviteGet() + // { + // var invites = await _secondClient.GetAllPendingInvites(); + // + // Assert.That(invites, Is.Not.Null); + // } + // + // [Test, Order(33)] + // public async Task StreamInviteUse() + // { + // var invites = await _secondClient.GetAllPendingInvites(); + // + // var res = await _secondClient.StreamInviteUse(invites[0].streamId, invites[0].token); + // + // Assert.That(res, Is.True); + // } + + // [Test, Order(34)] + // public async Task StreamUpdatePermission() + // { + // var res = await _myClient.StreamUpdatePermission( + // new StreamPermissionInput + // { + // role = StreamRoles.STREAM_REVIEWER, + // streamId = _streamId, + // userId = _secondUserAccount.userInfo.id + // } + // ); + // + // Assert.That(res, Is.True); + // } + // + // [Test, Order(40)] + // public async Task StreamRevokePermission() + // { + // var res = await _myClient.StreamRevokePermission( + // new StreamRevokePermissionInput { streamId = _streamId, userId = _secondUserAccount.userInfo.id } + // ); + // + // Assert.That(res, Is.True); + // } + + // #region activity + // + // [Test, Order(51)] + // public async Task StreamGetActivity() + // { + // var res = await _myClient.StreamGetActivity(_streamId); + // + // Assert.That(res, Is.Not.Null); + // //Assert.AreEqual(commitId, res[0].); + // } + // + // #endregion #region comments - [Test, Order(52)] - public async Task StreamGetComments() - { - var res = await _myClient.StreamGetActivity(_streamId); - - Assert.That(res, Is.Not.Null); - //Assert.AreEqual(commitId, res[0].); - } + // [Test, Order(52)] + // public async Task StreamGetComments() + // { + // var res = await _myClient.StreamGetActivity(_streamId); + // + // Assert.That(res, Is.Not.Null); + // //Assert.AreEqual(commitId, res[0].); + // } #endregion diff --git a/Core/Tests/Speckle.Core.Tests.Integration/Api/GraphQL/Legacy/Subscriptions/Branches.cs b/Core/Tests/Speckle.Core.Tests.Integration/Api/GraphQL/Legacy/Subscriptions/Branches.cs deleted file mode 100644 index 2833a279c1..0000000000 --- a/Core/Tests/Speckle.Core.Tests.Integration/Api/GraphQL/Legacy/Subscriptions/Branches.cs +++ /dev/null @@ -1,122 +0,0 @@ -using Speckle.Core.Api; -using Speckle.Core.Api.SubscriptionModels; -using Speckle.Core.Credentials; - -namespace Speckle.Core.Tests.Integration.Api.GraphQL.Legacy.Subscriptions; - -public class Branches : IDisposable -{ - private BranchInfo _branchCreatedInfo; - private BranchInfo _branchDeletedInfo; - private string _branchId; - private BranchInfo _branchUpdatedInfo; - private Client _client; - private string _streamId; - private Account _testUserAccount; - - [OneTimeSetUp] - public async Task Setup() - { - _testUserAccount = await Fixtures.SeedUser(); - _client = new Client(_testUserAccount); - } - - [Test, Order(0)] - public async Task SubscribeBranchCreated() - { - var streamInput = new StreamCreateInput { description = "Hello World", name = "Super Stream 01" }; - - _streamId = await _client.StreamCreate(streamInput); - Assert.That(_streamId, Is.Not.Null); - - _client.SubscribeBranchCreated(_streamId); - _client.OnBranchCreated += Client_OnBranchCreated; - - Thread.Sleep(5000); //let server catch-up - - var branchInput = new BranchCreateInput - { - description = "Just testing branch create...", - name = "awesome-features", - streamId = _streamId - }; - - _branchId = await _client.BranchCreate(branchInput); - Assert.That(_branchId, Is.Not.Null); - - await Task.Run(() => - { - Thread.Sleep(1000); //let client catch-up - Assert.That(_branchCreatedInfo, Is.Not.Null); - Assert.That(_branchCreatedInfo.name, Is.EqualTo(branchInput.name)); - }); - } - - private void Client_OnBranchCreated(object sender, BranchInfo e) - { - _branchCreatedInfo = e; - } - - [Test, Order(1)] - public async Task SubscribeBranchUpdated() - { - _client.SubscribeBranchUpdated(_streamId); - _client.OnBranchUpdated += Client_OnBranchUpdated; - - Thread.Sleep(1000); //let server catch-up - - var branchInput = new BranchUpdateInput - { - description = "Just testing branch bpdate...", - name = "cool-features", - streamId = _streamId, - id = _branchId - }; - - var res = await _client.BranchUpdate(branchInput); - Assert.That(res, Is.True); - - await Task.Run(() => - { - Thread.Sleep(1000); //let client catch-up - Assert.That(_branchUpdatedInfo, Is.Not.Null); - Assert.That(_branchUpdatedInfo.name, Is.EqualTo(branchInput.name)); - }); - } - - private void Client_OnBranchUpdated(object sender, BranchInfo e) - { - _branchUpdatedInfo = e; - } - - [Test, Order(3)] - public async Task SubscribeBranchDeleted() - { - _client.SubscribeBranchDeleted(_streamId); - _client.OnBranchDeleted += Client_OnBranchDeleted; - - Thread.Sleep(1000); //let server catch-up - - var branchInput = new BranchDeleteInput { streamId = _streamId, id = _branchId }; - - var res = await _client.BranchDelete(branchInput); - Assert.That(res, Is.True); - - await Task.Run(() => - { - Thread.Sleep(1000); //let client catch-up - Assert.That(_branchDeletedInfo, Is.Not.Null); - Assert.That(_branchDeletedInfo.id, Is.EqualTo(_branchId)); - }); - } - - private void Client_OnBranchDeleted(object sender, BranchInfo e) - { - _branchDeletedInfo = e; - } - - public void Dispose() - { - _client?.Dispose(); - } -} diff --git a/Core/Tests/Speckle.Core.Tests.Integration/Api/GraphQL/Legacy/Subscriptions/Commits.cs b/Core/Tests/Speckle.Core.Tests.Integration/Api/GraphQL/Legacy/Subscriptions/Commits.cs deleted file mode 100644 index 7e25fad641..0000000000 --- a/Core/Tests/Speckle.Core.Tests.Integration/Api/GraphQL/Legacy/Subscriptions/Commits.cs +++ /dev/null @@ -1,161 +0,0 @@ -using Speckle.Core.Api; -using Speckle.Core.Api.SubscriptionModels; -using Speckle.Core.Credentials; -using Speckle.Core.Models; -using Speckle.Core.Tests.Unit.Kits; -using Speckle.Core.Transports; - -namespace Speckle.Core.Tests.Integration.Api.GraphQL.Legacy.Subscriptions; - -public class Commits : IDisposable -{ - private Client _client; - private CommitInfo _commitCreatedInfo; - private CommitInfo _commitDeletedInfo; - private string _commitId; - private CommitInfo _commitUpdatedInfo; - private ServerTransport _myServerTransport; - private string _streamId; - private Account _testUserAccount; - - [OneTimeSetUp] - public async Task Setup() - { - _testUserAccount = await Fixtures.SeedUser(); - _client = new Client(_testUserAccount); - } - - private void InitServerTransport() - { - _myServerTransport = new ServerTransport(_testUserAccount, _streamId); - _myServerTransport.Api.CompressPayloads = false; - } - - [Test, Order(0)] - //[Ignore("Ironically, it fails.")] - public async Task SubscribeCommitCreated() - { - var streamInput = new StreamCreateInput { description = "Hello World", name = "Super Stream 01" }; - - _streamId = await _client.StreamCreate(streamInput); - Assert.That(_streamId, Is.Not.Null); - - InitServerTransport(); - - var branchInput = new BranchCreateInput - { - description = "Just testing branch create...", - name = "awesome-features", - streamId = _streamId - }; - - var branchId = await _client.BranchCreate(branchInput); - Assert.That(branchId, Is.Not.Null); - - _client.SubscribeCommitCreated(_streamId); - _client.OnCommitCreated += Client_OnCommitCreated; - - Thread.Sleep(1000); //let server catch-up - - var myObject = new Base(); - var ptsList = new List(); - for (int i = 0; i < 100; i++) - { - ptsList.Add(new Point(i, i, i)); - } - - myObject["Points"] = ptsList; - - var objectId = await Operations.Send(myObject, _myServerTransport, false); - - var commitInput = new CommitCreateInput - { - streamId = _streamId, - branchName = "awesome-features", - objectId = objectId, - message = "sending some test points", - sourceApplication = "Tests", - totalChildrenCount = 20 - }; - - _commitId = await _client.CommitCreate(commitInput); - Assert.That(_commitId, Is.Not.Null); - - await Task.Run(() => - { - Thread.Sleep(2000); //let client catch-up - Assert.That(_commitCreatedInfo, Is.Not.Null); - Assert.That(_commitCreatedInfo.message, Is.EqualTo(commitInput.message)); - }); - } - - private void Client_OnCommitCreated(object sender, CommitInfo e) - { - _commitCreatedInfo = e; - } - - [Test, Order(1)] - //[Ignore("Ironically, it fails.")] - public async Task SubscribeCommitUpdated() - { - _client.SubscribeCommitUpdated(_streamId); - _client.OnCommitUpdated += Client_OnCommitUpdated; - - Thread.Sleep(1000); //let server catch-up - - var commitInput = new CommitUpdateInput - { - message = "Just testing commit update...", - streamId = _streamId, - id = _commitId - }; - - var res = await _client.CommitUpdate(commitInput); - Assert.That(res, Is.True); - - await Task.Run(() => - { - Thread.Sleep(2000); //let client catch-up - Assert.That(_commitUpdatedInfo, Is.Not.Null); - Assert.That(_commitUpdatedInfo.message, Is.EqualTo(commitInput.message)); - }); - } - - private void Client_OnCommitUpdated(object sender, CommitInfo e) - { - _commitUpdatedInfo = e; - } - - [Test, Order(3)] - //[Ignore("Ironically, it fails.")] - public async Task SubscribeCommitDeleted() - { - _client.SubscribeCommitDeleted(_streamId); - _client.OnCommitDeleted += Client_OnCommitDeleted; - - Thread.Sleep(1000); //let server catch-up - - var commitInput = new CommitDeleteInput { streamId = _streamId, id = _commitId }; - - var res = await _client.CommitDelete(commitInput); - Assert.That(res, Is.True); - - await Task.Run(() => - { - Thread.Sleep(2000); //let client catch-up - Assert.That(_commitDeletedInfo, Is.Not.Null); - Assert.That(_commitDeletedInfo.id, Is.EqualTo(_commitId)); - }); - } - - private void Client_OnCommitDeleted(object sender, CommitInfo e) - { - _commitDeletedInfo = e; - } - - public void Dispose() - { - _client?.Dispose(); - _myServerTransport?.Dispose(); - } -} diff --git a/Core/Tests/Speckle.Core.Tests.Integration/Api/GraphQL/Legacy/Subscriptions/Streams.cs b/Core/Tests/Speckle.Core.Tests.Integration/Api/GraphQL/Legacy/Subscriptions/Streams.cs deleted file mode 100644 index 457c2d6b41..0000000000 --- a/Core/Tests/Speckle.Core.Tests.Integration/Api/GraphQL/Legacy/Subscriptions/Streams.cs +++ /dev/null @@ -1,113 +0,0 @@ -using Speckle.Core.Api; -using Speckle.Core.Api.SubscriptionModels; -using Speckle.Core.Credentials; - -namespace Speckle.Core.Tests.Integration.Api.GraphQL.Legacy.Subscriptions; - -public class Streams : IDisposable -{ - private Client _client; - - private StreamInfo _streamAddedInfo; - private string _streamId; - private StreamInfo _streamRemovedInfo; - private StreamInfo _streamUpdatedInfo; - private Account _testUserAccount; - - [OneTimeSetUp] - public async Task Setup() - { - _testUserAccount = await Fixtures.SeedUser(); - _client = new Client(_testUserAccount); - } - - [Test, Order(0)] - public async Task SubscribeStreamAdded() - { - _client.SubscribeUserStreamAdded(); - _client.OnUserStreamAdded += Client_OnUserStreamAdded; - - Thread.Sleep(1000); //let server catch-up - - var streamInput = new StreamCreateInput { description = "Hello World", name = "Super Stream 01" }; - - var res = await _client.StreamCreate(streamInput); - _streamId = res; - Assert.That(res, Is.Not.Null); - - await Task.Run(() => - { - Thread.Sleep(1000); //let client catch-up - Assert.That(_streamAddedInfo, Is.Not.Null); - Assert.That(_streamAddedInfo.name, Is.EqualTo(streamInput.name)); - }); - } - - private void Client_OnUserStreamAdded(object sender, StreamInfo e) - { - _streamAddedInfo = e; - } - - [Test, Order(1)] - public async Task SubscribeStreamUpdated() - { - _client.SubscribeStreamUpdated(_streamId); - _client.OnStreamUpdated += Client_OnStreamUpdated; - - Thread.Sleep(100); //let server catch-up - - var streamInput = new StreamUpdateInput - { - id = _streamId, - description = "Hello World", - name = "Super Stream 01 EDITED" - }; - - var res = await _client.StreamUpdate(streamInput); - - Assert.That(res, Is.True); - - await Task.Run(() => - { - Thread.Sleep(100); //let client catch-up - Assert.That(_streamUpdatedInfo, Is.Not.Null); - Assert.That(_streamUpdatedInfo.name, Is.EqualTo(streamInput.name)); - }); - } - - private void Client_OnStreamUpdated(object sender, StreamInfo e) - { - _streamUpdatedInfo = e; - } - - [Test, Order(2)] - public async Task SubscribeUserStreamRemoved() - { - _client.SubscribeUserStreamRemoved(); - _client.OnUserStreamRemoved += Client_OnStreamRemoved; - ; - - Thread.Sleep(100); //let server catch-up - - var res = await _client.StreamDelete(_streamId); - - Assert.That(res, Is.True); - - await Task.Run(() => - { - Thread.Sleep(100); //let client catch-up - Assert.That(_streamRemovedInfo, Is.Not.Null); - Assert.That(_streamRemovedInfo.id, Is.EqualTo(_streamId)); - }); - } - - private void Client_OnStreamRemoved(object sender, StreamInfo e) - { - _streamRemovedInfo = e; - } - - public void Dispose() - { - _client?.Dispose(); - } -} diff --git a/Core/Tests/Speckle.Core.Tests.Integration/Fixtures.cs b/Core/Tests/Speckle.Core.Tests.Integration/Fixtures.cs index 0d1886a7d0..bf8b502951 100644 --- a/Core/Tests/Speckle.Core.Tests.Integration/Fixtures.cs +++ b/Core/Tests/Speckle.Core.Tests.Integration/Fixtures.cs @@ -4,7 +4,6 @@ using System.Web; using Newtonsoft.Json; using Speckle.Core.Api; -using Speckle.Core.Api.GraphQL.Inputs; using Speckle.Core.Api.GraphQL.Models; using Speckle.Core.Credentials; using Speckle.Core.Logging; diff --git a/Core/Tests/Speckle.Core.Tests.Unit/Helpers/Path.cs b/Core/Tests/Speckle.Core.Tests.Unit/Helpers/Path.cs index 333954e93e..7878ab510c 100644 --- a/Core/Tests/Speckle.Core.Tests.Unit/Helpers/Path.cs +++ b/Core/Tests/Speckle.Core.Tests.Unit/Helpers/Path.cs @@ -1,5 +1,4 @@ using System.Runtime.InteropServices; -using System.Text.RegularExpressions; using NUnit.Framework; using Speckle.Core.Helpers; diff --git a/Core/Tests/Speckle.Core.Tests.Unit/Logging/SpeckleLogTests.cs b/Core/Tests/Speckle.Core.Tests.Unit/Logging/SpeckleLogTests.cs index 6a97323345..22b703300c 100644 --- a/Core/Tests/Speckle.Core.Tests.Unit/Logging/SpeckleLogTests.cs +++ b/Core/Tests/Speckle.Core.Tests.Unit/Logging/SpeckleLogTests.cs @@ -1,6 +1,5 @@ using NUnit.Framework; using Serilog.Context; -using Serilog.Core; using Serilog.Events; using Speckle.Core.Logging; diff --git a/DesktopUI2/DesktopUI2/ViewModels/CollaboratorsViewModel.cs b/DesktopUI2/DesktopUI2/ViewModels/CollaboratorsViewModel.cs index 80600b8d8f..d86f39bc50 100644 --- a/DesktopUI2/DesktopUI2/ViewModels/CollaboratorsViewModel.cs +++ b/DesktopUI2/DesktopUI2/ViewModels/CollaboratorsViewModel.cs @@ -12,7 +12,7 @@ using DesktopUI2.Views.Controls; using DesktopUI2.Views.Windows.Dialogs; using ReactiveUI; -using Speckle.Core.Api; +using Speckle.Core.Api.GraphQL.Inputs; using Speckle.Core.Helpers; using Speckle.Core.Logging; @@ -44,20 +44,21 @@ public CollaboratorsViewModel(IScreen screen, StreamViewModel stream) internal void ReloadUsers() { - AddedUsers = new ObservableCollection(); + var newAddedUsers = new ObservableCollection(); foreach (var collab in _stream.Stream.collaborators) //skip myself //if (_stream.StreamState.Client.Account.userInfo.id == collab.id) // continue; { - AddedUsers.Add(new AccountViewModel(collab)); + newAddedUsers.Add(new AccountViewModel(collab)); } foreach (var collab in _stream.Stream.pendingCollaborators) { - AddedUsers.Add(new AccountViewModel(collab)); + newAddedUsers.Add(new AccountViewModel(collab)); } + AddedUsers = newAddedUsers; this.RaisePropertyChanged(nameof(AddedUsers)); } @@ -253,16 +254,8 @@ private async void SaveCommand() { try { - await _stream.StreamState.Client - .StreamInviteCreate( - new StreamInviteCreateInput - { - email = user.Name, - streamId = _stream.StreamState.StreamId, - message = "I would like to share a model with you via Speckle!", - role = user.Role - } - ) + await _stream.StreamState.Client.ProjectInvite + .Create(_stream.StreamState.StreamId, new ProjectInviteCreateInput(null, user.Role, null, user.Id)) .ConfigureAwait(true); Analytics.TrackEvent( _stream.StreamState.Client.Account, @@ -283,16 +276,8 @@ await _stream.StreamState.Client { try { - await _stream.StreamState.Client - .StreamInviteCreate( - new StreamInviteCreateInput - { - userId = user.Id, - streamId = _stream.StreamState.StreamId, - message = "I would like to share a model with you via Speckle!", - role = user.Role - } - ) + await _stream.StreamState.Client.ProjectInvite + .Create(_stream.StreamState.StreamId, new ProjectInviteCreateInput(null, user.Role, null, user.Id)) .ConfigureAwait(true); Analytics.TrackEvent( _stream.StreamState.Client.Account, @@ -313,15 +298,8 @@ await _stream.StreamState.Client { try { - await _stream.StreamState.Client - .StreamUpdatePermission( - new StreamPermissionInput - { - userId = user.Id, - streamId = _stream.StreamState.StreamId, - role = user.Role - } - ) + await _stream.StreamState.Client.Project + .UpdateRole(new ProjectUpdateRoleInput(user.Id, _stream.StreamState.StreamId, user.Role)) .ConfigureAwait(true); Analytics.TrackEvent( _stream.StreamState.Client.Account, @@ -343,10 +321,8 @@ await _stream.StreamState.Client { try { - await _stream.StreamState.Client - .StreamRevokePermission( - new StreamRevokePermissionInput { userId = user.id, streamId = _stream.StreamState.StreamId } - ) + await _stream.StreamState.Client.Project + .UpdateRole(new ProjectUpdateRoleInput(user.id, _stream.StreamState.StreamId, null)) .ConfigureAwait(true); Analytics.TrackEvent( _stream.StreamState.Client.Account, @@ -368,8 +344,8 @@ await _stream.StreamState.Client { try { - await _stream.StreamState.Client - .StreamInviteCancel(_stream.StreamState.StreamId, user.inviteId) + await _stream.StreamState.Client.ProjectInvite + .Cancel(_stream.StreamState.StreamId, user.inviteId) .ConfigureAwait(true); Analytics.TrackEvent( _stream.StreamState.Client.Account, @@ -419,8 +395,6 @@ await _stream.StreamState.Client ex.Message ); } - - this.RaisePropertyChanged(nameof(AddedUsers)); } private async void CloseCommand() diff --git a/DesktopUI2/DesktopUI2/ViewModels/CommentViewModel.cs b/DesktopUI2/DesktopUI2/ViewModels/CommentViewModel.cs index 359116a9d7..162a295c24 100644 --- a/DesktopUI2/DesktopUI2/ViewModels/CommentViewModel.cs +++ b/DesktopUI2/DesktopUI2/ViewModels/CommentViewModel.cs @@ -9,6 +9,7 @@ using DesktopUI2.Views; using ReactiveUI; using Speckle.Core.Api; +using Speckle.Core.Api.GraphQL.Models; using Speckle.Core.Helpers; using Speckle.Core.Logging; using Splat; @@ -20,7 +21,7 @@ public class CommentViewModel : ReactiveObject { private ConnectorBindings Bindings; - public CommentViewModel(CommentItem item, string streamId, Client client) + public CommentViewModel(Comment item, string streamId, Client client) { Comment = item; StreamId = streamId; @@ -40,10 +41,10 @@ public CommentViewModel(CommentItem item, string streamId, Client client) } } - public CommentItem Comment { get; set; } + public Comment Comment { get; set; } public string StreamId { get; private set; } public Task Author => GetAuthorAsync(); - public Task Screenshot => GetScreenshotAsync(); + public Task Screenshot => Task.FromResult(GetScreenshot()); //return string.Join("", Comment.text.Doc?.Content.Select(x => string.Join("", x.Content.Select(x => x.Text).ToList())).ToList()); public string Text { get; private set; } @@ -72,9 +73,9 @@ private async Task GetAuthorAsync() return await ApiUtils.GetAccount(Comment.authorId, _client).ConfigureAwait(true); } - private async Task GetScreenshotAsync() + private Bitmap GetScreenshot() { - var screenshot = await _client.StreamGetCommentScreenshot(Comment.id, StreamId).ConfigureAwait(true); + var screenshot = Comment.screenshot; byte[] bytes = Convert.FromBase64String(screenshot.Split(',')[1]); Stream stream = new MemoryStream(bytes); return new Bitmap(stream); @@ -84,9 +85,13 @@ public void OpenCommentView() { try { - if (Comment.data != null && Comment.data.camPos != null) + if (Comment.viewerState is { ui.camera.position: not null }) { - Bindings.Open3DView(Comment.data.camPos, Comment.id); + var camera = Comment.viewerState.ui.camera; + //Bindings.Open3DView was designed to take the old flat comment.data.camPos + //We'll shim the comment.viewState to look like the old style camPos + var oldStyleCoordinates = camera.position.Concat(camera.target).ToList(); + Bindings.Open3DView(oldStyleCoordinates, Comment.id); Analytics.TrackEvent( Analytics.Events.DUIAction, new Dictionary { { "name", "Comment Open 3D View" } } @@ -114,10 +119,29 @@ public void OpenCommentView() } public void OpenComment() + { + string url; + if (_client.Account.serverInfo.frontend2) + { + url = FormatFe2Url(); + } + else + { + url = FormatFe1Url(); + } + + if (url is not null) + { + Open.Url(url); + Analytics.TrackEvent(Analytics.Events.DUIAction, new Dictionary { { "name", "Comment View" } }); + } + } + + private string FormatFe1Url() { if (Comment.resources == null || !Comment.resources.Any()) { - return; + return null; } var r0 = Comment.resources[0]; @@ -128,14 +152,19 @@ public void OpenComment() overlay = "&overlay=" + string.Join(",", Comment.resources.Skip(1).Select(x => x.resourceId)); } - var url = - $"{_client.Account.serverInfo.url}/streams/{StreamId}/{r0.resourceType}s/{r0.resourceId}?cId={Comment.id}{overlay}"; - if (_client.Account.serverInfo.frontend2) + return $"{_client.Account.serverInfo.url}/streams/{StreamId}/{r0.resourceType}s/{r0.resourceId}?cId={Comment.id}{overlay}"; + } + + private string FormatFe2Url() + { + if (Comment.viewerResources == null || !Comment.viewerResources.Any()) { - url = $"{_client.Account.serverInfo.url}/projects/{StreamId}/"; + return $"{_client.Account.serverInfo.url}/projects/{StreamId}"; } - Open.Url(url); - Analytics.TrackEvent(Analytics.Events.DUIAction, new Dictionary { { "name", "Comment View" } }); + var r0 = Comment.viewerResources[0]; + var resource = new[] { r0.modelId, r0.versionId }.Where(x => x != null); + var resourceId = string.Join("@", resource); + return $"{_client.Account.serverInfo.url}/projects/{StreamId}/models/{resourceId}#threadId={Comment.id}"; } } diff --git a/DesktopUI2/DesktopUI2/ViewModels/HomeViewModel.cs b/DesktopUI2/DesktopUI2/ViewModels/HomeViewModel.cs index d1385cae54..6cc8f0fcec 100644 --- a/DesktopUI2/DesktopUI2/ViewModels/HomeViewModel.cs +++ b/DesktopUI2/DesktopUI2/ViewModels/HomeViewModel.cs @@ -188,16 +188,7 @@ private async Task GetStreams() //NO SEARCH if (string.IsNullOrEmpty(SearchQuery)) { - if (SelectedFilter == Filter.favorite) - { - result = await account.Client - .FavoriteStreamsGet(25, StreamGetCancelTokenSource.Token) - .ConfigureAwait(true); - } - else - { - result = await account.Client.StreamsGet(25, StreamGetCancelTokenSource.Token).ConfigureAwait(true); - } + result = await account.Client.StreamsGet(25, StreamGetCancelTokenSource.Token).ConfigureAwait(true); } //SEARCH else @@ -290,7 +281,7 @@ private async Task GetNotifications() { try { - var result = await account.Client.GetAllPendingInvites().ConfigureAwait(true); + var result = await account.Client.ActiveUser.ProjectInvites().ConfigureAwait(true); foreach (var r in result) { Notifications.Add(new NotificationViewModel(r, account.Client.ServerUrl)); @@ -968,6 +959,11 @@ public bool ActiveFilter private async void SetFilters(Filter oldValue, Filter newValue) { + if (newValue == Filter.favorite) + { + throw new NotImplementedException(); + } + this.RaiseAndSetIfChanged(ref _selectedFilter, newValue); //refresh stream list if the previous filter is/was favorite if (newValue == Filter.favorite || oldValue == Filter.favorite) diff --git a/DesktopUI2/DesktopUI2/ViewModels/StreamViewModel.cs b/DesktopUI2/DesktopUI2/ViewModels/StreamViewModel.cs index 0f724fd6aa..487a1a15ac 100644 --- a/DesktopUI2/DesktopUI2/ViewModels/StreamViewModel.cs +++ b/DesktopUI2/DesktopUI2/ViewModels/StreamViewModel.cs @@ -29,7 +29,8 @@ using ReactiveUI; using Serilog.Events; using Speckle.Core.Api; -using Speckle.Core.Api.SubscriptionModels; +using Speckle.Core.Api.GraphQL.Enums; +using Speckle.Core.Api.GraphQL.Models; using Speckle.Core.Helpers; using Speckle.Core.Kits; using Speckle.Core.Logging; @@ -353,37 +354,38 @@ private void GetReport() ReportFilterItems = report.Select(o => o.Status).Distinct().ToList(); } - private async void GetActivity() - { - try - { - var filteredActivity = (await Client.StreamGetActivity(Stream.id).ConfigureAwait(true)) - .Where( - x => x.actionType == "commit_create" || x.actionType == "commit_receive" || x.actionType == "stream_create" - ) - .Reverse() - .ToList(); - var activity = new List(); - foreach (var a in filteredActivity) - { - var avm = new ActivityViewModel(a, Client); - activity.Add(avm); - } - - Activity = activity; - ScrollToBottom(); - } - catch (Exception ex) - { - SpeckleLog.Logger.Error(ex, "Failed getting activity {exceptionMessage}", ex.Message); - } + private void GetActivity() + { + //Disabled as API is deprecated + // try + // { + // var filteredActivity = (await Client.StreamGetActivity(Stream.id).ConfigureAwait(true)) + // .Where( + // x => x.actionType == "commit_create" || x.actionType == "commit_receive" || x.actionType == "stream_create" + // ) + // .Reverse() + // .ToList(); + // var activity = new List(); + // foreach (var a in filteredActivity) + // { + // var avm = new ActivityViewModel(a, Client); + // activity.Add(avm); + // } + // + // Activity = activity; + // ScrollToBottom(); + // } + // catch (Exception ex) + // { + // SpeckleLog.Logger.Error(ex, "Failed getting activity {exceptionMessage}", ex.Message); + // } } private async Task GetComments() { try { - var commentData = await Client.StreamGetComments(Stream.id).ConfigureAwait(true); + var commentData = await Client.Comment.GetProjectComments(Stream.id).ConfigureAwait(true); var comments = new List(); foreach (var c in commentData.items) { @@ -1099,25 +1101,10 @@ public bool PreviewImage360Loaded private void Subscribe() { - Client.SubscribeCommitCreated(StreamState.StreamId); - Client.SubscribeCommitUpdated(StreamState.StreamId); - Client.SubscribeCommitDeleted(StreamState.StreamId); - Client.OnCommitCreated += Client_OnCommitCreated; - Client.OnCommitUpdated += Client_OnCommitChange; - Client.OnCommitDeleted += Client_OnCommitChange; - - Client.SubscribeBranchCreated(StreamState.StreamId); - Client.SubscribeBranchUpdated(StreamState.StreamId); - Client.SubscribeBranchDeleted(StreamState.StreamId); - Client.OnBranchCreated += Client_OnBranchChange; - Client.OnBranchUpdated += Client_OnBranchChange; - Client.OnBranchDeleted += Client_OnBranchChange; - - Client.SubscribeCommentActivity(StreamState.StreamId); - Client.OnCommentActivity += Client_OnCommentActivity; - - Client.SubscribeStreamUpdated(StreamState.StreamId); - Client.OnStreamUpdated += Client_OnStreamUpdated; + Client.Subscription.CreateProjectUpdatedSubscription(StreamState.StreamId).Listeners += Client_OnStreamUpdated; + Client.Subscription.CreateProjectModelsUpdatedSubscription(StreamState.StreamId).Listeners += Client_OnModelChange; + Client.Subscription.CreateProjectVersionsUpdatedSubscription(StreamState.StreamId).Listeners += + Client_OnVersionUpdated; } private async void Client_OnCommentActivity(object sender, CommentItem e) @@ -1175,7 +1162,7 @@ private async void Client_OnCommentActivity(object sender, CommentItem e) } } - private async void Client_OnBranchChange(object sender, BranchInfo info) + private async void Client_OnModelChange(object sender, ProjectModelsUpdatedMessage info) { if (!_isAddingBranches) { @@ -1183,19 +1170,11 @@ private async void Client_OnBranchChange(object sender, BranchInfo info) } } - private async void Client_OnCommitChange(object sender, CommitInfo info) - { - if (info.branchName == SelectedBranch.Branch.name) - { - await GetCommits().ConfigureAwait(true); - } - } - - private async void Client_OnCommitCreated(object sender, CommitInfo info) + private async void Client_OnVersionUpdated(object sender, ProjectVersionsUpdatedMessage info) { try { - if (info.branchName == SelectedBranch.Branch.name) + if (info.modelId == SelectedBranch.Branch.id) { await GetCommits().ConfigureAwait(true); } @@ -1205,8 +1184,13 @@ private async void Client_OnCommitCreated(object sender, CommitInfo info) return; } + if (info.type is not ProjectVersionsUpdatedMessageType.CREATED) + { + return; + } + var authorName = "You"; - if (info.authorId != Client.Account.userInfo.id) + if (info.version?.authorUser.id != Client.Account.userInfo.id) { var author = await Client.OtherUserGet(info.id).ConfigureAwait(true); authorName = author.name; @@ -1226,7 +1210,7 @@ private async void Client_OnCommitCreated(object sender, CommitInfo info) MainUserControl.NotificationManager.Show( new PopUpNotificationViewModel { - Title = $"🆕 {authorName} sent to {Stream.name}/{info.branchName}'", + Title = $"🆕 {authorName} sent to {Stream.name}/{info.modelId}'", Message = openOnline ? "Click to view it online" : "Click open the project", OnClick = () => { @@ -1259,13 +1243,13 @@ private async void Client_OnCommitCreated(object sender, CommitInfo info) SpeckleLog.Logger.Warning( ex, "Swallowing exception in {methodName}: {exceptionMessage}", - nameof(Client_OnCommitCreated), + nameof(Client_OnVersionUpdated), ex.Message ); } } - private void Client_OnStreamUpdated(object sender, StreamInfo e) + private void Client_OnStreamUpdated(object sender, ProjectUpdatedMessage e) { GetStream().ConfigureAwait(true); } diff --git a/DesktopUI2/DesktopUI2/Views/MainUserControl.xaml.cs b/DesktopUI2/DesktopUI2/Views/MainUserControl.xaml.cs index d882a1bba0..ea80a891d9 100644 --- a/DesktopUI2/DesktopUI2/Views/MainUserControl.xaml.cs +++ b/DesktopUI2/DesktopUI2/Views/MainUserControl.xaml.cs @@ -1,11 +1,9 @@ -using System.Collections.Generic; using Avalonia.Controls; using Avalonia.Markup.Xaml; using Avalonia.ReactiveUI; using DesktopUI2.Models; using DesktopUI2.ViewModels; using ReactiveUI; -using Speckle.Core.Logging; namespace DesktopUI2.Views; diff --git a/DesktopUI2/DesktopUI2/Views/Pages/HomeView.xaml b/DesktopUI2/DesktopUI2/Views/Pages/HomeView.xaml index f767ff877d..a1e86c34e3 100644 --- a/DesktopUI2/DesktopUI2/Views/Pages/HomeView.xaml +++ b/DesktopUI2/DesktopUI2/Views/Pages/HomeView.xaml @@ -219,11 +219,12 @@ Content="reviewer" GroupName="3" IsChecked="{Binding Path=SelectedFilter, Converter={StaticResource EnumBooleanConverter}, ConverterParameter=reviewer}" /> - + + + + + + diff --git a/DesktopUI2/DesktopUI2/Views/Pages/StreamEditView.xaml b/DesktopUI2/DesktopUI2/Views/Pages/StreamEditView.xaml index 3ad9f1686b..763637f6ed 100644 --- a/DesktopUI2/DesktopUI2/Views/Pages/StreamEditView.xaml +++ b/DesktopUI2/DesktopUI2/Views/Pages/StreamEditView.xaml @@ -205,27 +205,27 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + +