mirror of
https://github.com/thelounge/thelounge.git
synced 2024-06-07 08:12:19 +02:00
chatuserlist
This commit is contained in:
parent
7073584f1c
commit
88c8830a17
|
@ -59,7 +59,7 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {filter as fuzzyFilter} from "fuzzy";
|
import {filter as fuzzyFilter} from "fuzzy";
|
||||||
import {computed, defineComponent, nextTick, PropType, ref} from "vue";
|
import {computed, defineComponent, nextTick, PropType, ref} from "vue";
|
||||||
import type {UserInMessage} from "../../server/models/msg";
|
import type {UserInMessage} from "../../shared/types/msg";
|
||||||
import type {ClientChan, ClientUser} from "../js/types";
|
import type {ClientChan, ClientUser} from "../js/types";
|
||||||
import Username from "./Username.vue";
|
import Username from "./Username.vue";
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ export default defineComponent({
|
||||||
const result = filteredUsers.value;
|
const result = filteredUsers.value;
|
||||||
|
|
||||||
for (const user of result) {
|
for (const user of result) {
|
||||||
const mode = user.original.modes[0] || "";
|
const mode: string = user.original.modes[0] || "";
|
||||||
|
|
||||||
if (!groups[mode]) {
|
if (!groups[mode]) {
|
||||||
groups[mode] = [];
|
groups[mode] = [];
|
||||||
|
|
|
@ -2,7 +2,7 @@ import {nextTick} from "vue";
|
||||||
|
|
||||||
import socket from "../socket";
|
import socket from "../socket";
|
||||||
import {store} from "../store";
|
import {store} from "../store";
|
||||||
import {ClientMessage} from "../types";
|
import {ClientMessage} from "../../../shared/types/msg";
|
||||||
|
|
||||||
socket.on("more", async (data) => {
|
socket.on("more", async (data) => {
|
||||||
const channel = store.getters.findChannel(data.chan)?.channel;
|
const channel = store.getters.findChannel(data.chan)?.channel;
|
||||||
|
@ -14,12 +14,15 @@ socket.on("more", async (data) => {
|
||||||
channel.inputHistory = channel.inputHistory.concat(
|
channel.inputHistory = channel.inputHistory.concat(
|
||||||
data.messages
|
data.messages
|
||||||
.filter((m) => m.self && m.text && m.type === "message")
|
.filter((m) => m.self && m.text && m.type === "message")
|
||||||
.map((m) => m.text)
|
// TS is too stupid to see the guard in .filter(), so we monkey patch it
|
||||||
|
// to please the compiler
|
||||||
|
.map((m) => (m.text ? m.text : ""))
|
||||||
.reverse()
|
.reverse()
|
||||||
.slice(0, 100 - channel.inputHistory.length)
|
.slice(0, 100 - channel.inputHistory.length)
|
||||||
);
|
);
|
||||||
channel.moreHistoryAvailable =
|
channel.moreHistoryAvailable =
|
||||||
data.totalMessages > channel.messages.length + data.messages.length;
|
data.totalMessages > channel.messages.length + data.messages.length;
|
||||||
|
// TODO: invalid type cast
|
||||||
channel.messages.unshift(...(data.messages as ClientMessage[]));
|
channel.messages.unshift(...(data.messages as ClientMessage[]));
|
||||||
|
|
||||||
await nextTick();
|
await nextTick();
|
||||||
|
|
4
client/js/types.d.ts
vendored
4
client/js/types.d.ts
vendored
|
@ -15,9 +15,7 @@ interface LoungeWindow extends Window {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
type ClientUser = SharedUser & {
|
type ClientUser = SharedUser;
|
||||||
//
|
|
||||||
};
|
|
||||||
|
|
||||||
type ClientChan = Omit<SharedChan, "users" | "messages"> & {
|
type ClientChan = Omit<SharedChan, "users" | "messages"> & {
|
||||||
moreHistoryAvailable: boolean;
|
moreHistoryAvailable: boolean;
|
||||||
|
|
Loading…
Reference in a new issue