Topics: Show messages count in topic title (#4344)
This commit is contained in:
parent
6054151969
commit
c96d05bd9f
@ -165,12 +165,14 @@ export async function fetchMessages({
|
|||||||
const messages = result.messages.map(buildApiMessage).filter(Boolean);
|
const messages = result.messages.map(buildApiMessage).filter(Boolean);
|
||||||
const users = result.users.map(buildApiUser).filter(Boolean);
|
const users = result.users.map(buildApiUser).filter(Boolean);
|
||||||
const chats = result.chats.map((c) => buildApiChatFromPreview(c)).filter(Boolean);
|
const chats = result.chats.map((c) => buildApiChatFromPreview(c)).filter(Boolean);
|
||||||
|
const count = !(result instanceof GramJs.messages.Messages) && result.count;
|
||||||
dispatchThreadInfoUpdates(result.messages);
|
dispatchThreadInfoUpdates(result.messages);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
messages,
|
messages,
|
||||||
users,
|
users,
|
||||||
chats,
|
chats,
|
||||||
|
count,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -29,6 +29,7 @@ import renderText from './helpers/renderText';
|
|||||||
import useLang from '../../hooks/useLang';
|
import useLang from '../../hooks/useLang';
|
||||||
import useLastCallback from '../../hooks/useLastCallback';
|
import useLastCallback from '../../hooks/useLastCallback';
|
||||||
|
|
||||||
|
import Transition from '../ui/Transition';
|
||||||
import Avatar from './Avatar';
|
import Avatar from './Avatar';
|
||||||
import DotAnimation from './DotAnimation';
|
import DotAnimation from './DotAnimation';
|
||||||
import FullNameTitle from './FullNameTitle';
|
import FullNameTitle from './FullNameTitle';
|
||||||
@ -172,7 +173,14 @@ const GroupChatInfo: FC<OwnProps & StateProps> = ({
|
|||||||
if (isTopic) {
|
if (isTopic) {
|
||||||
return (
|
return (
|
||||||
<span className="status" dir="auto">
|
<span className="status" dir="auto">
|
||||||
{messagesCount ? lang('messages', messagesCount, 'i') : renderText(chat.title)}
|
<Transition
|
||||||
|
name="fade"
|
||||||
|
shouldRestoreHeight
|
||||||
|
activeKey={messagesCount !== undefined ? 1 : 2}
|
||||||
|
className="message-count-transition"
|
||||||
|
>
|
||||||
|
{messagesCount !== undefined && lang('messages', messagesCount, 'i')}
|
||||||
|
</Transition>
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -275,6 +275,10 @@
|
|||||||
max-width: 2.625rem !important;
|
max-width: 2.625rem !important;
|
||||||
max-height: 2.625rem !important;
|
max-height: 2.625rem !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.message-count-transition {
|
||||||
|
height: 1.125rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.Avatar, .topic-header-icon {
|
.Avatar, .topic-header-icon {
|
||||||
|
|||||||
@ -1237,7 +1237,7 @@ async function loadViewportMessages<T extends GlobalState>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
messages, users, chats,
|
messages, users, chats, count,
|
||||||
} = result;
|
} = result;
|
||||||
|
|
||||||
global = getGlobal();
|
global = getGlobal();
|
||||||
@ -1284,6 +1284,12 @@ async function loadViewportMessages<T extends GlobalState>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (count) {
|
||||||
|
global = updateThreadInfo(global, chat.id, threadId, {
|
||||||
|
messagesCount: count,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
setGlobal(global);
|
setGlobal(global);
|
||||||
onLoaded?.();
|
onLoaded?.();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user