mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-11-18 20:58:55 -06:00
Pin friends
This commit is contained in:
@@ -918,6 +918,10 @@ export interface Friendship {
|
||||
userOneId: number;
|
||||
userTwoId: number;
|
||||
createdAt: Generated<number>;
|
||||
/** userOne keeps this friend at the top of their friends list */
|
||||
isPinnedByUserOne: Generated<DBBoolean>;
|
||||
/** userTwo keeps this friend at the top of their friends list */
|
||||
isPinnedByUserTwo: Generated<DBBoolean>;
|
||||
}
|
||||
|
||||
/** Pending friend request from one user to another. */
|
||||
|
||||
@@ -9,7 +9,13 @@ import {
|
||||
stringConstant,
|
||||
textField,
|
||||
} from "~/form/fields";
|
||||
import { _action, id, superRefine, type ValidationCtx } from "~/utils/schema";
|
||||
import {
|
||||
_action,
|
||||
id,
|
||||
revalidateRoot,
|
||||
superRefine,
|
||||
type ValidationCtx,
|
||||
} from "~/utils/schema";
|
||||
import { AVAILABILITY } from "./availability-constants";
|
||||
|
||||
const DAY_MINUTES = 24 * 60;
|
||||
@@ -54,7 +60,7 @@ export const saveWeekSchema = v.object({
|
||||
|
||||
export const dismissScheduleNudgeSchema = v.object({
|
||||
_action: _action("DISMISS_SCHEDULE_NUDGE"),
|
||||
revalidateRoot: v.optional(v.nullable(v.literal(true))),
|
||||
revalidateRoot,
|
||||
});
|
||||
|
||||
export const saveScheduleVisibilitySchema = v.object({
|
||||
@@ -63,7 +69,7 @@ export const saveScheduleVisibilitySchema = v.object({
|
||||
label: "labels.scheduleSharedWith",
|
||||
minLength: 0,
|
||||
}),
|
||||
revalidateRoot: v.optional(v.nullable(v.literal(true))),
|
||||
revalidateRoot,
|
||||
});
|
||||
|
||||
export const eventsActionSchema = v.union([
|
||||
|
||||
@@ -86,6 +86,7 @@ export default function EventsPage() {
|
||||
controlled
|
||||
active={filter === value}
|
||||
defaultShouldRevalidate={false}
|
||||
preventScrollReset
|
||||
>
|
||||
{viewLabels[value]}
|
||||
</SubNavLink>
|
||||
|
||||
@@ -420,3 +420,69 @@ describe("findByUserIdWithActivity", () => {
|
||||
expect(result).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("updateOwnFriendshipPinned", () => {
|
||||
beforeEach(async () => {
|
||||
await createUsers(3);
|
||||
});
|
||||
|
||||
const isPinnedFor = async (userId: number) => {
|
||||
const [friend] = await FriendRepository.findByUserIdWithActivity(userId);
|
||||
|
||||
return friend.isPinned;
|
||||
};
|
||||
|
||||
test("pins the friendship for the acting user only", async () => {
|
||||
const friendship = await FriendshipFactory.create({
|
||||
userOneId: users.id(1),
|
||||
userTwoId: users.id(2),
|
||||
});
|
||||
|
||||
await withUserId(users.id(2), () =>
|
||||
FriendRepository.updateOwnFriendshipPinned({
|
||||
friendshipId: friendship.id,
|
||||
isPinned: true,
|
||||
}),
|
||||
);
|
||||
|
||||
expect(await isPinnedFor(users.id(2))).toBe(1);
|
||||
expect(await isPinnedFor(users.id(1))).toBe(0);
|
||||
});
|
||||
|
||||
test("unpins a pinned friendship", async () => {
|
||||
const friendship = await FriendshipFactory.create({
|
||||
userOneId: users.id(1),
|
||||
userTwoId: users.id(2),
|
||||
});
|
||||
|
||||
await withUserId(users.id(1), async () => {
|
||||
await FriendRepository.updateOwnFriendshipPinned({
|
||||
friendshipId: friendship.id,
|
||||
isPinned: true,
|
||||
});
|
||||
await FriendRepository.updateOwnFriendshipPinned({
|
||||
friendshipId: friendship.id,
|
||||
isPinned: false,
|
||||
});
|
||||
});
|
||||
|
||||
expect(await isPinnedFor(users.id(1))).toBe(0);
|
||||
});
|
||||
|
||||
test("does not pin a friendship the user is not part of", async () => {
|
||||
const friendship = await FriendshipFactory.create({
|
||||
userOneId: users.id(1),
|
||||
userTwoId: users.id(2),
|
||||
});
|
||||
|
||||
await withUserId(users.id(3), () =>
|
||||
FriendRepository.updateOwnFriendshipPinned({
|
||||
friendshipId: friendship.id,
|
||||
isPinned: true,
|
||||
}),
|
||||
);
|
||||
|
||||
expect(await isPinnedFor(users.id(1))).toBe(0);
|
||||
expect(await isPinnedFor(users.id(2))).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { sub } from "date-fns";
|
||||
import { type SelectQueryBuilder, sql } from "kysely";
|
||||
import { db } from "~/db/sql";
|
||||
import type { DB } from "~/db/tables";
|
||||
import type { DB, DBBoolean } from "~/db/tables";
|
||||
import { actorId } from "~/features/auth/core/user.server";
|
||||
import { dateToDatabaseTimestamp } from "~/utils/dates";
|
||||
import { commonUserSelect } from "~/utils/kysely.server";
|
||||
import { toDBBoolean } from "~/utils/sql";
|
||||
import { FRIEND } from "./friends-constants";
|
||||
|
||||
export async function findByUserIdWithActivity(userId: number) {
|
||||
@@ -33,9 +34,16 @@ export async function findByUserIdWithActivity(userId: number) {
|
||||
]),
|
||||
),
|
||||
)
|
||||
.select([
|
||||
.select((eb) => [
|
||||
"Friendship.id as friendshipId",
|
||||
"Friendship.createdAt as friendshipCreatedAt",
|
||||
eb
|
||||
.case()
|
||||
.when("Friendship.userOneId", "=", userId)
|
||||
.then(eb.ref("Friendship.isPinnedByUserOne"))
|
||||
.else(eb.ref("Friendship.isPinnedByUserTwo"))
|
||||
.end()
|
||||
.as("isPinned"),
|
||||
])
|
||||
.orderBy("Friendship.createdAt", "desc")
|
||||
.execute(),
|
||||
@@ -58,6 +66,7 @@ export async function findByUserIdWithActivity(userId: number) {
|
||||
...row,
|
||||
friendshipId: null as number | null,
|
||||
friendshipCreatedAt: null as number | null,
|
||||
isPinned: 0 as DBBoolean,
|
||||
})),
|
||||
];
|
||||
}
|
||||
@@ -228,6 +237,43 @@ export async function deleteOwnFriendshipById(id: number) {
|
||||
.execute();
|
||||
}
|
||||
|
||||
/** Pins or unpins the friendship for the acting user only, the other side keeps their own choice. */
|
||||
export async function updateOwnFriendshipPinned({
|
||||
friendshipId,
|
||||
isPinned,
|
||||
}: {
|
||||
friendshipId: number;
|
||||
isPinned: boolean;
|
||||
}) {
|
||||
const userId = actorId();
|
||||
const value = toDBBoolean(isPinned);
|
||||
|
||||
return db
|
||||
.updateTable("Friendship")
|
||||
.set((eb) => ({
|
||||
isPinnedByUserOne: eb
|
||||
.case()
|
||||
.when("Friendship.userOneId", "=", userId)
|
||||
.then(value)
|
||||
.else(eb.ref("Friendship.isPinnedByUserOne"))
|
||||
.end(),
|
||||
isPinnedByUserTwo: eb
|
||||
.case()
|
||||
.when("Friendship.userTwoId", "=", userId)
|
||||
.then(value)
|
||||
.else(eb.ref("Friendship.isPinnedByUserTwo"))
|
||||
.end(),
|
||||
}))
|
||||
.where("Friendship.id", "=", friendshipId)
|
||||
.where((eb) =>
|
||||
eb.or([
|
||||
eb("Friendship.userOneId", "=", userId),
|
||||
eb("Friendship.userTwoId", "=", userId),
|
||||
]),
|
||||
)
|
||||
.execute();
|
||||
}
|
||||
|
||||
export async function findPendingReceivedRequests(receiverId: number) {
|
||||
return db
|
||||
.selectFrom("FriendRequest")
|
||||
|
||||
@@ -67,6 +67,22 @@ export const action: ActionFunction = async ({ request }) => {
|
||||
|
||||
break;
|
||||
}
|
||||
case "PIN_FRIEND": {
|
||||
await FriendRepository.updateOwnFriendshipPinned({
|
||||
friendshipId: result.data.friendshipId,
|
||||
isPinned: true,
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
case "UNPIN_FRIEND": {
|
||||
await FriendRepository.updateOwnFriendshipPinned({
|
||||
friendshipId: result.data.friendshipId,
|
||||
isPinned: false,
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
case "ACCEPT_REQUEST": {
|
||||
const friendRequest =
|
||||
await FriendRepository.findFriendRequestByIdAndReceiver({
|
||||
|
||||
36
app/features/friends/friends-constants.test.ts
Normal file
36
app/features/friends/friends-constants.test.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { friendSectionSortValue } from "./friends-constants";
|
||||
|
||||
describe("friendSectionSortValue", () => {
|
||||
test.each([
|
||||
{
|
||||
why: "pinned with activity",
|
||||
isPinned: true,
|
||||
activityType: "SENDOUQ",
|
||||
expected: 0,
|
||||
},
|
||||
{
|
||||
why: "unpinned with activity",
|
||||
isPinned: false,
|
||||
activityType: "TOURNAMENT_MATCH",
|
||||
expected: 1,
|
||||
},
|
||||
{
|
||||
why: "pinned without activity",
|
||||
isPinned: true,
|
||||
activityType: null,
|
||||
expected: 2,
|
||||
},
|
||||
{
|
||||
why: "unpinned without activity",
|
||||
isPinned: false,
|
||||
activityType: null,
|
||||
expected: 3,
|
||||
},
|
||||
] as const)(
|
||||
"$why sorts as $expected",
|
||||
({ isPinned, activityType, expected }) => {
|
||||
expect(friendSectionSortValue({ isPinned, activityType })).toBe(expected);
|
||||
},
|
||||
);
|
||||
});
|
||||
@@ -38,3 +38,19 @@ export function friendActivitySortValue(type: FriendActivityType | null) {
|
||||
if (isInProgressFriendActivity(type)) return 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Section of the friends list, pinned friends with activity at the top and idle unpinned ones at the bottom. Lower sorts first. */
|
||||
export function friendSectionSortValue({
|
||||
isPinned,
|
||||
activityType,
|
||||
}: {
|
||||
isPinned: boolean;
|
||||
activityType: FriendActivityType | null;
|
||||
}) {
|
||||
const hasActivity = activityType !== null;
|
||||
|
||||
if (isPinned && hasActivity) return 0;
|
||||
if (hasActivity) return 1;
|
||||
if (isPinned) return 2;
|
||||
return 3;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,9 @@ import {
|
||||
cancelFriendRequestSchema,
|
||||
declineFriendRequestSchema,
|
||||
deleteFriendSchema,
|
||||
pinFriendSchema,
|
||||
sendFriendRequestBaseSchema,
|
||||
unpinFriendSchema,
|
||||
} from "./friends-schemas";
|
||||
|
||||
const sendFriendRequestSchemaServer = v.pipeAsync(
|
||||
@@ -54,4 +56,6 @@ export const friendsActionSchema = v.unionAsync([
|
||||
deleteFriendSchema,
|
||||
acceptFriendRequestSchema,
|
||||
declineFriendRequestSchema,
|
||||
pinFriendSchema,
|
||||
unpinFriendSchema,
|
||||
]);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as v from "valibot";
|
||||
import { stringConstant, userSearch } from "~/form/fields";
|
||||
import { _action, id } from "~/utils/schema";
|
||||
import { _action, id, revalidateRoot } from "~/utils/schema";
|
||||
|
||||
export const sendFriendRequestBaseSchema = v.object({
|
||||
_action: stringConstant("SEND_REQUEST"),
|
||||
@@ -26,3 +26,15 @@ export const declineFriendRequestSchema = v.object({
|
||||
_action: _action("DECLINE_REQUEST"),
|
||||
friendRequestId: id,
|
||||
});
|
||||
|
||||
export const pinFriendSchema = v.object({
|
||||
_action: _action("PIN_FRIEND"),
|
||||
friendshipId: id,
|
||||
revalidateRoot,
|
||||
});
|
||||
|
||||
export const unpinFriendSchema = v.object({
|
||||
_action: _action("UNPIN_FRIEND"),
|
||||
friendshipId: id,
|
||||
revalidateRoot,
|
||||
});
|
||||
|
||||
@@ -4,7 +4,10 @@ import * as FriendSchedule from "~/features/availability/core/FriendSchedule.ser
|
||||
import { getViewerTimezone } from "~/features/timezone/timezone-context.server";
|
||||
import { userPage } from "~/utils/urls";
|
||||
import * as FriendRepository from "../FriendRepository.server";
|
||||
import { friendActivitySortValue } from "../friends-constants";
|
||||
import {
|
||||
friendActivitySortValue,
|
||||
friendSectionSortValue,
|
||||
} from "../friends-constants";
|
||||
import {
|
||||
resolveFriendActivity,
|
||||
resolveSendouQMatchStreams,
|
||||
@@ -63,9 +66,11 @@ export const loader = async () => {
|
||||
tournamentId: activity.tournamentId ?? friend.tournamentId,
|
||||
streamUrl: activity.streamUrl,
|
||||
friendshipCreatedAt: friend.friendshipCreatedAt,
|
||||
isPinned: Boolean(friend.isPinned),
|
||||
schedule: schedules.get(friend.id) ?? null,
|
||||
};
|
||||
}),
|
||||
[(friend) => friendSectionSortValue(friend), "asc"],
|
||||
[(friend) => friendActivitySortValue(friend.activityType), "desc"],
|
||||
[(friend) => (friend.schedule ? 1 : 0), "desc"],
|
||||
[(friend) => friend.friendshipCreatedAt ?? 0, "desc"],
|
||||
@@ -100,6 +105,7 @@ export const loader = async () => {
|
||||
matchId: activity.matchId,
|
||||
tournamentId: activity.tournamentId ?? tm.tournamentId,
|
||||
streamUrl: activity.streamUrl,
|
||||
isPinned: false,
|
||||
schedule: schedules.get(tm.id) ?? null,
|
||||
};
|
||||
}),
|
||||
|
||||
@@ -37,11 +37,20 @@
|
||||
gap: var(--s-1-5);
|
||||
}
|
||||
|
||||
.scheduleSlot {
|
||||
.rowActions {
|
||||
display: flex;
|
||||
gap: var(--s-1-5);
|
||||
margin-block-end: var(--s-1);
|
||||
}
|
||||
|
||||
.actionSlot {
|
||||
display: flex;
|
||||
width: 18px;
|
||||
margin-block-end: var(--s-1);
|
||||
& > button {
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.pinForm {
|
||||
display: contents;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { CalendarDays } from "lucide-react";
|
||||
import { CalendarDays, Pin } from "lucide-react";
|
||||
import * as React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link, type MetaFunction, useLoaderData } from "react-router";
|
||||
import * as R from "remeda";
|
||||
import { ActionButton } from "~/components/ActionButton";
|
||||
import { Avatar } from "~/components/Avatar";
|
||||
import { Divider } from "~/components/Divider";
|
||||
@@ -15,11 +16,14 @@ import { useSearchParam } from "~/modules/search-params/hooks";
|
||||
import { metaTags } from "~/utils/remix";
|
||||
import type { SendouRouteHandle } from "~/utils/remix.server";
|
||||
import { FriendMenu } from "../components/FriendMenu";
|
||||
import { friendSectionSortValue } from "../friends-constants";
|
||||
import {
|
||||
acceptFriendRequestSchema,
|
||||
cancelFriendRequestSchema,
|
||||
declineFriendRequestSchema,
|
||||
pinFriendSchema,
|
||||
sendFriendRequestBaseSchema,
|
||||
unpinFriendSchema,
|
||||
} from "../friends-schemas";
|
||||
import {
|
||||
friendsSearchParams,
|
||||
@@ -212,6 +216,7 @@ function FriendsListSection() {
|
||||
secondary
|
||||
controlled
|
||||
active={filter === value}
|
||||
preventScrollReset
|
||||
>
|
||||
{viewLabels[value]}
|
||||
</SubNavLink>
|
||||
@@ -234,22 +239,71 @@ function FriendsListSection() {
|
||||
}
|
||||
|
||||
function FriendRow({ item }: { item: ShownItem }) {
|
||||
const friendshipId =
|
||||
"friendshipId" in item && typeof item.friendshipId === "number"
|
||||
? item.friendshipId
|
||||
: null;
|
||||
|
||||
return (
|
||||
<div className={styles.friendRow} data-testid={`friend-row-${item.id}`}>
|
||||
<FriendMenu name={item.username} {...item} />
|
||||
<div className={styles.scheduleSlot}>
|
||||
{item.schedule ? (
|
||||
<ScheduleButton
|
||||
userId={item.id}
|
||||
username={item.username}
|
||||
weeks={item.schedule}
|
||||
/>
|
||||
) : null}
|
||||
<div className={styles.rowActions}>
|
||||
<div className={styles.actionSlot}>
|
||||
{item.schedule ? (
|
||||
<ScheduleButton
|
||||
userId={item.id}
|
||||
username={item.username}
|
||||
weeks={item.schedule}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
<div className={styles.actionSlot}>
|
||||
{typeof friendshipId === "number" ? (
|
||||
<PinButton
|
||||
userId={item.id}
|
||||
username={item.username}
|
||||
friendshipId={friendshipId}
|
||||
isPinned={item.isPinned}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function PinButton({
|
||||
userId,
|
||||
username,
|
||||
friendshipId,
|
||||
isPinned,
|
||||
}: {
|
||||
userId: number;
|
||||
username: string;
|
||||
friendshipId: number;
|
||||
isPinned: boolean;
|
||||
}) {
|
||||
const { t } = useTranslation(["friends"]);
|
||||
|
||||
return (
|
||||
<ActionButton
|
||||
schema={isPinned ? unpinFriendSchema : pinFriendSchema}
|
||||
action={isPinned ? "UNPIN_FRIEND" : "PIN_FRIEND"}
|
||||
fields={{ friendshipId, revalidateRoot: true }}
|
||||
formClassName={styles.pinForm}
|
||||
variant="minimal"
|
||||
size="small"
|
||||
icon={<Pin size={18} fill={isPinned ? "currentColor" : "none"} />}
|
||||
aria-label={t(
|
||||
isPinned ? "friends:friendsList.unpin" : "friends:friendsList.pin",
|
||||
{ name: username },
|
||||
)}
|
||||
aria-pressed={isPinned}
|
||||
testId={`friend-pin-button-${userId}`}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function ScheduleButton({
|
||||
userId,
|
||||
username,
|
||||
@@ -298,10 +352,11 @@ function resolveShownItems(
|
||||
...data.teamMembers.filter((tm) => !friendIds.has(tm.id)),
|
||||
];
|
||||
|
||||
// same order the loader sorted each group in: active first, then the ones
|
||||
// who shared a schedule
|
||||
const sortValue = (item: (typeof combined)[number]) =>
|
||||
(item.subtitle ? 2 : 0) + (item.schedule ? 1 : 0);
|
||||
|
||||
return combined.sort((a, b) => sortValue(b) - sortValue(a));
|
||||
// same order the loader sorted each group in: pinned and active first, then
|
||||
// the ones who shared a schedule
|
||||
return R.sortBy(
|
||||
combined,
|
||||
[(item) => friendSectionSortValue(item), "asc"],
|
||||
[(item) => (item.schedule ? 1 : 0), "desc"],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import * as v from "valibot";
|
||||
import { hidden, select, stringConstant, toggle } from "~/form/fields";
|
||||
import { themeInputSchema } from "~/utils/schema";
|
||||
import { revalidateRoot, themeInputSchema } from "~/utils/schema";
|
||||
|
||||
export const customThemeSchema = v.object({
|
||||
_action: stringConstant("UPDATE_CUSTOM_THEME"),
|
||||
newValue: hidden(v.nullable(themeInputSchema), null),
|
||||
revalidateRoot: v.optional(v.nullable(v.literal(true))),
|
||||
revalidateRoot,
|
||||
});
|
||||
|
||||
export const clockFormatSchema = v.object({
|
||||
|
||||
129
app/features/sidebar/core/sidebar.server.test.ts
Normal file
129
app/features/sidebar/core/sidebar.server.test.ts
Normal file
@@ -0,0 +1,129 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import type { FriendActivityType } from "~/features/friends/friends-constants";
|
||||
import { orderSidebarFriends } from "./sidebar.server";
|
||||
|
||||
describe("orderSidebarFriends", () => {
|
||||
test("ranks pinned active, active, pinned idle and idle in that order", () => {
|
||||
const ordered = orderSidebarFriends([
|
||||
entry("idle"),
|
||||
entry("pinnedIdle", { isPinned: true }),
|
||||
entry("active", { activityType: "SENDOUQ_MATCH" }),
|
||||
entry("pinnedActive", {
|
||||
isPinned: true,
|
||||
activityType: "SENDOUQ_MATCH",
|
||||
}),
|
||||
]);
|
||||
|
||||
expect(idsOf(ordered)).toEqual([
|
||||
"pinnedActive",
|
||||
"active",
|
||||
"pinnedIdle",
|
||||
"idle",
|
||||
]);
|
||||
});
|
||||
|
||||
test("keeps the activity quotas in order within a section", () => {
|
||||
const ordered = orderSidebarFriends([
|
||||
entry("q1", { activityType: "SENDOUQ" }),
|
||||
entry("q2", { activityType: "SENDOUQ" }),
|
||||
entry("q3", { activityType: "SENDOUQ" }),
|
||||
entry("sub1", { activityType: "TOURNAMENT_SUB" }),
|
||||
entry("sub2", { activityType: "TOURNAMENT_SUB" }),
|
||||
entry("sub3", { activityType: "TOURNAMENT_SUB" }),
|
||||
entry("match", { activityType: "SENDOUQ_MATCH" }),
|
||||
]);
|
||||
|
||||
expect(idsOf(ordered)).toEqual([
|
||||
"q1",
|
||||
"q2",
|
||||
"sub1",
|
||||
"sub2",
|
||||
"q3",
|
||||
"sub3",
|
||||
"match",
|
||||
]);
|
||||
});
|
||||
|
||||
test("pinning a friend does not disturb the quota order of the rest", () => {
|
||||
const ordered = orderSidebarFriends([
|
||||
entry("q1", { activityType: "SENDOUQ" }),
|
||||
entry("q2", { activityType: "SENDOUQ" }),
|
||||
entry("q3", { activityType: "SENDOUQ", isPinned: true }),
|
||||
entry("sub1", { activityType: "TOURNAMENT_SUB" }),
|
||||
]);
|
||||
|
||||
expect(idsOf(ordered)).toEqual(["q3", "q1", "q2", "sub1"]);
|
||||
});
|
||||
|
||||
test("shows a pinned friend that would otherwise fall past the visible quota", () => {
|
||||
const ordered = orderSidebarFriends([
|
||||
...Array.from({ length: 10 }, (_, i) => entry(`idle${i}`)),
|
||||
entry("pinned", { isPinned: true }),
|
||||
]);
|
||||
|
||||
expect(ordered).toHaveLength(8);
|
||||
expect(idsOf(ordered)[0]).toBe("pinned");
|
||||
});
|
||||
|
||||
test("drops active friends past the visible quota", () => {
|
||||
const ordered = orderSidebarFriends(
|
||||
Array.from({ length: 12 }, (_, i) =>
|
||||
entry(`match${i}`, { activityType: "TOURNAMENT_MATCH" }),
|
||||
),
|
||||
);
|
||||
|
||||
expect(idsOf(ordered)).toEqual([
|
||||
"match0",
|
||||
"match1",
|
||||
"match2",
|
||||
"match3",
|
||||
"match4",
|
||||
"match5",
|
||||
"match6",
|
||||
"match7",
|
||||
]);
|
||||
});
|
||||
|
||||
test("places friends before team members sharing their activity", () => {
|
||||
const ordered = orderSidebarFriends([
|
||||
entry("teamMember", {
|
||||
isFriend: false,
|
||||
activityType: "SENDOUQ_MATCH",
|
||||
}),
|
||||
entry("friend", { activityType: "SENDOUQ_MATCH" }),
|
||||
]);
|
||||
|
||||
expect(idsOf(ordered)).toEqual(["friend", "teamMember"]);
|
||||
});
|
||||
|
||||
test("ranks an active team member above an idle friend", () => {
|
||||
const ordered = orderSidebarFriends([
|
||||
entry("idleFriend"),
|
||||
entry("activeTeamMember", {
|
||||
isFriend: false,
|
||||
activityType: "SENDOUQ",
|
||||
}),
|
||||
]);
|
||||
|
||||
expect(idsOf(ordered)).toEqual(["activeTeamMember", "idleFriend"]);
|
||||
});
|
||||
});
|
||||
|
||||
function entry(
|
||||
id: string,
|
||||
{
|
||||
isFriend = true,
|
||||
isPinned = false,
|
||||
activityType = null,
|
||||
}: {
|
||||
isFriend?: boolean;
|
||||
isPinned?: boolean;
|
||||
activityType?: FriendActivityType | null;
|
||||
} = {},
|
||||
) {
|
||||
return { id, isFriend, isPinned, activityType };
|
||||
}
|
||||
|
||||
function idsOf(entries: Array<{ id: string }>) {
|
||||
return entries.map(({ id }) => id);
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
import * as FriendRepository from "~/features/friends/FriendRepository.server";
|
||||
import {
|
||||
type FriendActivityType,
|
||||
friendSectionSortValue,
|
||||
isInProgressFriendActivity,
|
||||
} from "~/features/friends/friends-constants";
|
||||
import {
|
||||
@@ -330,8 +331,8 @@ function resolveFriends(
|
||||
friendsWithActivity: FriendWithActivity[],
|
||||
streamedSendouQMatches: ReadonlyMap<number, string>,
|
||||
) {
|
||||
const activityForRow = (row: FriendWithActivity) =>
|
||||
resolveFriendActivity({
|
||||
const entries = R.uniqueBy(friendsWithActivity, (f) => f.id).map((row) => {
|
||||
const activity = resolveFriendActivity({
|
||||
friendId: row.id,
|
||||
tournamentId: row.tournamentId,
|
||||
tournamentName: row.tournamentName,
|
||||
@@ -340,91 +341,69 @@ function resolveFriends(
|
||||
sendouQMatchStreams: streamedSendouQMatches,
|
||||
});
|
||||
|
||||
const unique = R.uniqueBy(friendsWithActivity, (f) => f.id);
|
||||
const friendRows = unique.filter((f) => f.friendshipId !== null);
|
||||
const teamMemberRows = unique.filter((f) => f.friendshipId === null);
|
||||
return {
|
||||
row,
|
||||
activity,
|
||||
isFriend: row.friendshipId !== null,
|
||||
isPinned: Boolean(row.isPinned),
|
||||
activityType: activity.type,
|
||||
};
|
||||
});
|
||||
|
||||
const activeFriends: SidebarFriend[] = [];
|
||||
const sendouqFriends: SidebarFriend[] = [];
|
||||
const tournamentSubFriends: SidebarFriend[] = [];
|
||||
const inactiveFriends: FriendWithActivity[] = [];
|
||||
return orderSidebarFriends(entries).map(({ row, activity }) =>
|
||||
rowToSidebarFriend(row, activity),
|
||||
);
|
||||
}
|
||||
|
||||
for (const friend of friendRows) {
|
||||
const activity = activityForRow(friend);
|
||||
type OrderableFriend = {
|
||||
/** Mutual friend rather than a team member shown alongside them. */
|
||||
isFriend: boolean;
|
||||
isPinned: boolean;
|
||||
activityType: FriendActivityType | null;
|
||||
};
|
||||
|
||||
if (!activity.type) {
|
||||
inactiveFriends.push(friend);
|
||||
continue;
|
||||
}
|
||||
/** Pinned friends with activity, the rest with activity, pinned idle friends, the rest, truncated to what fits. Each section keeps its own order of activity type quotas, friends before team members. */
|
||||
export function orderSidebarFriends<T extends OrderableFriend>(entries: T[]) {
|
||||
const friends = entries.filter(({ isFriend }) => isFriend);
|
||||
const teamMembers = entries.filter(({ isFriend }) => !isFriend);
|
||||
|
||||
const sidebarFriend = rowToSidebarFriend(friend, activity);
|
||||
const sendouqFriends = friends.filter(
|
||||
({ activityType }) => activityType === "SENDOUQ",
|
||||
);
|
||||
const tournamentSubFriends = friends.filter(
|
||||
({ activityType }) => activityType === "TOURNAMENT_SUB",
|
||||
);
|
||||
const inMatchFriends = friends.filter(({ activityType }) =>
|
||||
isInProgressFriendActivity(activityType),
|
||||
);
|
||||
const idleFriends = friends.filter(({ activityType }) => !activityType);
|
||||
const activeTeamMembers = teamMembers.filter(
|
||||
({ activityType }) => activityType,
|
||||
);
|
||||
const idleTeamMembers = teamMembers.filter(
|
||||
({ activityType }) => !activityType,
|
||||
);
|
||||
|
||||
if (isInProgressFriendActivity(activity.type)) {
|
||||
activeFriends.push(sidebarFriend);
|
||||
} else if (activity.type === "SENDOUQ") {
|
||||
sendouqFriends.push(sidebarFriend);
|
||||
} else {
|
||||
tournamentSubFriends.push(sidebarFriend);
|
||||
}
|
||||
}
|
||||
const ordered = [
|
||||
...sendouqFriends.slice(0, SENDOUQ_QUOTA),
|
||||
...tournamentSubFriends.slice(0, TOURNAMENT_SUB_QUOTA),
|
||||
...sendouqFriends.slice(SENDOUQ_QUOTA),
|
||||
...tournamentSubFriends.slice(TOURNAMENT_SUB_QUOTA),
|
||||
...inMatchFriends,
|
||||
...activeTeamMembers,
|
||||
...idleFriends,
|
||||
...idleTeamMembers,
|
||||
];
|
||||
|
||||
const result: SidebarFriend[] = [];
|
||||
|
||||
const sendouqToShow = sendouqFriends.slice(0, SENDOUQ_QUOTA);
|
||||
const tournamentToShow = tournamentSubFriends.slice(0, TOURNAMENT_SUB_QUOTA);
|
||||
|
||||
result.push(...sendouqToShow, ...tournamentToShow);
|
||||
|
||||
const remaining = MAX_FRIENDS_VISIBLE - result.length;
|
||||
if (remaining > 0) {
|
||||
const extraSendouq = sendouqFriends.slice(SENDOUQ_QUOTA);
|
||||
const extraTournament = tournamentSubFriends.slice(TOURNAMENT_SUB_QUOTA);
|
||||
result.push(...[...extraSendouq, ...extraTournament].slice(0, remaining));
|
||||
}
|
||||
|
||||
if (result.length < MAX_FRIENDS_VISIBLE) {
|
||||
result.push(...activeFriends.slice(0, MAX_FRIENDS_VISIBLE - result.length));
|
||||
}
|
||||
|
||||
if (result.length < MAX_FRIENDS_VISIBLE) {
|
||||
const shownIds = new Set(result.map((f) => f.id));
|
||||
const inactiveTeamMembers: FriendWithActivity[] = [];
|
||||
|
||||
for (const tm of teamMemberRows) {
|
||||
if (result.length >= MAX_FRIENDS_VISIBLE) break;
|
||||
if (shownIds.has(tm.id)) continue;
|
||||
|
||||
const activity = activityForRow(tm);
|
||||
if (!activity.type) {
|
||||
inactiveTeamMembers.push(tm);
|
||||
continue;
|
||||
}
|
||||
|
||||
result.push(rowToSidebarFriend(tm, activity));
|
||||
shownIds.add(tm.id);
|
||||
}
|
||||
|
||||
for (const friend of inactiveFriends) {
|
||||
if (result.length >= MAX_FRIENDS_VISIBLE) break;
|
||||
if (shownIds.has(friend.id)) continue;
|
||||
|
||||
result.push(rowToSidebarFriend(friend, null));
|
||||
shownIds.add(friend.id);
|
||||
}
|
||||
|
||||
for (const tm of inactiveTeamMembers) {
|
||||
if (result.length >= MAX_FRIENDS_VISIBLE) break;
|
||||
|
||||
result.push(rowToSidebarFriend(tm, null));
|
||||
}
|
||||
}
|
||||
|
||||
return result.slice(0, MAX_FRIENDS_VISIBLE);
|
||||
return R.sortBy(ordered, friendSectionSortValue).slice(
|
||||
0,
|
||||
MAX_FRIENDS_VISIBLE,
|
||||
);
|
||||
}
|
||||
|
||||
function rowToSidebarFriend(
|
||||
row: FriendWithActivity,
|
||||
activity: FriendActivity | null,
|
||||
activity: FriendActivity,
|
||||
): SidebarFriend {
|
||||
return {
|
||||
id: row.id,
|
||||
@@ -433,12 +412,12 @@ function rowToSidebarFriend(
|
||||
discordAvatar: row.discordAvatar,
|
||||
customAvatarUrl: row.customAvatarUrl,
|
||||
url: userPage({ discordId: row.discordId, customUrl: row.customUrl }),
|
||||
subtitle: activity?.subtitle ?? "",
|
||||
badge: activity?.badge ?? "",
|
||||
activityType: activity?.type ?? null,
|
||||
matchId: activity?.matchId ?? null,
|
||||
tournamentId: activity?.tournamentId ?? row.tournamentId,
|
||||
streamUrl: activity?.streamUrl ?? null,
|
||||
subtitle: activity.subtitle ?? "",
|
||||
badge: activity.badge ?? "",
|
||||
activityType: activity.type,
|
||||
matchId: activity.matchId,
|
||||
tournamentId: activity.tournamentId ?? row.tournamentId,
|
||||
streamUrl: activity.streamUrl,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -510,6 +510,11 @@ export function checkboxValueToBoolean(value: unknown) {
|
||||
export const _action = <T extends string>(value: T) =>
|
||||
preprocess(deduplicate, v.literal(value));
|
||||
|
||||
/** Marker field asking the root loader to revalidate too (see `shouldRevalidate` in root.tsx), `true` in a JSON body and `"true"` in form data. */
|
||||
export const revalidateRoot = v.optional(
|
||||
v.nullable(v.union([v.literal(true), v.literal("true")])),
|
||||
);
|
||||
|
||||
/** Works around a bug at least in Safari 15 where a SubmitButton value might get sent twice */
|
||||
export function deduplicate(value: unknown) {
|
||||
if (Array.isArray(value)) {
|
||||
|
||||
4
changelog/2026-09-20-pin-friends.md
Normal file
4
changelog/2026-09-20-pin-friends.md
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
type: feature
|
||||
---
|
||||
Friends can be pinned from the friends page, keeping them at the top of the friends list and the sidebar
|
||||
5
changelog/2026-09-20-tab-scroll-reset.md
Normal file
5
changelog/2026-09-20-tab-scroll-reset.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
navItem: calendar
|
||||
type: bug
|
||||
---
|
||||
Switching tabs on the friends and events pages no longer scrolls back to the top
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
} from "./helpers/sidebar";
|
||||
import { FriendsPage } from "./pages/friends/friends-page";
|
||||
import { NotificationPopover } from "./pages/layout/notification-popover";
|
||||
import { SideNav } from "./pages/layout/side-nav";
|
||||
|
||||
const WEDNESDAY = 2;
|
||||
|
||||
@@ -114,6 +115,64 @@ test.describe("Friends", () => {
|
||||
await friends.locators.nextWeekToggle.click();
|
||||
await expect(friends.locators.noScheduleText).toBeVisible();
|
||||
});
|
||||
|
||||
test("pinned friends sort to the top of their section on the page and in the sidebar", async ({
|
||||
page,
|
||||
factories,
|
||||
}) => {
|
||||
const [pinnedQueueing, queueing, pinnedIdle, idle] = await createNamedUsers(
|
||||
factories,
|
||||
["PinQueue", "PlainQueue", "PinIdle", "PlainIdle"],
|
||||
);
|
||||
await befriend(
|
||||
factories,
|
||||
[idle.id, pinnedIdle.id, queueing.id, pinnedQueueing.id],
|
||||
ADMIN_ID,
|
||||
);
|
||||
await factories.SQGroupFactory.create({ memberUserIds: [queueing.id] });
|
||||
await factories.SQGroupFactory.create({
|
||||
memberUserIds: [pinnedQueueing.id],
|
||||
});
|
||||
|
||||
await impersonate(page, ADMIN_ID);
|
||||
|
||||
const friends = new FriendsPage(page);
|
||||
await friends.goto();
|
||||
|
||||
await friends.togglePin(pinnedIdle.id);
|
||||
await friends.togglePin(pinnedQueueing.id);
|
||||
await expect(friends.pinButton(pinnedIdle.id)).toHaveAttribute(
|
||||
"aria-pressed",
|
||||
"true",
|
||||
);
|
||||
await expect(friends.pinButton(idle.id)).toHaveAttribute(
|
||||
"aria-pressed",
|
||||
"false",
|
||||
);
|
||||
|
||||
await expectTopToBottom([
|
||||
friends.row(pinnedQueueing.id),
|
||||
friends.row(queueing.id),
|
||||
friends.row(pinnedIdle.id),
|
||||
friends.row(idle.id),
|
||||
]);
|
||||
|
||||
// the sidebar refreshes with the page, no navigation needed
|
||||
const sideNav = new SideNav(page);
|
||||
await expectTopToBottom([
|
||||
sideNav.friend("PinQueue").trigger,
|
||||
sideNav.friend("PlainQueue").trigger,
|
||||
sideNav.friend("PinIdle").trigger,
|
||||
sideNav.friend("PlainIdle").trigger,
|
||||
]);
|
||||
|
||||
await friends.goto();
|
||||
await friends.togglePin(pinnedIdle.id);
|
||||
await expect(friends.pinButton(pinnedIdle.id)).toHaveAttribute(
|
||||
"aria-pressed",
|
||||
"false",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
function daySlot(dayIndex: number, start: string, end: string) {
|
||||
|
||||
@@ -52,9 +52,11 @@ export class FriendsPage {
|
||||
);
|
||||
}
|
||||
|
||||
/** Scoped to the page content: the mobile friends panel still shows the same name for a frame after navigating here from it. */
|
||||
/** Scoped to the page content: the mobile friends panel still shows the same name for a frame after navigating here from it. Exact, as the pin button's label names the friend too. */
|
||||
friendButton(name: string) {
|
||||
return this.page.getByRole("main").getByRole("button", { name });
|
||||
return this.page
|
||||
.getByRole("main")
|
||||
.getByRole("button", { name, exact: true });
|
||||
}
|
||||
|
||||
friend(name: string) {
|
||||
@@ -69,6 +71,14 @@ export class FriendsPage {
|
||||
return this.page.getByTestId(`friend-schedule-button-${userId}`);
|
||||
}
|
||||
|
||||
pinButton(userId: number) {
|
||||
return this.page.getByTestId(`friend-pin-button-${userId}`);
|
||||
}
|
||||
|
||||
async togglePin(userId: number) {
|
||||
await waitForPOSTResponse(this.page, () => this.pinButton(userId).click());
|
||||
}
|
||||
|
||||
/** One day row of the open week modal, Monday being 0. */
|
||||
day(dayIndex: number) {
|
||||
return this.locators.scheduleDays.getByRole("listitem").nth(dayIndex);
|
||||
@@ -82,8 +92,11 @@ class FriendMenu {
|
||||
constructor(page: Page, name: string) {
|
||||
this.page = page;
|
||||
// scoped to the page content because the sidebar's friends section shows
|
||||
// a button with the same name once the friendship data refreshes
|
||||
this.trigger = page.getByRole("main").getByRole("button", { name });
|
||||
// a button with the same name once the friendship data refreshes, exact
|
||||
// because the pin button's label names the friend too
|
||||
this.trigger = page
|
||||
.getByRole("main")
|
||||
.getByRole("button", { name, exact: true });
|
||||
}
|
||||
|
||||
async deleteFriend() {
|
||||
|
||||
@@ -21,5 +21,7 @@
|
||||
"view.all": "",
|
||||
"teamMembers.empty": "",
|
||||
"unseenRequests_one": "",
|
||||
"unseenRequests_other": ""
|
||||
"unseenRequests_other": "",
|
||||
"friendsList.pin": "",
|
||||
"friendsList.unpin": ""
|
||||
}
|
||||
|
||||
@@ -21,5 +21,7 @@
|
||||
"view.all": "",
|
||||
"teamMembers.empty": "",
|
||||
"unseenRequests_one": "",
|
||||
"unseenRequests_other": ""
|
||||
"unseenRequests_other": "",
|
||||
"friendsList.pin": "",
|
||||
"friendsList.unpin": ""
|
||||
}
|
||||
|
||||
@@ -21,5 +21,7 @@
|
||||
"view.all": "All",
|
||||
"teamMembers.empty": "No team members yet",
|
||||
"unseenRequests_one": "{{count}} unseen friend request",
|
||||
"unseenRequests_other": "{{count}} unseen friend requests"
|
||||
"unseenRequests_other": "{{count}} unseen friend requests",
|
||||
"friendsList.pin": "Pin {{name}} to the top",
|
||||
"friendsList.unpin": "Unpin {{name}}"
|
||||
}
|
||||
|
||||
@@ -22,5 +22,7 @@
|
||||
"teamMembers.empty": "Aún no hay miembros en el equipo",
|
||||
"unseenRequests_one": "{{count}} solicitud de amistad sin ver",
|
||||
"unseenRequests_many": "",
|
||||
"unseenRequests_other": "{{count}} solicitudes de amistad sin ver"
|
||||
"unseenRequests_other": "{{count}} solicitudes de amistad sin ver",
|
||||
"friendsList.pin": "",
|
||||
"friendsList.unpin": ""
|
||||
}
|
||||
|
||||
@@ -22,5 +22,7 @@
|
||||
"teamMembers.empty": "Aún no hay miembros en el equipo",
|
||||
"unseenRequests_one": "{{count}} solicitud de amistad sin ver",
|
||||
"unseenRequests_many": "",
|
||||
"unseenRequests_other": "{{count}} solicitudes de amistad sin ver"
|
||||
"unseenRequests_other": "{{count}} solicitudes de amistad sin ver",
|
||||
"friendsList.pin": "",
|
||||
"friendsList.unpin": ""
|
||||
}
|
||||
|
||||
@@ -22,5 +22,7 @@
|
||||
"teamMembers.empty": "",
|
||||
"unseenRequests_one": "",
|
||||
"unseenRequests_many": "",
|
||||
"unseenRequests_other": ""
|
||||
"unseenRequests_other": "",
|
||||
"friendsList.pin": "",
|
||||
"friendsList.unpin": ""
|
||||
}
|
||||
|
||||
@@ -22,5 +22,7 @@
|
||||
"teamMembers.empty": "",
|
||||
"unseenRequests_one": "",
|
||||
"unseenRequests_many": "",
|
||||
"unseenRequests_other": ""
|
||||
"unseenRequests_other": "",
|
||||
"friendsList.pin": "",
|
||||
"friendsList.unpin": ""
|
||||
}
|
||||
|
||||
@@ -22,5 +22,7 @@
|
||||
"teamMembers.empty": "",
|
||||
"unseenRequests_one": "",
|
||||
"unseenRequests_two": "",
|
||||
"unseenRequests_other": ""
|
||||
"unseenRequests_other": "",
|
||||
"friendsList.pin": "",
|
||||
"friendsList.unpin": ""
|
||||
}
|
||||
|
||||
@@ -22,5 +22,7 @@
|
||||
"teamMembers.empty": "",
|
||||
"unseenRequests_one": "",
|
||||
"unseenRequests_many": "",
|
||||
"unseenRequests_other": ""
|
||||
"unseenRequests_other": "",
|
||||
"friendsList.pin": "",
|
||||
"friendsList.unpin": ""
|
||||
}
|
||||
|
||||
@@ -19,5 +19,7 @@
|
||||
"view.friends": "",
|
||||
"view.teamMembers": "",
|
||||
"view.all": "",
|
||||
"teamMembers.empty": ""
|
||||
"teamMembers.empty": "",
|
||||
"friendsList.pin": "",
|
||||
"friendsList.unpin": ""
|
||||
}
|
||||
|
||||
@@ -19,5 +19,7 @@
|
||||
"view.friends": "",
|
||||
"view.teamMembers": "",
|
||||
"view.all": "",
|
||||
"teamMembers.empty": ""
|
||||
"teamMembers.empty": "",
|
||||
"friendsList.pin": "",
|
||||
"friendsList.unpin": ""
|
||||
}
|
||||
|
||||
@@ -21,5 +21,7 @@
|
||||
"view.all": "",
|
||||
"teamMembers.empty": "",
|
||||
"unseenRequests_one": "",
|
||||
"unseenRequests_other": ""
|
||||
"unseenRequests_other": "",
|
||||
"friendsList.pin": "",
|
||||
"friendsList.unpin": ""
|
||||
}
|
||||
|
||||
@@ -23,5 +23,7 @@
|
||||
"unseenRequests_one": "",
|
||||
"unseenRequests_few": "",
|
||||
"unseenRequests_many": "",
|
||||
"unseenRequests_other": ""
|
||||
"unseenRequests_other": "",
|
||||
"friendsList.pin": "",
|
||||
"friendsList.unpin": ""
|
||||
}
|
||||
|
||||
@@ -22,5 +22,7 @@
|
||||
"teamMembers.empty": "",
|
||||
"unseenRequests_one": "",
|
||||
"unseenRequests_many": "",
|
||||
"unseenRequests_other": ""
|
||||
"unseenRequests_other": "",
|
||||
"friendsList.pin": "",
|
||||
"friendsList.unpin": ""
|
||||
}
|
||||
|
||||
@@ -23,5 +23,7 @@
|
||||
"unseenRequests_one": "",
|
||||
"unseenRequests_few": "",
|
||||
"unseenRequests_many": "",
|
||||
"unseenRequests_other": ""
|
||||
"unseenRequests_other": "",
|
||||
"friendsList.pin": "",
|
||||
"friendsList.unpin": ""
|
||||
}
|
||||
|
||||
@@ -20,5 +20,7 @@
|
||||
"view.teamMembers": "队伍成员",
|
||||
"view.all": "全部",
|
||||
"teamMembers.empty": "暂无队伍成员",
|
||||
"unseenRequests": "有 {{count}} 条未查看的好友请求"
|
||||
"unseenRequests": "有 {{count}} 条未查看的好友请求",
|
||||
"friendsList.pin": "",
|
||||
"friendsList.unpin": ""
|
||||
}
|
||||
|
||||
19
migrations/20260920115346-friendship-pinned.ts
Normal file
19
migrations/20260920115346-friendship-pinned.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import type { Kysely } from "kysely";
|
||||
|
||||
/** Either side of a friendship can pin it to the top of their friends list */
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await db.transaction().execute(async (trx) => {
|
||||
await trx.schema
|
||||
.alterTable("Friendship")
|
||||
.addColumn("isPinnedByUserOne", "integer", (col) =>
|
||||
col.notNull().defaultTo(0),
|
||||
)
|
||||
.execute();
|
||||
await trx.schema
|
||||
.alterTable("Friendship")
|
||||
.addColumn("isPinnedByUserTwo", "integer", (col) =>
|
||||
col.notNull().defaultTo(0),
|
||||
)
|
||||
.execute();
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user