-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
1,195 additions
and
307 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Planera.Data; | ||
|
||
public enum InterfaceTheme | ||
{ | ||
Light, | ||
Dark, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,46 @@ | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.SignalR; | ||
using Planera.Data; | ||
using Planera.Extensions; | ||
using Planera.Services; | ||
|
||
namespace Planera.Hubs; | ||
|
||
[Authorize] | ||
public class UserHub : Hub<IUserHubContext> | ||
public class UserHub(UserService userService, IHubContext<ProjectHub, IProjectHubContext> projectHub) | ||
: Hub<IUserHubContext> | ||
{ | ||
private readonly UserService _userService; | ||
private readonly IHubContext<ProjectHub, IProjectHubContext> _projectHub; | ||
|
||
public UserHub(UserService userService, IHubContext<ProjectHub, IProjectHubContext> projectHub) | ||
{ | ||
_userService = userService; | ||
_projectHub = projectHub; | ||
} | ||
|
||
public async Task AcceptInvitation(string projectId) | ||
{ | ||
string userId = Context.User!.FindFirst("Id")!.Value; | ||
var result = await _userService.AcceptInvitation(userId, projectId); | ||
var userId = Context.User!.FindFirst("Id")!.Value; | ||
var result = await userService.AcceptInvitation(userId, projectId); | ||
|
||
var invitation = result.Unwrap(); | ||
await Clients | ||
.User(Context.User!.Identity!.Name!) | ||
.OnAddProject(invitation.Project); | ||
await _projectHub.Clients | ||
await projectHub.Clients | ||
.Group(projectId) | ||
.OnAddParticipant(invitation.User); | ||
} | ||
|
||
public async Task DeclineInvitation(string projectId) | ||
{ | ||
string userId = Context.User!.FindFirst("Id")!.Value; | ||
var result = await _userService.DeclineInvitation(userId, projectId); | ||
var userId = Context.User!.FindFirst("Id")!.Value; | ||
var result = await userService.DeclineInvitation(userId, projectId); | ||
result.Unwrap(); | ||
} | ||
|
||
public async Task SetTheme(InterfaceTheme theme) | ||
{ | ||
var userId = Context.User!.FindFirst("Id")!.Value; | ||
var result = await userService.EditAsync( | ||
userId, | ||
null, | ||
null, | ||
null, | ||
theme | ||
); | ||
result.Unwrap(); | ||
} | ||
} |
Oops, something went wrong.