Skip to content

Commit

Permalink
Merge pull request #3221 from tloncorp/lb/fix-talk-sunset
Browse files Browse the repository at this point in the history
talk sunset: correctly register if you've already seen the sunset banner & add passive indicator on mobile
  • Loading branch information
arthyn authored Feb 8, 2024
2 parents 0917261 + b337fe4 commit 5e0a5f1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
15 changes: 14 additions & 1 deletion ui/src/dms/MobileMessagesSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import MobileHeader from '@/components/MobileHeader';
import AddIconMobileNav from '@/components/icons/AddIconMobileNav';
import FilterIconMobileNav from '@/components/icons/FilterIconMobileNav';
import useAppName from '@/logic/useAppName';
import CautionIcon from '@/components/icons/CautionIcon';
import { useLocalState } from '@/state/local';
import ActionMenu, { Action } from '@/components/ActionMenu';
import MessagesList from './MessagesList';
import MessagesSidebarItem from './MessagesSidebarItem';
Expand Down Expand Up @@ -80,7 +82,7 @@ export default function MobileMessagesSidebar() {
return (
<div className="flex h-full w-full flex-col">
<MobileHeader
title="Messages"
title={appName === 'Talk' ? <TalkSunsetHeader /> : 'Messages'}
action={
<div className="flex h-12 items-center justify-end space-x-2">
<ReconnectingSpinner />
Expand Down Expand Up @@ -133,3 +135,14 @@ export default function MobileMessagesSidebar() {
</div>
);
}

function TalkSunsetHeader() {
const onClick = () =>
useLocalState.setState({ manuallyShowTalkSunset: true });

return (
<div className="flex items-center justify-center py-1" onClick={onClick}>
Messages <CautionIcon className="ml-2 h-5 w-5 text-indigo" />
</div>
);
}
14 changes: 12 additions & 2 deletions ui/src/nav/TalkNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import MessagesSidebar from '@/dms/MessagesSidebar';
import Dialog from '@/components/Dialog';
import CautionIcon from '@/components/icons/CautionIcon';
import WidgetDrawer from '@/components/WidgetDrawer';
import { useState } from 'react';
import { useEffect, useState } from 'react';
import {
usePutEntryMutation,
useSeenTalkSunset,
Expand All @@ -14,15 +14,25 @@ import {
import { useLocalState, useManuallyShowTalkSunset } from '@/state/local';

export default function TalkNav() {
const [timedDelay, setTimedDelay] = useState(false);
const isMobile = useIsMobile();
const seenSunset = useSeenTalkSunset();
const manuallyShowSunset = useManuallyShowTalkSunset();

useEffect(() => {
const timeout = setTimeout(() => {
setTimedDelay(true);
}, 3000);
return () => clearTimeout(timeout);
}, [setTimedDelay]);

return (
<div className={cn('fixed flex h-full w-full')}>
{isMobile ? null : <MessagesSidebar />}
<Outlet />
{(!seenSunset || manuallyShowSunset) && <TalkSunsetNotification />}
{timedDelay && (!seenSunset || manuallyShowSunset) && (
<TalkSunsetNotification />
)}
</div>
);
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/state/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ export function useSeenTalkSunset() {
const { data, isLoading } = useMergedSettings();

return useMemo(() => {
if (isLoading || data === undefined || data.groups === undefined) {
if (isLoading || data === undefined || data.talk === undefined) {
console.log('returning sunset default');
return false;
}
Expand Down

0 comments on commit 5e0a5f1

Please sign in to comment.