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

refactor: remove extra folders from folders view #16958

Merged
merged 2 commits into from
Feb 29, 2024
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
9 changes: 0 additions & 9 deletions src/script/conversation/ConversationLabelRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,6 @@ export const createLabel = (
type,
});

export const createLabelGroups = (groups: Conversation[] = []) =>
createLabel(t('conversationLabelGroups'), groups, DefaultLabelIds.Groups);

export const createLabelPeople = (contacts: Conversation[] = []) =>
createLabel(t('conversationLabelPeople'), contacts, DefaultLabelIds.Contacts);

export const createLabelFavorites = (favorites: Conversation[] = []) =>
createLabel(t('conversationLabelFavorites'), favorites, DefaultLabelIds.Favorites);

export class ConversationLabelRepository extends TypedEventTarget<{type: 'conversation-favorited'}> {
labels: ko.ObservableArray<ConversationLabel>;
private allLabeledConversations: ko.Computed<Conversation[]>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ import {
ConversationLabel,
ConversationLabelRepository,
createLabel,
createLabelGroups,
createLabelPeople,
} from '../../../../conversation/ConversationLabelRepository';
import type {ConversationRepository} from '../../../../conversation/ConversationRepository';
import {ConversationState} from '../../../../conversation/ConversationState';
Expand Down Expand Up @@ -75,7 +73,6 @@ const GroupedConversations: React.FC<GroupedConversationsProps> = ({
callState = container.resolve(CallState),
}) => {
const {conversationLabelRepository} = conversationRepository;
const {visibleConversations: conversations} = useKoSubscribableChildren(conversationState, ['visibleConversations']);

useKoSubscribableChildren(callState, ['activeCalls']);

Expand All @@ -84,19 +81,11 @@ const GroupedConversations: React.FC<GroupedConversationsProps> = ({

useLabels(conversationLabelRepository);

const groups = conversationLabelRepository.getGroupsWithoutLabel(conversations);
const contacts = conversationLabelRepository.getContactsWithoutLabel(conversations);
const custom = conversationLabelRepository
const folders = conversationLabelRepository
.getLabels()
.map(label => createLabel(label.name, conversationLabelRepository.getLabelConversations(label), label.id))
.filter(({conversations}) => !!conversations().length);

const folders = [
...(groups.length > 0 ? [createLabelGroups(groups)] : []),
...(contacts.length > 0 ? [createLabelPeople(contacts)] : []),
...custom,
];

return (
<ul className="conversation-folder-list">
{folders.map(folder => (
Expand Down
Loading