frontend: cleanup

This commit is contained in:
hippoz 2022-04-28 18:48:44 +03:00
parent 7f3735502f
commit 8539e4ab7c
No known key found for this signature in database
GPG key ID: 7C52899193467641
8 changed files with 9 additions and 24 deletions

View file

@ -1,5 +0,0 @@
<script>
import Main from "./Main.svelte";
</script>
<Main />

View file

@ -1,6 +1,6 @@
<script>
import { Edit2Icon, HashIcon, MenuIcon } from "svelte-feather-icons";
import { overlayStore, selectedChannel, showSidebar } from "../stores";
import { HashIcon, MenuIcon } from "svelte-feather-icons";
import { overlayStore, showSidebar } from "../stores";
export let channel;
</script>

View file

@ -1,5 +1,4 @@
<script>
import { showChannelView } from "../stores";
import ChannelTopBar from "./ChannelTopBar.svelte";
import MessageInput from "./MessageInput.svelte";
import Messages from "./Messages.svelte";

View file

@ -1,6 +1,6 @@
<script>
import { SendIcon } from "svelte-feather-icons";
import request from "../request";
import request from "../request";
import { apiRoute } from "../storage";
import { messagesStoreProvider, overlayStore, smallViewport, userInfoStore } from "../stores";

View file

@ -1,6 +1,6 @@
<script>
import { afterUpdate, beforeUpdate, onMount } from "svelte";
import { messagesStoreProvider, showSidebar, smallViewport } from "../stores.js";
import { afterUpdate } from "svelte";
import { messagesStoreProvider, smallViewport } from "../stores.js";
import Message from "./Message.svelte";
export let channelId;

View file

@ -11,7 +11,6 @@
// janky code to hide the channel view during animation
// this will make a smooth sidebar animation on smaller viewports (such as a phone, where you switch between sidebar being active)
const scheduleSelectChannel = (channel) => {
if ($smallViewport) {
$showChannelView = false;

View file

@ -1,4 +1,4 @@
import App from './components/App.svelte';
import Main from './components/Main.svelte';
import gateway from './gateway';
import { getAuthToken, initStorageDefaults } from './storage';
import logging from "./logging";
@ -20,7 +20,7 @@ if (loadingElement) {
loadingElement.parentElement.removeChild(loadingElement);
}
const app = new App({
const app = new Main({
target: document.body
});

View file

@ -74,11 +74,7 @@ class ChannelsStore extends Store {
});
gateway.subscribe(GatewayEventType.MessageCreate, ({ channel_id }) => {
const index = this.value.findIndex(e => e.id === channel_id);
if (index === -1)
return;
if (!this.value[index])
return;
if (selectedChannel.value.id === channel_id)
if (index === -1 || !this.value[index] || selectedChannel.value.id === channel_id)
return;
this.value[index]._hasUnreads = true;
@ -86,11 +82,7 @@ class ChannelsStore extends Store {
});
selectedChannel.subscribe(({ id }) => {
const index = this.value.findIndex(e => e.id === id);
if (index === -1)
return;
if (!this.value[index])
return;
if (!this.value[index]._hasUnreads)
if (index === -1 || !this.value[index] || !this.value[index]._hasUnreads)
return;
this.value[index]._hasUnreads = false;