Skip to content

Commit

Permalink
implement changing avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
Puyodead1 committed Jul 18, 2024
1 parent 686431e commit 329a14c
Show file tree
Hide file tree
Showing 50 changed files with 300 additions and 103 deletions.
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import useLogger from "./hooks/useLogger";
import AppPage from "./pages/AppPage";
import LogoutPage from "./pages/LogoutPage";
import ChannelPage from "./pages/subpages/ChannelPage";
import { useAppStore } from "./stores/AppStore";
import { Globals } from "./utils/Globals";
// @ts-expect-error no types
import FPSStats from "react-fps-stats";
import { bannerController } from "./controllers/banners";
import { useAppStore } from "./hooks/useAppStore";
import { isTauri } from "./utils/Utils";

function App() {
Expand Down
6 changes: 3 additions & 3 deletions src/components/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { PresenceUpdateStatus } from "@spacebarchat/spacebar-api-types/v9";
import { observer } from "mobx-react-lite";
import React from "react";
import React, { useRef } from "react";
import styled from "styled-components";
import { useAppStore } from "../hooks/useAppStore";
import AccountStore from "../stores/AccountStore";
import { useAppStore } from "../stores/AppStore";
import Presence from "../stores/objects/Presence";
import User from "../stores/objects/User";
import Container from "./Container";
Expand Down Expand Up @@ -33,7 +33,7 @@ interface Props {
function Avatar(props: Props) {
const app = useAppStore();

const ref = React.useRef<HTMLDivElement>(null);
const ref = useRef<HTMLDivElement>(null);

const user = props.user ?? app.account;
if (!user) return null;
Expand Down
2 changes: 1 addition & 1 deletion src/components/ChannelHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { observer } from "mobx-react-lite";
import React, { useEffect } from "react";
import styled from "styled-components";
import { useAppStore } from "../stores/AppStore";
import { useAppStore } from "../hooks/useAppStore";
import Icon, { IconProps } from "./Icon";
import { SectionHeader } from "./SectionHeader";
import Floating from "./floating/Floating";
Expand Down
2 changes: 1 addition & 1 deletion src/components/ChannelList/ChannelList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ChannelType } from "@spacebarchat/spacebar-api-types/v9";
import { observer } from "mobx-react-lite";
import { AutoSizer, List, ListRowProps } from "react-virtualized";
import styled from "styled-components";
import { useAppStore } from "../../stores/AppStore";
import { useAppStore } from "../../hooks/useAppStore";
import ChannelListItem from "./ChannelListItem";

const Container = styled.div`
Expand Down
2 changes: 1 addition & 1 deletion src/components/ChannelList/ChannelListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { useNavigate } from "react-router-dom";
import styled from "styled-components";
import { ContextMenuContext } from "../../contexts/ContextMenuContext";
import { modalController } from "../../controllers/modals";
import { useAppStore } from "../../stores/AppStore";
import Channel from "../../stores/objects/Channel";
import { Permissions } from "../../utils/Permissions";
import Icon from "../Icon";
import SidebarPill from "../SidebarPill";
import Floating from "../floating/Floating";
import FloatingTrigger from "../floating/FloatingTrigger";
import { useAppStore } from "../../hooks/useAppStore";

const ListItem = styled.div<{ isCategory?: boolean }>`
padding: ${(props) => (props.isCategory ? "16px 8px 0 0" : "1px 8px 0 0")};
Expand Down
6 changes: 2 additions & 4 deletions src/components/GuildItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import React, { useContext } from "react";
import { useNavigate } from "react-router-dom";
import styled from "styled-components";
import { ContextMenuContext } from "../contexts/ContextMenuContext";
import { useAppStore } from "../hooks/useAppStore";
import useLogger from "../hooks/useLogger";
import { useAppStore } from "../stores/AppStore";
import Guild from "../stores/objects/Guild";
import { Permissions } from "../utils/Permissions";
import REST from "../utils/REST";
Expand All @@ -30,9 +30,7 @@ const Wrapper = styled(Container)<{ active?: boolean; hasImage?: boolean }>`
border-radius: ${(props) => (props.active ? "30%" : "50%")};
background-color: ${(props) =>
props.hasImage ? "transparent" : props.active ? "var(--primary)" : "var(--background-secondary)"};
transition:
border-radius 0.2s ease,
background-color 0.2s ease;
transition: border-radius 0.2s ease, background-color 0.2s ease;
&:hover {
border-radius: 30%;
Expand Down
2 changes: 1 addition & 1 deletion src/components/GuildSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useNavigate } from "react-router-dom";
import { AutoSizer, List, ListRowProps } from "react-virtualized";
import styled from "styled-components";
import { modalController } from "../controllers/modals";
import { useAppStore } from "../stores/AppStore";
import { useAppStore } from "../hooks/useAppStore";
import GuildItem, { GuildSidebarListItem } from "./GuildItem";
import SidebarAction from "./SidebarAction";

Expand Down
2 changes: 1 addition & 1 deletion src/components/Loader.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { invoke } from "@tauri-apps/api/core";
import { observer } from "mobx-react-lite";
import React from "react";
import { useAppStore } from "../hooks/useAppStore";
import LoadingPage from "../pages/LoadingPage";
import { useAppStore } from "../stores/AppStore";
import { isTauri } from "../utils/Utils";

interface Props {
Expand Down
2 changes: 1 addition & 1 deletion src/components/MemberList/MemberList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { autorun } from "mobx";
import { observer } from "mobx-react-lite";
import React from "react";
import styled from "styled-components";
import { useAppStore } from "../../stores/AppStore";
import { useAppStore } from "../../hooks/useAppStore";
import GuildMemberListStore from "../../stores/GuildMemberListStore";
import ListSection from "../ListSection";
import MemberListItem from "./MemberListItem";
Expand Down
2 changes: 1 addition & 1 deletion src/components/MemberList/MemberListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { observer } from "mobx-react-lite";
import { useContext } from "react";
import styled from "styled-components";
import { ContextMenuContext } from "../../contexts/ContextMenuContext";
import { useAppStore } from "../../stores/AppStore";
import { useAppStore } from "../../hooks/useAppStore";
import GuildMember from "../../stores/objects/GuildMember";
import Avatar from "../Avatar";
import Floating from "../floating/Floating";
Expand Down
2 changes: 1 addition & 1 deletion src/components/UserPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { observer } from "mobx-react-lite";
import styled from "styled-components";
import { modalController } from "../controllers/modals";
import { useAppStore } from "../stores/AppStore";
import { useAppStore } from "../hooks/useAppStore";
import Avatar from "./Avatar";
import Icon from "./Icon";
import IconButton from "./IconButton";
Expand Down
2 changes: 1 addition & 1 deletion src/components/contextMenus/GuildContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import { ChannelType } from "@spacebarchat/spacebar-api-types/v9";
import { modalController } from "../../controllers/modals";
import { useAppStore } from "../../hooks/useAppStore";
import useLogger from "../../hooks/useLogger";
import { useAppStore } from "../../stores/AppStore";
import Guild from "../../stores/objects/Guild";
import { ContextMenu, ContextMenuButton, ContextMenuDivider } from "./ContextMenu";

Expand Down
2 changes: 1 addition & 1 deletion src/components/contextMenus/MessageContextMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { modalController } from "../../controllers/modals";
import { useAppStore } from "../../stores/AppStore";
import { useAppStore } from "../../hooks/useAppStore";
import Message from "../../stores/objects/Message";
import { ContextMenu, ContextMenuButton, ContextMenuDivider } from "./ContextMenu";

Expand Down
2 changes: 1 addition & 1 deletion src/components/contextMenus/UserContextMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// loosely based on https://github.com/revoltchat/frontend/blob/master/components/app/menus/UserContextMenu.tsx

import { modalController } from "../../controllers/modals";
import { useAppStore } from "../../stores/AppStore";
import { useAppStore } from "../../hooks/useAppStore";
import GuildMember from "../../stores/objects/GuildMember";
import User from "../../stores/objects/User";
import { ContextMenu, ContextMenuButton, ContextMenuDivider } from "./ContextMenu";
Expand Down
2 changes: 1 addition & 1 deletion src/components/floating/GuildMenuPopout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import useLogger from "../../hooks/useLogger";

import React, { useEffect } from "react";
import { modalController } from "../../controllers/modals";
import { useAppStore } from "../../stores/AppStore";
import { useAppStore } from "../../hooks/useAppStore";
import { Permissions } from "../../utils/Permissions";
import { ContextMenu, ContextMenuButton, ContextMenuDivider } from "../contextMenus/ContextMenu";

Expand Down
2 changes: 1 addition & 1 deletion src/components/floating/UserProfilePopout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { HorizontalDivider } from "../Divider";
import { CDNRoutes, ImageFormat } from "@spacebarchat/spacebar-api-types/v9";
import dayjs from "dayjs";
import SpacebarLogoBlue from "../../assets/images/logo/Spacebar_Icon.svg?react";
import { useAppStore } from "../../stores/AppStore";
import { useAppStore } from "../../hooks/useAppStore";
import REST from "../../utils/REST";
import Floating from "./Floating";
import FloatingTrigger from "./FloatingTrigger";
Expand Down
2 changes: 1 addition & 1 deletion src/components/guards/AuthenticationGuard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Navigate } from "react-router-dom";
import { useAppStore } from "../../hooks/useAppStore";
import { LoadingSuspense } from "../../pages/LoadingPage";
import { useAppStore } from "../../stores/AppStore";

interface Props {
component: React.FC;
Expand Down
2 changes: 1 addition & 1 deletion src/components/guards/UnauthenticatedGuard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Navigate } from "react-router-dom";
import { useAppStore } from "../../hooks/useAppStore";
import { LoadingSuspense } from "../../pages/LoadingPage";
import { useAppStore } from "../../stores/AppStore";

interface Props {
component: React.FC;
Expand Down
2 changes: 1 addition & 1 deletion src/components/markdown/Mention.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { memo } from "react";
import { useNavigate } from "react-router-dom";
import styled from "styled-components";
import { ContextMenuContext } from "../../contexts/ContextMenuContext";
import { useAppStore } from "../../stores/AppStore";
import { useAppStore } from "../../hooks/useAppStore";
import Channel from "../../stores/objects/Channel";
import Role from "../../stores/objects/Role";
import User from "../../stores/objects/User";
Expand Down
2 changes: 1 addition & 1 deletion src/components/messaging/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { runInAction } from "mobx";
import { observer } from "mobx-react-lite";
import React from "react";
import styled from "styled-components";
import { useAppStore } from "../../hooks/useAppStore";
import useLogger from "../../hooks/useLogger";
import { useAppStore } from "../../stores/AppStore";
import Channel from "../../stores/objects/Channel";
import Guild from "../../stores/objects/Guild";
import MemberList from "../MemberList/MemberList";
Expand Down
2 changes: 1 addition & 1 deletion src/components/messaging/ChatHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as Icons from "@mdi/js";
import { observer } from "mobx-react-lite";
import styled from "styled-components";
import { useAppStore } from "../../hooks/useAppStore";
import useLogger from "../../hooks/useLogger";
import { useAppStore } from "../../stores/AppStore";
import Channel from "../../stores/objects/Channel";
import Icon from "../Icon";
import { SectionHeader } from "../SectionHeader";
Expand Down
2 changes: 1 addition & 1 deletion src/components/messaging/Message.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { observer } from "mobx-react-lite";
import { memo, useContext } from "react";
import { ContextMenuContext } from "../../contexts/ContextMenuContext";
import { useAppStore } from "../../stores/AppStore";
import { useAppStore } from "../../hooks/useAppStore";
import { MessageLike } from "../../stores/objects/Message";
import { QueuedMessageStatus } from "../../stores/objects/QueuedMessage";
import Avatar from "../Avatar";
Expand Down
6 changes: 3 additions & 3 deletions src/components/messaging/MessageAuthor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { observer } from "mobx-react-lite";
import React, { useContext } from "react";
import styled from "styled-components";
import { ContextMenuContext } from "../../contexts/ContextMenuContext";
import { useAppStore } from "../../hooks/useAppStore";
import useLogger from "../../hooks/useLogger";
import { useAppStore } from "../../stores/AppStore";
import Guild from "../../stores/objects/Guild";
import GuildMember from "../../stores/objects/GuildMember";
import { MessageLike } from "../../stores/objects/Message";
Expand Down Expand Up @@ -36,7 +36,7 @@ function MessageAuthor({ message, guild }: Props) {

React.useEffect(() => {
if (!eventData) return;
contextMenu.onContextMenu(eventData, { type: "user", user: message.author, member });
contextMenu?.onContextMenu(eventData, { type: "user", user: message.author, member });
}, [eventData, member]);

const onContextMenu = async (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
Expand Down Expand Up @@ -68,7 +68,7 @@ function MessageAuthor({ message, guild }: Props) {
style={{
color,
}}
ref={contextMenu.setReferenceElement}
ref={contextMenu?.setReferenceElement}
onContextMenu={onContextMenu}
>
{message.author.username}
Expand Down
4 changes: 2 additions & 2 deletions src/components/messaging/MessageInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import React from "react";
import styled from "styled-components";

import { modalController } from "../../controllers/modals";
import { useAppStore } from "../../hooks/useAppStore";
import useLogger from "../../hooks/useLogger";
import { useAppStore } from "../../stores/AppStore";
import Guild from "../../stores/objects/Guild";
import Snowflake from "../../utils/Snowflake";
import { MAX_ATTACHMENTS } from "../../utils/constants";
Expand Down Expand Up @@ -197,7 +197,7 @@ function MessageInput({ channel }: Props) {
channel.type === ChannelType.DM
? channel.recipients?.[0].username
: "#" + channel.name
}`
}`
: "You do not have permission to send messages in this channel."
}
disabled={!channel.hasPermission("SEND_MESSAGES")}
Expand Down
3 changes: 2 additions & 1 deletion src/components/messaging/MessageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import InfiniteScroll from "react-infinite-scroll-component";
import PulseLoader from "react-spinners/PulseLoader";
import styled from "styled-components";
import useResizeObserver from "use-resize-observer";
import { useAppStore } from "../../hooks/useAppStore";
import useLogger from "../../hooks/useLogger";
import { useAppStore } from "../../stores/AppStore";
import { MessageGroup as MessageGroupType } from "../../stores/MessageStore";
import Channel from "../../stores/objects/Channel";
import Guild from "../../stores/objects/Guild";
Expand All @@ -30,6 +30,7 @@ const EndMessageContainer = styled.div`
interface Props {
guild: Guild;
channel: Channel;
before?: string;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { observer } from "mobx-react-lite";
import styled from "styled-components";
import { useAppStore } from "../../../stores/AppStore";
import { useAppStore } from "../../../hooks/useAppStore";
import QueuedMessage from "../../../stores/objects/QueuedMessage";
import { bytesToSize } from "../../../utils/Utils";
import Icon from "../../Icon";
Expand Down
4 changes: 2 additions & 2 deletions src/components/modals/BanMemberModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useForm } from "react-hook-form";
import styled from "styled-components";
import * as yup from "yup";
import { ModalProps, modalController } from "../../controllers/modals";
import { useAppStore } from "../../stores/AppStore";
import { useAppStore } from "../../hooks/useAppStore";
import { Modal } from "./ModalComponents";

const DescriptionText = styled.p`
Expand Down Expand Up @@ -54,7 +54,7 @@ export function BanMemberModal({ target, type, ...props }: ModalProps<"ban_membe
data.reason
? {
"X-Audit-Log-Reason": data.reason,
}
}
: undefined,
)
.then(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/modals/CreateChannelModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useNavigate } from "react-router-dom";
import styled from "styled-components";
import * as yup from "yup";
import { ModalProps, modalController } from "../../controllers/modals";
import { useAppStore } from "../../stores/AppStore";
import { useAppStore } from "../../hooks/useAppStore";
import { messageFromFieldError } from "../../utils/messageFromFieldError";
import { Input, InputErrorText } from "../AuthComponents";
import { TextDivider } from "../Divider";
Expand Down
2 changes: 1 addition & 1 deletion src/components/modals/CreateInviteModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import React from "react";
import { useForm } from "react-hook-form";
import styled from "styled-components";
import { ModalProps } from "../../controllers/modals/types";
import { useAppStore } from "../../hooks/useAppStore";
import useLogger from "../../hooks/useLogger";
import { useAppStore } from "../../stores/AppStore";
import { messageFromFieldError } from "../../utils/messageFromFieldError";
import { Input, InputErrorText, InputLabel, LabelWrapper } from "../AuthComponents";
import Button from "../Button";
Expand Down
2 changes: 1 addition & 1 deletion src/components/modals/CreateServerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { useForm } from "react-hook-form";
import { useNavigate } from "react-router-dom";
import styled from "styled-components";
import { ModalProps, modalController } from "../../controllers/modals";
import { useAppStore } from "../../hooks/useAppStore";
import useLogger from "../../hooks/useLogger";
import { useAppStore } from "../../stores/AppStore";
import { messageFromFieldError } from "../../utils/messageFromFieldError";
import { Input, InputErrorText, InputLabel, InputWrapper, LabelWrapper } from "../AuthComponents";
import { TextDivider } from "../Divider";
Expand Down
2 changes: 1 addition & 1 deletion src/components/modals/JoinServerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { useForm } from "react-hook-form";
import { useNavigate } from "react-router-dom";
import styled from "styled-components";
import { ModalProps, modalController } from "../../controllers/modals";
import { useAppStore } from "../../hooks/useAppStore";
import useLogger from "../../hooks/useLogger";
import { useAppStore } from "../../stores/AppStore";
import { messageFromFieldError } from "../../utils/messageFromFieldError";
import { Input, InputErrorText, InputLabel, LabelWrapper } from "../AuthComponents";
import { TextDivider } from "../Divider";
Expand Down
4 changes: 2 additions & 2 deletions src/components/modals/KickMemberModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useForm } from "react-hook-form";
import styled from "styled-components";
import * as yup from "yup";
import { ModalProps, modalController } from "../../controllers/modals";
import { useAppStore } from "../../stores/AppStore";
import { useAppStore } from "../../hooks/useAppStore";
import { Modal } from "./ModalComponents";

const DescriptionText = styled.p`
Expand Down Expand Up @@ -54,7 +54,7 @@ export function KickMemberModal({ target, ...props }: ModalProps<"kick_member">)
data.reason
? {
"X-Audit-Log-Reason": data.reason,
}
}
: undefined,
)
.then(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/modals/LeaveServerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Routes } from "@spacebarchat/spacebar-api-types/v9";
import { useState } from "react";
import { useNavigate } from "react-router-dom";
import { ModalProps, modalController } from "../../controllers/modals";
import { useAppStore } from "../../hooks/useAppStore";
import useLogger from "../../hooks/useLogger";
import { useAppStore } from "../../stores/AppStore";
import { Modal } from "./ModalComponents";

export function LeaveServerModal({ target, ...props }: ModalProps<"leave_server">) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/modals/SettingsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { observer } from "mobx-react-lite";
import { useState } from "react";
import styled, { css } from "styled-components";
import { ModalProps, modalController } from "../../controllers/modals";
import { useAppStore } from "../../stores/AppStore";
import { useAppStore } from "../../hooks/useAppStore";
import { isTauri } from "../../utils/Utils";
import { APP_VERSION, GIT_BRANCH, GIT_REVISION, REPO_URL } from "../../utils/revison";
import Icon from "../Icon";
Expand Down
Loading

0 comments on commit 329a14c

Please sign in to comment.