Skip to content

Commit

Permalink
refactor: remove extra folders from folders view (#16958)
Browse files Browse the repository at this point in the history
* refactor: remove extra folders from folders view

* remove useless variable
  • Loading branch information
thisisamir98 committed Feb 29, 2024
1 parent 38e818a commit e347e5e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 21 deletions.
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

0 comments on commit e347e5e

Please sign in to comment.