Compare commits
No commits in common. "74cd9cd06ed67cfa4ecd04031164b946054a8d4d" and "cdb4e02413fb6098c3d2afce3177722038b89099" have entirely different histories.
74cd9cd06e
...
cdb4e02413
4 changed files with 6 additions and 44 deletions
|
@ -99,7 +99,7 @@ body {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
@supports(width: 1dvw) {
|
@supports(height: 1dvw) {
|
||||||
html, body {
|
html, body {
|
||||||
min-width: 100dvw;
|
min-width: 100dvw;
|
||||||
max-width: 100dvw;
|
max-width: 100dvw;
|
||||||
|
|
|
@ -1,21 +1,8 @@
|
||||||
<script>
|
<script>
|
||||||
import { CornerUpLeftIcon, MoreVerticalIcon } from "svelte-feather-icons";
|
import { MoreVerticalIcon } from "svelte-feather-icons";
|
||||||
import { overlayStore, setMessageInputEvent, userInfoStore } from "../stores";
|
import { overlayStore, userInfoStore } from "../stores";
|
||||||
|
|
||||||
export let message;
|
export let message;
|
||||||
|
|
||||||
const reply = () => {
|
|
||||||
let replyString = "";
|
|
||||||
const messageLines = message.content.split("\n");
|
|
||||||
|
|
||||||
messageLines.forEach(line => {
|
|
||||||
replyString += `> ${line}\n`;
|
|
||||||
});
|
|
||||||
|
|
||||||
replyString += `@${message.author_username} `;
|
|
||||||
|
|
||||||
setMessageInputEvent.update(replyString);
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@ -63,11 +50,8 @@
|
||||||
<div class="message">
|
<div class="message">
|
||||||
<span class="author">{ message.author_username }</span>
|
<span class="author">{ message.author_username }</span>
|
||||||
<span class="message-content" class:pending={ message._isPending }>{ message.content }</span>
|
<span class="message-content" class:pending={ message._isPending }>{ message.content }</span>
|
||||||
<button class="icon-button icon-button-auto edit-message" on:click="{ reply }" aria-label="Reply to Message">
|
|
||||||
<CornerUpLeftIcon />
|
|
||||||
</button>
|
|
||||||
{#if userInfoStore.value && (message.author_id === userInfoStore.value.id || userInfoStore.value.is_superuser)}
|
{#if userInfoStore.value && (message.author_id === userInfoStore.value.id || userInfoStore.value.is_superuser)}
|
||||||
<button class="icon-button edit-message" on:click="{ () => overlayStore.open('editMessage', { message }) }" aria-label="Edit Message">
|
<button class="icon-button icon-button-auto edit-message" on:click="{ () => overlayStore.open('editMessage', { message }) }" aria-label="Edit Message">
|
||||||
<MoreVerticalIcon />
|
<MoreVerticalIcon />
|
||||||
</button>
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import { ArrowUpIcon } from "svelte-feather-icons";
|
import { ArrowUpIcon } from "svelte-feather-icons";
|
||||||
import request from "../request";
|
import request from "../request";
|
||||||
import { apiRoute, getItem } from "../storage";
|
import { apiRoute, getItem } from "../storage";
|
||||||
import { messagesStoreProvider, overlayStore, selectedChannel, setMessageInputEvent, smallViewport, typingStore, userInfoStore } from "../stores";
|
import { messagesStoreProvider, overlayStore, selectedChannel, smallViewport, typingStore, userInfoStore } from "../stores";
|
||||||
|
|
||||||
export let channel;
|
export let channel;
|
||||||
let messageInput = "";
|
let messageInput = "";
|
||||||
|
@ -92,25 +92,10 @@
|
||||||
typingStore.didInputKey();
|
typingStore.didInputKey();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const unsubscribers = [];
|
|
||||||
|
|
||||||
|
|
||||||
// Focus the text area when the component first loads, or when the user selects another channel
|
// Focus the text area when the component first loads, or when the user selects another channel
|
||||||
const focusTextarea = () => messageTextarea && messageTextarea.focus();
|
const focusTextarea = () => messageTextarea && messageTextarea.focus();
|
||||||
onMount(focusTextarea);
|
onMount(focusTextarea);
|
||||||
unsubscribers.push(selectedChannel.subscribe(focusTextarea));
|
onDestroy(selectedChannel.subscribe(focusTextarea));
|
||||||
|
|
||||||
// Handle the setMessageInput event
|
|
||||||
unsubscribers.push(setMessageInputEvent.subscribe((value) => {
|
|
||||||
messageInput = value;
|
|
||||||
focusTextarea();
|
|
||||||
}));
|
|
||||||
|
|
||||||
|
|
||||||
onDestroy(() => {
|
|
||||||
unsubscribers.forEach(e => e());
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
|
@ -37,12 +37,6 @@ class Store {
|
||||||
this.updated();
|
this.updated();
|
||||||
}
|
}
|
||||||
|
|
||||||
// like set(), but without checking if the value is the same
|
|
||||||
update(value) {
|
|
||||||
this.value = value;
|
|
||||||
this.updated();
|
|
||||||
}
|
|
||||||
|
|
||||||
updated() {
|
updated() {
|
||||||
storeLog(`(${this.name}) (updated) Calling all (${this._handlers.length}) handlers`, this.value);
|
storeLog(`(${this.name}) (updated) Calling all (${this._handlers.length}) handlers`, this.value);
|
||||||
for (let i = this._handlers.length - 1; i >= 0; i--) {
|
for (let i = this._handlers.length - 1; i >= 0; i--) {
|
||||||
|
@ -462,7 +456,6 @@ export const userInfoStore = new UserInfoStore();
|
||||||
export const overlayStore = new OverlayStore();
|
export const overlayStore = new OverlayStore();
|
||||||
export const typingStore = new TypingStore();
|
export const typingStore = new TypingStore();
|
||||||
export const presenceStore = new PresenceStore();
|
export const presenceStore = new PresenceStore();
|
||||||
export const setMessageInputEvent = new Store(null, "event:setMessageInput");
|
|
||||||
|
|
||||||
export const allStores = {
|
export const allStores = {
|
||||||
selectedChannel,
|
selectedChannel,
|
||||||
|
|
Loading…
Reference in a new issue