Skip to content

Commit

Permalink
Merge pull request #3974 from tloncorp/promote-10-1
Browse files Browse the repository at this point in the history
ops: promote 6.4.0 (again)
  • Loading branch information
arthyn authored Oct 1, 2024
2 parents 09eb9cf + d1cfd43 commit 4eeba6d
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 113 deletions.
1 change: 0 additions & 1 deletion desk/app/chat.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -1874,7 +1874,6 @@
::
++ di-take-counter
|= =diff:dm:c
?< =(%archive net.dm)
?< (~(has in blocked) ship)
(di-ingest-diff diff)
::
Expand Down
2 changes: 1 addition & 1 deletion desk/app/grouper.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
%shut
~? dev-mode ['inviting to private/secret' joiner.bite]
=/ =action:groups
:- [our.bowl token.bite]
:- flag
:- now.bowl
:- %cordon
[%shut [%add-ships %pending (~(gas in *(set ship)) ~[joiner.bite])]]
Expand Down
18 changes: 12 additions & 6 deletions packages/app/features/top/useConnectionStatus.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import * as api from '@tloncorp/shared/dist/api';
import { debounce } from 'lodash';
import { ConnectionStatus } from '@tloncorp/shared/dist/api';
import { useCurrentUserId } from '@tloncorp/ui';
import { debounce } from 'lodash';
import { useEffect, useState } from 'react';

export const useConnectionStatus = (contactId: string) => {
const [connectionStatus, setConnectionStatus] =
useState<ConnectionStatus | null>(null);
const currentUserId = useCurrentUserId();

useEffect(() => {
api.checkConnectionStatus(
contactId,
debounce(setConnectionStatus, 500, { trailing: true })
);
}, [contactId]);
if (currentUserId === contactId) {
setConnectionStatus({ status: 'yes', complete: true });
} else {
api.checkConnectionStatus(
contactId,
debounce(setConnectionStatus, 500, { trailing: true })
);
}
}, [contactId, currentUserId]);
return connectionStatus;
};
23 changes: 18 additions & 5 deletions packages/ui/src/components/ActionSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export type Action = {
render?: (props: ActionRenderProps) => ReactElement;
endIcon?: IconType | ReactElement;
startIcon?: IconType | ReactElement;
accent?: Accent;
};

export type ActionRenderProps = {
Expand Down Expand Up @@ -296,16 +297,19 @@ const ActionSheetActionFrame = styled(ListItem, {
variants: {
type: {
positive: {
backgroundColor: '$positiveBackground',
pressStyle: {
backgroundColor: '$positiveBackground',
},
},
negative: {
backgroundColor: '$negativeBackground',
pressStyle: {
backgroundColor: '$negativeBackground',
},
},
neutral: {},
disabled: {},
},
} as const,
});
Expand Down Expand Up @@ -349,27 +353,33 @@ function ActionSheetAction({ action }: { action: Action }) {
action.render({ action })
) : (
<ActionSheetActionFrame
type={action.accent ?? (accent as Accent)}
onPress={accent !== 'disabled' ? action.action : undefined}
>
{action.startIcon && resolveIcon(action.startIcon)}
{action.startIcon &&
resolveIcon(action.startIcon, action.accent ?? accent)}
<ListItem.MainContent>
<ActionSheet.ActionTitle>{action.title}</ActionSheet.ActionTitle>
<ActionSheet.ActionTitle accent={action.accent ?? accent}>
{action.title}
</ActionSheet.ActionTitle>
{action.description && (
<ActionSheet.ActionDescription>
{action.description}
</ActionSheet.ActionDescription>
)}
</ListItem.MainContent>
{action.endIcon && (
<ListItem.EndContent>{resolveIcon(action.endIcon)}</ListItem.EndContent>
<ListItem.EndContent>
{resolveIcon(action.endIcon, action.accent ?? accent)}
</ListItem.EndContent>
)}
</ActionSheetActionFrame>
);
}

function resolveIcon(icon: IconType | ReactElement) {
function resolveIcon(icon: IconType | ReactElement, accent: Accent) {
if (typeof icon === 'string') {
return <ActionSheetActionIcon type={icon} />;
return <ActionSheetActionIcon accent={accent} type={icon} />;
}
return icon;
}
Expand All @@ -386,6 +396,9 @@ const ActionSheetActionIcon = styled(Icon, {
color: '$negativeActionText',
},
neutral: {},
disabled: {
color: '$tertiaryText',
},
},
} as const,
});
Expand Down
36 changes: 0 additions & 36 deletions packages/ui/src/components/ChatList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,16 @@ import {
useEffect,
useLayoutEffect,
useMemo,
useRef,
useState,
} from 'react';
import React from 'react';
import {
LayoutChangeEvent,
NativeScrollEvent,
NativeSyntheticEvent,
SectionList,
SectionListData,
SectionListRenderItemInfo,
StyleProp,
ViewStyle,
ViewToken,
} from 'react-native';
import Animated, {
Easing,
Expand Down Expand Up @@ -55,7 +51,6 @@ function ChatListComponent({
onLongPressItem,
onPressItem,
onPressMenuButton,
onSectionChange,
activeTab,
setActiveTab,
showFilters,
Expand Down Expand Up @@ -126,35 +121,6 @@ function ChatListComponent({
[]
);

const isAtTopRef = useRef(true);

const onViewableItemsChanged = useRef(
({ viewableItems }: { viewableItems: ViewToken[] }) => {
if (viewableItems.length === 0) {
return;
}

if (!isAtTopRef.current) {
const { section } = viewableItems[0];
if (section) {
onSectionChange?.(section.title);
}
}
}
).current;

const handleScroll = useRef(
(event: NativeSyntheticEvent<NativeScrollEvent>) => {
const atTop = event.nativeEvent.contentOffset.y === 0;
if (atTop !== isAtTopRef.current) {
isAtTopRef.current = atTop;
if (atTop) {
onSectionChange?.('Home');
}
}
}
).current;

const handlePressTryAll = useCallback(() => {
setActiveTab('all');
}, [setActiveTab]);
Expand Down Expand Up @@ -194,8 +160,6 @@ function ChatListComponent({
waitForInteraction: false,
}}
renderSectionHeader={renderSectionHeader}
onViewableItemsChanged={onViewableItemsChanged}
onMomentumScrollEnd={activeTab === 'all' ? handleScroll : undefined}
/>
)}
</>
Expand Down
Loading

0 comments on commit 4eeba6d

Please sign in to comment.