Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Community breadcrumb in favourites scope #5063

Merged
merged 4 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
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: 15 additions & 2 deletions frontend/app/src/components/home/ChatSubtext.svelte
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<script lang="ts">
import type { ChatSummary, OpenChat } from "openchat-client";
import { getContext } from "svelte";
import { createEventDispatcher, getContext } from "svelte";
import { _ } from "svelte-i18n";
import { now } from "../../stores/time";
import VisibilityLabel from "./VisibilityLabel.svelte";
import DisappearLabel from "./DisappearLabel.svelte";

const client = getContext<OpenChat>("client");
const dispatch = createEventDispatcher();

export let chat: ChatSummary;
export let clickableMembers = false;

$: userStore = client.userStore;
$: userId = chat.kind === "direct_chat" ? chat.them.userId : "";
Expand All @@ -27,6 +30,12 @@
});
}
}

function onMembersClick() {
if (clickableMembers) {
dispatch("membersClick");
}
}
</script>

{#if chat.kind === "direct_chat"}
Expand All @@ -37,7 +46,7 @@
<DisappearLabel ttl={chat.eventsTTL} />
{/if}
<VisibilityLabel isPublic={chat.public} />
<div class="members">
<div class="members" class:clickable={clickableMembers} on:click={onMembersClick}>
<span class="num">{chat.memberCount.toLocaleString()}</span>
{$_("members")}
</div>
Expand All @@ -58,4 +67,8 @@
font-weight: 700;
}
}

.clickable {
cursor: pointer;
}
</style>
20 changes: 17 additions & 3 deletions frontend/app/src/components/home/ChatSummary.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,14 @@
}

$: displayDate = client.getDisplayDate(chatSummary);
$: selectedCommunity = client.selectedCommunity;
$: communities = client.communities;
$: community =
chatSummary.kind === "channel"
? $communities.get({ kind: "community", communityId: chatSummary.id.communityId })
: undefined;
$: blocked = chatSummary.kind === "direct_chat" && $blockedUsers.has(chatSummary.them.userId);
$: readonly = client.isChatReadOnly(chatSummary.id);
$: canDelete = getCanDelete(chatSummary, $selectedCommunity);
$: canDelete = getCanDelete(chatSummary, community);
$: pinned = client.pinned($chatListScope.kind, chatSummary.id);
$: muted = chatSummary.membership.notificationsMuted;

Expand Down Expand Up @@ -344,7 +348,13 @@
<div class="details" class:rtl={$rtlStore}>
<div class="name-date">
<div class="chat-name">
<h4>{chat.name}</h4>
<h4>
{#if community !== undefined && $chatListScope.kind === "favourite"}
<span>{community.name}</span>
<span>{">"}</span>
{/if}
<span>{chat.name}</span>
</h4>
<Diamond status={chat.diamondStatus} />
</div>
</div>
Expand Down Expand Up @@ -672,7 +682,11 @@
.chat-name {
h4 {
@include font(medium, normal, fs-100);
display: flex;
flex-direction: row;
gap: $sp2;
}

display: flex;
align-items: center;
gap: $sp2;
Expand Down
59 changes: 46 additions & 13 deletions frontend/app/src/components/home/CurrentChatHeader.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<script lang="ts">
import { AvatarSize, type OpenChat, type TypersByKey } from "openchat-client";
import {
AvatarSize,
routeForChatIdentifier,
type OpenChat,
type TypersByKey,
} from "openchat-client";
import page from "page";
import { mobileWidth } from "../../stores/screenDimensions";
import CurrentChatMenu from "./CurrentChatMenu.svelte";
import SectionHeader from "../SectionHeader.svelte";
Expand Down Expand Up @@ -38,6 +44,8 @@
$: isBot = $userStore[userId]?.kind === "bot";
$: hasUserProfile = !isMultiUser && !isBot;
$: selectedChatId = client.selectedChatId;
$: selectedCommunity = client.selectedCommunity;
$: chatListScope = client.chatListScope;

function clearSelection() {
dispatch("clearSelection");
Expand Down Expand Up @@ -104,6 +112,18 @@
}
}

function navigateToCommunity() {
if ($selectedCommunity !== undefined) {
page(`/community/${$selectedCommunity.id.communityId}`);
}
}

function navigateToChannel() {
if ($selectedCommunity !== undefined) {
page(routeForChatIdentifier("community", selectedChatSummary.id));
}
}

$: chat = normaliseChatSummary($now, selectedChatSummary, $typersByContext);
</script>

Expand Down Expand Up @@ -134,11 +154,21 @@
size={AvatarSize.Default} />
</div>
<div class="chat-details">
<div class="chat-name" title={chat.name}>
<div class="chat-name">
{#if isMultiUser && !readonly}
<span on:click={showGroupDetails} class="group-details">
{chat.name}
</span>
<div class="title">
{#if $selectedCommunity !== undefined && $chatListScope.kind === "favourite"}
<span on:click={navigateToCommunity} class="pointer">
{$selectedCommunity.name}
</span>
<span>{">"}</span>
<span on:click={navigateToChannel} class="pointer">
{chat.name}
</span>
{:else}
{chat.name}
{/if}
</div>
{:else if hasUserProfile}
<span on:click={openUserProfile} class="user-link">
{chat.name}
Expand All @@ -157,9 +187,10 @@
{:else if chat.typing !== undefined}
{chat.typing} <Typing />
{:else if isMultiUser}
<div class="members" on:click={showGroupMembers}>
<ChatSubtext chat={selectedChatSummary} />
</div>
<ChatSubtext
chat={selectedChatSummary}
clickableMembers
on:membersClick={showGroupMembers} />
{:else}
<ChatSubtext chat={selectedChatSummary} />
{/if}
Expand Down Expand Up @@ -197,10 +228,6 @@
@include font(book, normal, fs-80);
@include ellipsis();
color: var(--txt-light);

.members {
cursor: pointer;
}
}

.avatar {
Expand All @@ -211,7 +238,7 @@
}
}

.group-details {
.pointer {
cursor: pointer;
}

Expand All @@ -235,6 +262,12 @@
padding: 0 $sp2;
}

.title {
display: flex;
flex-direction: row;
gap: $sp3;
}

.back {
flex: 0 0 10px;
margin-right: 5px;
Expand Down
Loading