diff --git a/.env.production b/.env.production new file mode 100644 index 00000000..327e0600 --- /dev/null +++ b/.env.production @@ -0,0 +1,2 @@ +# VITE_API_URL=http://local.revolt.chat:8000 +VITE_API_URL=https://app.revolt.chat/api diff --git a/src/pages/channels/Channel.tsx b/src/pages/channels/Channel.tsx index c60de584..62857c79 100644 --- a/src/pages/channels/Channel.tsx +++ b/src/pages/channels/Channel.tsx @@ -1,5 +1,6 @@ import { Hash } from "@styled-icons/boxicons-regular"; import { Ghost } from "@styled-icons/boxicons-solid"; +import dayjs from "dayjs"; import { reaction } from "mobx"; import { observer } from "mobx-react-lite"; import { Redirect, useParams } from "react-router-dom"; @@ -181,18 +182,19 @@ const TextChannel = observer(({ channel }: { channel: ChannelI }) => { let lastSubscribed: number | undefined; function subscribe() { if (document.hasFocus()) { - const tenMinutesAgo = new Date(); - tenMinutesAgo.setMinutes(tenMinutesAgo.getMinutes() - 10); - - if (!lastSubscribed || +tenMinutesAgo > lastSubscribed) { + if ( + !lastSubscribed || + dayjs().subtract(10, "minutes").isAfter(lastSubscribed) + ) { + lastSubscribed = +new Date(); channel.server?.subscribe(); - lastSubscribed = +tenMinutesAgo; } } } // Trigger logic every minute const subTimer = setInterval(subscribe, 60e3); + subscribe(); function onFocus() { // Mark channel as read if it's unread