On conversation open, scroll to unread indicator if present

This commit is contained in:
Evan Hahn 2022-03-08 14:05:05 -06:00 committed by GitHub
parent efee887135
commit 944d60f40b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 49 additions and 67 deletions

View file

@ -1,7 +1,7 @@
// Copyright 2019-2020 Signal Messenger, LLC
// Copyright 2019-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React from 'react';
import React, { forwardRef } from 'react';
import type { LocalizerType } from '../../types/Util';
@ -10,16 +10,18 @@ export type Props = {
i18n: LocalizerType;
};
export const LastSeenIndicator = ({ count, i18n }: Props): JSX.Element => {
const message =
count === 1
? i18n('unreadMessage')
: i18n('unreadMessages', [String(count)]);
export const LastSeenIndicator = forwardRef<HTMLDivElement, Props>(
({ count, i18n }, ref) => {
const message =
count === 1
? i18n('unreadMessage')
: i18n('unreadMessages', [String(count)]);
return (
<div className="module-last-seen-indicator">
<div className="module-last-seen-indicator__bar" />
<div className="module-last-seen-indicator__text">{message}</div>
</div>
);
};
return (
<div className="module-last-seen-indicator" ref={ref}>
<div className="module-last-seen-indicator__bar" />
<div className="module-last-seen-indicator__text">{message}</div>
</div>
);
}
);