Skip to content

Commit

Permalink
misc cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sspenst committed Dec 17, 2023
1 parent d7b9d36 commit 388c757
Show file tree
Hide file tree
Showing 15 changed files with 289 additions and 296 deletions.
1 change: 0 additions & 1 deletion components/cards/levelSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export default function LevelSelect({ levels }: LevelSelectProps) {
id: level._id.toString(),
level: level,
stats: new SelectOptionStats(level.leastMoves, level.userMoves),
searchLabel: level.name,
text: level.name,
} as SelectOption;
})} />
Expand Down
3 changes: 1 addition & 2 deletions components/collection/collectionScrollList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,8 @@ export default function CollectionScrollList({ collection, id, isHidden, onLoadi
href: href,
id: `${id}-${levelInCollection._id.toString()}`,
level: levelInCollection,
text: levelInCollection.name,
searchLabel: levelInCollection.name,
stats: new SelectOptionStats(levelInCollection.leastMoves, (levelInCollection as EnrichedLevel)?.userMoves),
text: levelInCollection.name,
width: 216,
}} />
</div>
Expand Down
5 changes: 2 additions & 3 deletions components/header/notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AppContext } from '../../contexts/appContext';
import NotificationList from '../notification/notificationList';

export default function Notifications() {
const { user, notifications, setNotifications } = useContext(AppContext);
const { notifications, setNotifications, user } = useContext(AppContext);

useEffect(() => {
if (user) {
Expand All @@ -20,8 +20,7 @@ export default function Notifications() {

return (
<Menu>
<Menu.Button onClickCapture={() => {
}} aria-label='notifications'>
<Menu.Button aria-label='notifications'>
<div className='flex items-start hover:opacity-70' id='notificationsBtn'>
<svg xmlns='http://www.w3.org/2000/svg' fill='currentColor' className='bi bi-bell h-6 w-5' viewBox='0 0 17 17'>
<path d='M8 16a2 2 0 0 0 2-2H6a2 2 0 0 0 2 2zM8 1.918l-.797.161A4.002 4.002 0 0 0 4 6c0 .628-.134 2.197-.459 3.742-.16.767-.376 1.566-.663 2.258h10.244c-.287-.692-.502-1.49-.663-2.258C12.134 8.197 12 6.628 12 6a4.002 4.002 0 0 0-3.203-3.92L8 1.917zM14.22 12c.223.447.481.801.78 1H1c.299-.199.557-.553.78-1C2.68 10.2 3 6.88 3 6c0-2.42 1.72-4.44 4.005-4.901a1 1 0 1 1 1.99 0A5.002 5.002 0 0 1 13 6c0 .88.32 4.2 1.22 6z' />
Expand Down
1 change: 0 additions & 1 deletion components/profile/playHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ export default function PlayHistory() {
href: `/level/${level.slug}`,
id: playAttempt.levelId._id.toString() + '-' + playAttempt._id.toString(),
level: level,
searchLabel: level.name,
stats: new SelectOptionStats(level.leastMoves, level.userMoves),
text: level.name,
}} />
Expand Down
4 changes: 2 additions & 2 deletions contexts/appContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { MultiplayerSocket } from '../pages/_app';
interface AppContextInterface {
deviceInfo: DeviceInfo;
forceUpdate: () => void;
notifications: Notification[];
multiplayerSocket: MultiplayerSocket;
mutatePlayLater: () => void;
mutateUser: KeyedMutator<ReqUser>;
notifications: Notification[];
playLater?: { [key: string]: boolean };
setNotifications: React.Dispatch<React.SetStateAction<Notification[]>>;
setShouldAttemptAuth: React.Dispatch<React.SetStateAction<boolean>>;
Expand All @@ -38,7 +38,6 @@ export const AppContext = createContext<AppContextInterface>({
screenSize: ScreenSize.SM,
},
forceUpdate: () => { return; },
notifications: [],
multiplayerSocket: {
connectedPlayers: [],
connectedPlayersCount: 0,
Expand All @@ -48,6 +47,7 @@ export const AppContext = createContext<AppContextInterface>({
},
mutatePlayLater: () => { return; },
mutateUser: {} as KeyedMutator<ReqUser>,
notifications: [],
playLater: undefined,
setNotifications: () => { return; },
setShouldAttemptAuth: () => { return; },
Expand Down
2 changes: 1 addition & 1 deletion helpers/filterSelectOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function filterSelectOptions(
}

if (filterText.length > 0) {
options = options.filter((option: SelectOption) => (option.searchLabel)?.toLowerCase().includes(filterText.toLowerCase()));
options = options.filter((option: SelectOption) => (option.searchLabel ?? option.text?.toString())?.toLowerCase().includes(filterText.toLowerCase()));
}

return options;
Expand Down
3 changes: 0 additions & 3 deletions helpers/notificationHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export async function createNewWallPostNotification(gameId: GameId, type: Notifi
userId: userId,
}]),
queuePushNotification(id),

]);

await requestBroadcastNotifications(new Types.ObjectId(userId)); // needs to happen after creating the notif
Expand Down Expand Up @@ -226,7 +225,6 @@ export async function createNewLevelAddedToCollectionNotification(gameId: GameId
const [nm,] = await Promise.all([
await NotificationModel.create(createRecords),
...ids.map(id => queuePushNotification(id)),

]);

await requestBroadcastNotifications(new Types.ObjectId(level.userId)); // needs to happen after creating the notif
Expand Down Expand Up @@ -296,7 +294,6 @@ export async function createNewRecordOnALevelYouSolvedNotifications(gameId: Game
const [nm, ] = await Promise.all([
NotificationModel.create(createRecords, options),
...ids.map(id => queuePushNotification(id)),

]);

await Promise.all(userIds.map(userId => requestBroadcastNotifications(new Types.ObjectId(userId)))); // needs to happen after creating the notif
Expand Down
2 changes: 1 addition & 1 deletion models/selectOption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ interface SelectOption {
id: string;
level?: EnrichedLevel | undefined;
onClick?: () => void;
searchLabel?: string; // text to search on, since text field is a react node (default is text?.toString())
stats?: SelectOptionStats | undefined;
searchLabel: string; // text to search on, since text field is a react node with private/public lock stuff
text: React.ReactNode;
width?: number;
}
Expand Down
Loading

0 comments on commit 388c757

Please sign in to comment.