Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port upstream commits into lavender #9

Merged
merged 13 commits into from
Dec 27, 2024
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"varsIgnorePattern": "^_"
}
],
"solid/jsx-no-undef": [0],
"require-jsdoc": [
"warn",
{
Expand Down
2 changes: 1 addition & 1 deletion GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ I am still working on putting stuff together, but here are some important things
- Comment above all classes, constants, Solid components, constructors, methods which do not override the parent class and functions.
- If you have relatively long and / or complex code, either explain what it does in the method / function comment or in-line reasonable comments throughout to make it easy to follow through.
- Avoid importing external libraries in more than one component, re-export where appropriate.
- Import only types where necessary, such as `revolt.js` in `@revolt/ui`.
- Import only types where necessary, such as `@upryzing/upryzing.js` in `@revolt/ui`.

Also another major thing: **accessibility!**

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cd lavender
# git submodule init && git submodule update

# install all packages
pnpm i
pnpm i --frozen-lockfile
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is --frozen-lockfile here?

When developing, it's important that we keep the lockfile up to date, --frozen-lockfile should only be used in CI/CD environments (imo)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have 0 clue, ask the guy who put it on upstream

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I think its less for developers and more for users that just want newer commits

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, maybe.

Might add a disclaimer on the README then


# build deps:
pnpm build:deps
Expand Down Expand Up @@ -55,7 +55,7 @@ Any edits to the `uprzying.js` codebase will immediately be reflected while deve

```bash
# install packages
pnpm i
pnpm i --frozen-lockfile
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refer to my previous comment


# build dependencies
pnpm build:deps
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"test:browser:regression": "pnpm --filter browser-test-runner exec playwright test regression",
"test:browser:report": "pnpm --filter browser-test-runner exec playwright show-report",
"lint": "eslint --ext .ts,.tsx components/ packages/",
"lint:fix": "pnpm lint --fix",
"lint:fix": "eslint --fix --ext .ts,.tsx packages/client",
"dev:web": "pnpm --filter @upryzing/lavender dev",
"dev:desktop": "pnpm --filter @upryzing/lavender-desktop tauri dev",
"build:deps": "pnpm --filter @upryzing/upryzing.js build",
Expand All @@ -20,6 +20,9 @@
"fmt:check": "prettier --check '**/*.{ts,tsx,json}'",
"typecheck": "cd packages/client && pnpm run typecheck"
},
"devDependencies": {
"eslint": "^8.49.0"
},
"keywords": [],
"engines": {
"node": ">=18",
Expand Down
7 changes: 5 additions & 2 deletions packages/client/.env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# specify custom API URL
VITE_API_URL=
# connect to local Upryzing instance
VITE_API_URL=http://localhost:14702
VITE_WS_URL=ws://localhost:14703
VITE_MEDIA_URL=http://localhost:14704
VITE_PROXY_URL=http://localhost:14705

# specify hCaptcha sitekey
VITE_HCAPTCHA_SITEKEY=
Expand Down
2 changes: 1 addition & 1 deletion packages/client/codegen.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const directiveRegex = new RegExp("use:(" + DIRECTIVES.join("|") + ")");
export default function codegenPlugin() {
return {
name: "codegen",
enforce: "pre",
enforce: "pre" as const,
transform(src: string, id: string) {
if (fileRegex.test(id)) {
src = src.replace(codegenRegex, (substring, group1) => {
Expand Down
40 changes: 19 additions & 21 deletions packages/client/components/app/interface/channels/text/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import MdNotificationsOff from "@material-design-icons/svg/filled/notifications_
import MdShield from "@material-design-icons/svg/filled/shield.svg?component-solid";
import MdSmartToy from "@material-design-icons/svg/filled/smart_toy.svg?component-solid";
import MdSpa from "@material-design-icons/svg/filled/spa.svg?component-solid";
import MdSchedule from "@material-design-icons/svg/filled/schedule.svg?component-solid";

import { MessageContextMenu } from "../../../menus/MessageContextMenu";
import {
Expand Down Expand Up @@ -103,6 +102,7 @@ export function Message(props: Props) {
}
avatar={
<AvatarContainer
// @ts-expect-error this is a hack; replace with plain element & panda-css
use:floating={floatingUserMenusFromMessage(props.message)}
>
<Avatar size={36} src={props.message.avatarURL} />
Expand Down Expand Up @@ -164,20 +164,17 @@ export function Message(props: Props) {
</Tooltip>
</Match>
<Match when={props.message.webhook}>
<Tooltip content={t("app.main.channel.webhook")} placement="top">
<MdCloud {...iconSize(16)} />
</Tooltip>
</Match>
<Match when={props.message.webhook}>
<Tooltip content={t("app.main.channel.webhook")} placement="top">
<Tooltip
content={
"Webhook"

// TODO: missing i18n
}
placement="top"
>
<MdCloud {...iconSize(16)} />
</Tooltip>
</Match>
<Match when={props.message.member?.timeout}>
<Tooltip content={`User has been timed out for ${dayjs(props.message.member?.timeout).toNow(true)}`} placement="top">
<MdSchedule {...iconSize(16)} />
</Tooltip>
</Match>
Comment on lines -176 to -180
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you seem to have accidentally removed the timeout indicator

<Match when={props.message.isSuppressed}>
<Tooltip content={"Silent" /* TODO: i18n */} placement="top">
<MdNotificationsOff {...iconSize(16)} />
Expand Down Expand Up @@ -207,11 +204,10 @@ export function Message(props: Props) {
</Tooltip>
</NewUser>
</Match>
{/* pronounce example
<Match when={props.message.authorId === "01EX2NCWQ0CHS3QJF0FEQS1GR4"}>
<Match when={props.message.authorId === "01JENZCKGRKNQEN0W3XXWTJQS7"}>
<span />
<span>he/him &middot; </span>
</Match> */}
<span>she/her &middot; </span>
</Match>
</Switch>
}
compact={
Expand All @@ -235,10 +231,10 @@ export function Message(props: Props) {
menuGenerator={(user) =>
user
? floatingUserMenus(
user!,
// TODO: try to fetch on demand member
props.message.server?.getMember(user!.id)
)
user!,
// TODO: try to fetch on demand member
props.message.server?.getMember(user!.id)
)
: {}
}
isServer={!!props.message.server}
Expand All @@ -260,7 +256,9 @@ export function Message(props: Props) {
</For>
</Show>
<Reactions
reactions={props.message.reactions}
reactions={
props.message.reactions as never as Map<string, Set<string>>
}
interactions={props.message.interactions}
userId={client().user!.id}
addReaction={react}
Expand Down
30 changes: 15 additions & 15 deletions packages/client/components/app/interface/channels/text/Messages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -816,23 +816,23 @@ const Padding = styled.div`
*/
type ListEntry =
| {
// Message
t: 0;
message: MessageInterface;
tail: boolean;
highlight: boolean;
}
// Message
t: 0;
message: MessageInterface;
tail: boolean;
highlight: boolean;
}
| {
// Message Divider
t: 1;
date?: string;
unread?: boolean;
}
// Message Divider
t: 1;
date?: string;
unread?: boolean;
}
| {
// Blocked messages
t: 2;
count: number;
};
// Blocked messages
t: 2;
count: number;
};

