Skip to content

Commit

Permalink
Fix chat autoload
Browse files Browse the repository at this point in the history
  • Loading branch information
SpikeViper committed Feb 10, 2025
1 parent 9851fad commit 6ab6eba
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
{
<div class="unread-badge"></div>
}

@if (_canEdit)
{
<div class="edit-button" @onclick="@OnClickEdit">
<i class="bi bi bi-gear-fill"></i>
</div>
}
</div>
</div>
</div>
Expand Down Expand Up @@ -57,14 +64,17 @@
</div>

@code {
[Parameter] public Planet Planet { get; set; }
[Parameter]
public Planet Planet { get; set; }

public bool Open { get; set; } = true;

public List<Channel> TopChannels;

private int _notifications;
private bool _hasUnread;

private static bool _canEdit;

protected override void OnInitialized()
{
Expand All @@ -80,10 +90,17 @@
ChannelService.CategoryReordered += OnOrderUpdate;

DetermineUnreadAndNotifications();

DeterminePermissions();

GetTopLevelItems();
}

private void DeterminePermissions()
{
_canEdit = Planet.MyMember?.HasPermission(PlanetPermissions.Manage) ?? false;
}

private void DetermineUnreadAndNotifications()
{
_hasUnread = UnreadService.IsPlanetUnread(Planet.Id);
Expand Down Expand Up @@ -166,6 +183,16 @@
Open = !Open;
StateHasChanged();
}

private void OnClickEdit()
{
var data = new EditPlanetComponent.ModalParams()
{
Planet = Planet
};

ModalRoot.Instance.OpenModal<EditPlanetComponent>(data);
}

private void GetTopLevelItems()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,30 @@
background-color: var(--strong-tint);
border-radius: 8px;
height: 13px;
min-width: 13px;
transition: min-width, height 0.2s ease-in-out;
display: flex;
flex-direction: row;
align-items: center;
}

.header-wrapper:hover .header .right .unread-badge {
min-width: 16px;
height: 16px;

}

.header .right .unread-badge.notification {
background-color: var(--p-red);
}

.header .edit-button {
margin-left: 6px;
transition: transform 0.2s ease-in-out;
}

.header .edit-button:hover {
transform: rotate(45deg) scale(1.1);
}

.unread-badge span {
font-size: 10px;
padding: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ else
if (imported.PlanetId is not null)
{
var planet = await client.PlanetService.FetchPlanetAsync(imported.PlanetId!.Value);
await planet.EnsureReadyAsync();
Data = await planet.FetchChannelAsync(imported.ChannelId);
}
else
Expand Down
4 changes: 4 additions & 0 deletions Valour/Client/Modals/ModalRoot.razor
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@


@code {
public static ModalRoot Instance { get; private set; }

private readonly TimeSpan _fadeDuration = TimeSpan.FromMilliseconds(300);

private class ModalInstance
Expand Down Expand Up @@ -62,6 +64,8 @@
protected override void OnInitialized()
{
KeyboardListener.KeyDown += OnKeyDown;

Instance = this;
}

/// <summary>
Expand Down
9 changes: 7 additions & 2 deletions Valour/Sdk/Models/Planet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,13 @@ public void Dispose()
public async Task EnsureReadyAsync()
{
if (_node is null)
_node = await Client.NodeService.GetNodeForPlanetAsync(Id);

{
if (NodeName is not null)
_node = await Client.NodeService.GetByName(NodeName);
else
_node = await Client.NodeService.GetNodeForPlanetAsync(Id);
}

// Always also get member of client
if (MyMember is null)
MyMember = await FetchMemberByUserAsync(Client.Me.Id);
Expand Down

0 comments on commit 6ab6eba

Please sign in to comment.