Skip to content

Commit

Permalink
Merge branch 'main' into platform_part_2
Browse files Browse the repository at this point in the history
  • Loading branch information
sspenst committed Dec 17, 2023
2 parents a1c1e3d + 388c757 commit db22817
Show file tree
Hide file tree
Showing 15 changed files with 289 additions and 295 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
2 changes: 1 addition & 1 deletion contexts/appContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ interface AppContextInterface {
forceUpdate: () => void;
game: Game;
host: string | undefined;
notifications: Notification[];
multiplayerSocket: MultiplayerSocket;
mutatePlayLater: () => void;
mutateUser: KeyedMutator<ReqUser>;
notifications: Notification[];
playLater?: { [key: string]: boolean };
protocol: string | undefined;
setNotifications: React.Dispatch<React.SetStateAction<Notification[]>>;
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(gameId, new Types.ObjectId(userId)); // needs to happen after creating the notif

Check warning on line 59 in helpers/notificationHelper.ts

View check run for this annotation

Codecov / codecov/patch

helpers/notificationHelper.ts#L59

Added line #L59 was not covered by tests
Expand Down Expand Up @@ -231,7 +230,6 @@ export async function createNewLevelAddedToCollectionNotification(gameId: GameId
const [nm,] = await Promise.all([
await NotificationModel.create(createRecords),
...ids.map(id => queuePushNotification(id)),

]);

await requestBroadcastNotifications(gameId, new Types.ObjectId(level.userId)); // needs to happen after creating the notif

Check warning on line 235 in helpers/notificationHelper.ts

View check run for this annotation

Codecov / codecov/patch

helpers/notificationHelper.ts#L235

Added line #L235 was not covered by tests
Expand Down Expand Up @@ -301,7 +299,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(gameId, 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 db22817

Please sign in to comment.