{device ? (
diff --git a/src/components/BatteryStatus.tsx b/src/components/BatteryStatus.tsx
index a84df7e8..bd6022c9 100644
--- a/src/components/BatteryStatus.tsx
+++ b/src/components/BatteryStatus.tsx
@@ -27,7 +27,7 @@ const batteryStates: BatteryStateConfig[] = [
{
condition: level => level > 100,
Icon: PlugZapIcon,
- className: 'text-gray-600',
+ className: 'text-gray-500',
text: () => 'Plugged in',
},
{
@@ -39,7 +39,7 @@ const batteryStates: BatteryStateConfig[] = [
{
condition: level => level > 20,
Icon: BatteryMediumIcon,
- className: 'text-yellow-400',
+ className: 'text-yellow-500',
text: level => `${level}% charging`,
},
{
diff --git a/src/components/PageComponents/Messages/ChannelChat.tsx b/src/components/PageComponents/Messages/ChannelChat.tsx
index 29715b88..bc08b2d9 100644
--- a/src/components/PageComponents/Messages/ChannelChat.tsx
+++ b/src/components/PageComponents/Messages/ChannelChat.tsx
@@ -14,55 +14,66 @@ const EmptyState = () => (
);
-export const ChannelChat = ({
- messages = [],
-}: ChannelChatProps) => {
+export const ChannelChat = ({ messages = [] }: ChannelChatProps) => {
const messagesEndRef = useRef(null);
const scrollContainerRef = useRef(null);
+ const userScrolledUpRef = useRef(false);
const scrollToBottom = useCallback((behavior: ScrollBehavior = 'smooth') => {
- const scrollContainer = scrollContainerRef.current;
- if (!scrollContainer) return;
-
- const scrollThreshold = 50; // How close to bottom to trigger smooth scroll
- const isNearBottom = scrollContainer.scrollHeight - scrollContainer.scrollTop - scrollContainer.clientHeight < scrollThreshold;
-
- if (behavior === 'instant' || isNearBottom) {
+ requestAnimationFrame(() => {
messagesEndRef.current?.scrollIntoView({ behavior });
- }
+ });
}, []);
useEffect(() => {
- if (messages.length > 0) {
+ const scrollContainer = scrollContainerRef.current;
+ if (!scrollContainer) return;
+
+ const isScrolledToBottom = scrollContainer.scrollHeight - scrollContainer.scrollTop - scrollContainer.clientHeight <= 10;
+
+ if (isScrolledToBottom || !userScrolledUpRef.current) {
scrollToBottom('smooth');
}
}, [messages, scrollToBottom]);
+ useEffect(() => {
+ const scrollContainer = scrollContainerRef.current;
+ const handleScroll = () => {
+ if (!scrollContainer) return;
+ const isAtBottom = scrollContainer.scrollHeight - scrollContainer.scrollTop - scrollContainer.clientHeight <= 10;
+ userScrolledUpRef.current = !isAtBottom;
+ };
+
+ scrollContainer?.addEventListener('scroll', handleScroll);
+
+ return () => {
+ scrollContainer?.removeEventListener('scroll', handleScroll);
+ };
+ }, []);
if (!messages?.length) {
return (
-
+
);
}
-
return (
-
{messages?.map((message) => {
return (
);
})}
+
);
};
\ No newline at end of file
diff --git a/src/components/PageComponents/Messages/MessageInput.tsx b/src/components/PageComponents/Messages/MessageInput.tsx
index 3f4a32ff..f29dd25c 100644
--- a/src/components/PageComponents/Messages/MessageInput.tsx
+++ b/src/components/PageComponents/Messages/MessageInput.tsx
@@ -56,10 +56,7 @@ export const MessageInput = ({
if (byteLength <= maxBytes) {
setLocalDraft(newValue);
setMessageBytes(byteLength);
-
- startTransition(() => {
- setDraft(to, newValue);
- });
+ setDraft(to, newValue);
}
};