switch layer naming to view to make it less confusing

This commit is contained in:
hippoz 2022-02-03 02:44:40 +02:00
parent c85657f8be
commit 641db09c7f
Signed by: hippoz
GPG key ID: 7C52899193467641

View file

@ -8,7 +8,7 @@ import FuzzyView from "./FuzzyView.svelte";
let selectedChannel = null;
let guilds = [];
let user = null;
let layer = { type: "CHAT" };
let view = { type: "CHAT" };
apiClient.getRequest("/users/@self")
.then((res) => {
@ -54,12 +54,12 @@ import FuzzyView from "./FuzzyView.svelte";
if (content.startsWith(":") && content.length > 1) {
switch (content[1]) {
case "g": {
layer = { type: "GUILD_FUZZY" };
view = { type: "GUILD_FUZZY" };
break;
}
case "c": {
if (selectedGuild) {
layer = { type: "CHANNEL_FUZZY" };
view = { type: "CHANNEL_FUZZY" };
}
break;
}
@ -107,7 +107,7 @@ import FuzzyView from "./FuzzyView.svelte";
function fuzzySelectedGuild({ detail: id }) {
selectedGuild = guilds.find(e => e.id === id);
selectedChannel = null;
layer = { type: "CHAT" };
view = { type: "CHAT" };
}
function fuzzySelectedChannel({ detail: id }) {
@ -115,7 +115,7 @@ import FuzzyView from "./FuzzyView.svelte";
return;
selectedChannel = selectedGuild.channels.find(e => e.id === id);
layer = { type: "CHAT" };
view = { type: "CHAT" };
}
</script>
@ -134,16 +134,16 @@ import FuzzyView from "./FuzzyView.svelte";
</style>
<main>
{#if layer.type === "CHAT"}
{#if view.type === "CHAT"}
<ChatView
messageStore={messageStore}
selectedChannel={selectedChannel}
selectedGuild={selectedGuild}
on:entermessage={onTextEntryMessage}
/>
{:else if layer.type === "GUILD_FUZZY"}
{:else if view.type === "GUILD_FUZZY"}
<FuzzyView on:selected={fuzzySelectedGuild} elements={guilds} title="Select a guild" />
{:else if layer.type === "CHANNEL_FUZZY"}
{:else if view.type === "CHANNEL_FUZZY"}
<FuzzyView on:selected={fuzzySelectedChannel} elements={selectedGuild ? selectedGuild.channels : []} title={`Select a channel in ${selectedGuild ? selectedGuild.name : "[unknown guild]"}`} />
{/if}
</main>