/**
* Render individual list entry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ const Config: SettingsConfiguration<Channel> = {
return webhook!.name;
}

return t(`app.settings.channel_pages.${key.replaceAll("/", ".")}.title`);
return t(
`app.settings.channel_pages.${key.replaceAll("/", ".")}.title` as any
);
},

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default function ServerOverview(props: ServerSettingsProps) {
</FormGroup>
<FormGroup>
<CategoryButton
description="Server can be joined from Discover"
description="Space can be joined from Discover"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: i18n

icon={<BiRegularGlobe size={24} />}
action={
<Checkbox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const Config: SettingsConfiguration<Server> = {
title(key) {
const t = useTranslation();
return t(
`app.settings.server_pages.${key.replaceAll("/", ".")}.title`,
`app.settings.server_pages.${key.replaceAll("/", ".")}.title` as any,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Um, doesn't eslint complain about using any here?

Either way, the proper type here should be string

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its either eslint warning or TS error

undefined,
key
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
Accessor,
type Accessor,
Match,
Show,
Switch,
Expand Down Expand Up @@ -41,7 +41,7 @@ import MdVerifiedUser from "@material-design-icons/svg/outlined/verified_user.sv

import { useSettingsNavigation } from "../Settings";

import { UserSummary } from "./account";
import { UserSummary } from "./account/index";

/**
* Account Page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ export default function Feedback() {
return (
<Column gap="lg">
<CategoryButtonGroup>
{/* TODO: uncomment or delete once we're certain on what we're doing irt a roadmap
<Link
{/*<Link
href="https://github.com/orgs/revoltchat/projects/6/views/4"
target="_blank"
>
Expand All @@ -35,10 +34,9 @@ export default function Feedback() {
>
Roadmap
</CategoryButton>
</Link>
*/}
<Link
href="https://github.com/orgs/revoltchat/discussions"
</Link>
*/}<Link
href="https://github.com/orgs/upryzing/discussions"
amycatgirl marked this conversation as resolved.
Show resolved Hide resolved
target="_blank"
>
<CategoryButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ export default function Keybinds() {

const translateCombo = (combo: KeyCombo, short: boolean) =>
combo
.map((key) => t(`keys.${key}.${short ? "short" : "full"}`, {}, key))
.map((key) =>
t(`keys.${key}.${short ? "short" : "full"}` as any, {}, key)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, string type instead of any.

)
.join("+");

const translateSequence = (sequence: KeyComboSequence, short: boolean) =>
Expand Down Expand Up @@ -94,8 +96,12 @@ export default function Keybinds() {
.flat()
.map((action) => [
action,
t(`app.settings.pages.keybinds.action.${action}.description`) as string,
t(`app.settings.pages.keybinds.action.${action}.title`) as string,
t(
`app.settings.pages.keybinds.action.${action}.description` as any
) as string,
t(
`app.settings.pages.keybinds.action.${action}.title` as any
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the template string being casted to any here and in all of these translation functions?

It's driving me crazy

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it isn't, it throws TS2345, presumably due to a nonexistent key?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did see some changes on the translation function so maybe it's due to those?

Reviewing through github is a bit of a pain, let alone doing it through vscode (i always forget how to add comments on prs), so I might pull this locally and check what type it expects

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did see some changes on the translation function so maybe it's due to those?

Reviewing through github is a bit of a pain, let alone doing it through vscode (i always forget how to add comments on prs), so I might pull this locally and check what type it expects

Argument of type '"app.settings.pages.keybinds.action.navigate_channel_up.title" | "app.settings.pages.keybinds.action.navigate_channel_down.title" | "app.settings.pages.keybinds.action.navigate_server_up.title" | ... 13 more ... | "app.settings.pages.keybinds.action.navigate_previous_context_settings.title"' is not assignable to parameter of type '"keys" | "general" | "actions" | "login" | "app" | "quantities" | "dayjs" | "notifications" | "error" | "shortcuts" | "permissions" | "keys.Delete" | "keys.Backspace" | "keys.Escape" | ... 931 more ... | "shortcuts.ctrlc"'.
  Type '"app.settings.pages.keybinds.action.navigate_previous_context_modal.title"' is not assignable to type '"keys" | "general" | "actions" | "login" | "app" | "quantities" | "dayjs" | "notifications" | "error" | "shortcuts" | "permissions" | "keys.Delete" | "keys.Backspace" | "keys.Escape" | ... 931 more ... | "shortcuts.ctrlc"'. Did you mean '"app.settings.pages.keybinds.action.navigate_previous_context.title"'?

Have fun with that

) as string,
...state.keybinds
.getKeybinds()
[action].flatMap((sequence) => [
Expand Down Expand Up @@ -135,7 +141,7 @@ export default function Keybinds() {
<For each={filteredData()}>
{([category, actions]) => (
<CategoryCollapse
title={t(`app.settings.pages.keybinds.category.${category}`)}
title={t(`app.settings.pages.keybinds.category.${category}` as any)}
// TODO: open={category !== "advanced"}
>
<Column group="6px">
Expand All @@ -144,12 +150,14 @@ export default function Keybinds() {
<ActionCategory>
<CategoryButton
description={t(
`app.settings.pages.keybinds.action.${action}.description`
`app.settings.pages.keybinds.action.${action}.description` as any
)}
action={<BiSolidPlusCircle size={24} />}
onClick={() => addKeybind(action)}
>
{t(`app.settings.pages.keybinds.action.${action}.title`)}
{t(
`app.settings.pages.keybinds.action.${action}.title` as any
)}
</CategoryButton>
<For each={state.keybinds.getKeybinds()[action]}>
{(sequence, index) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
Languages,
browserPreferredLanguage,
language,
loadAndSetLanguage,
setLanguage,
useTranslation,
} from "@revolt/i18n";
import { UnicodeEmoji } from "@revolt/markdown/emoji";
Expand Down Expand Up @@ -101,7 +101,7 @@ function PickLanguage() {
<CategoryButton
icon={<UnicodeEmoji emoji={lang.emoji} />}
action={<Checkbox value={id === language()} />}
onClick={() => loadAndSetLanguage(id as never)}
onClick={() => setLanguage(id as never)}
>
<Row>
{lang.display}{" "}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export function UserSummary(props: {
const bannerStyle = () =>
props.bannerUrl
? {
"background-image": `linear-gradient(${theme.colours["user-banner-gradient"]}, ${theme.colours["user-banner-gradient"]}), url("${props.bannerUrl}")`,
}
"background-image": `linear-gradient(${theme.colours["user-banner-gradient"]}, ${theme.colours["user-banner-gradient"]}), url("${props.bannerUrl}")`,
}
: {
background: `var(--colours-settings-background)`,
};
background: `var(--colours-settings-background)`,
};

return (
<CategoryButtonGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import MdPublic from "@material-design-icons/svg/outlined/public.svg?component-s
import MdToken from "@material-design-icons/svg/outlined/token.svg?component-solid";

import { useSettingsNavigation } from "../../Settings";
import { UserSummary } from "../account";
import { UserSummary } from "../account/index";
import { EditProfileButtons } from "../profile/EditProfileButtons";

/**
Expand Down
Loading
Loading