mirror of
https://github.com/thelounge/thelounge
synced 2024-11-28 23:10:23 +00:00
network
This commit is contained in:
parent
d716402da2
commit
12a0b0b6f9
3 changed files with 46 additions and 11 deletions
4
client/js/types.d.ts
vendored
4
client/js/types.d.ts
vendored
|
@ -1,8 +1,8 @@
|
||||||
import {defineComponent} from "vue";
|
import {defineComponent} from "vue";
|
||||||
|
|
||||||
import Network from "../../server/models/network";
|
|
||||||
import {SharedMessage} from "../../shared/types/msg";
|
import {SharedMessage} from "../../shared/types/msg";
|
||||||
import {SharedChan} from "../../shared/types/chan";
|
import {SharedChan} from "../../shared/types/chan";
|
||||||
|
import {SharedNetwork} from "../../shared/types/network";
|
||||||
import {SharedUser} from "../../shared/models/user";
|
import {SharedUser} from "../../shared/models/user";
|
||||||
import {SharedMention} from "../../shared/models/mention";
|
import {SharedMention} from "../../shared/models/mention";
|
||||||
import {ClientConfiguration} from "../../server/server";
|
import {ClientConfiguration} from "../../server/server";
|
||||||
|
@ -46,7 +46,7 @@ type InitClientChan = ClientChan & {
|
||||||
};
|
};
|
||||||
|
|
||||||
// We omit channels so we can use ClientChan[] instead of Chan[]
|
// We omit channels so we can use ClientChan[] instead of Chan[]
|
||||||
type ClientNetwork = Omit<Network, "channels"> & {
|
type ClientNetwork = Omit<SharedNetwork, "channels"> & {
|
||||||
isJoinChannelShown: boolean;
|
isJoinChannelShown: boolean;
|
||||||
isCollapsed: boolean;
|
isCollapsed: boolean;
|
||||||
channels: ClientChan[];
|
channels: ClientChan[];
|
||||||
|
|
|
@ -9,12 +9,7 @@ import Network from "./network";
|
||||||
import Prefix from "./prefix";
|
import Prefix from "./prefix";
|
||||||
import {MessageType} from "../../shared/types/msg";
|
import {MessageType} from "../../shared/types/msg";
|
||||||
import {ChanType, SpecialChanType, ChanState} from "../../shared/types/chan";
|
import {ChanType, SpecialChanType, ChanState} from "../../shared/types/chan";
|
||||||
|
import {SharedNetworkChan} from "../../shared/types/network";
|
||||||
// eslint-disable-next-line no-use-before-define
|
|
||||||
export type FilteredChannel = Chan & {
|
|
||||||
users: [];
|
|
||||||
totalMessages: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type ChanConfig = {
|
export type ChanConfig = {
|
||||||
name: string;
|
name: string;
|
||||||
|
@ -189,7 +184,10 @@ class Chan {
|
||||||
* If true, channel is assumed active.
|
* If true, channel is assumed active.
|
||||||
* @param {int} lastMessage - Last message id seen by active client to avoid sending duplicates.
|
* @param {int} lastMessage - Last message id seen by active client to avoid sending duplicates.
|
||||||
*/
|
*/
|
||||||
getFilteredClone(lastActiveChannel?: number | boolean, lastMessage?: number): FilteredChannel {
|
getFilteredClone(
|
||||||
|
lastActiveChannel?: number | boolean,
|
||||||
|
lastMessage?: number
|
||||||
|
): SharedNetworkChan {
|
||||||
return Object.keys(this).reduce((newChannel, prop) => {
|
return Object.keys(this).reduce((newChannel, prop) => {
|
||||||
if (Chan.optionalProperties.includes(prop)) {
|
if (Chan.optionalProperties.includes(prop)) {
|
||||||
if (this[prop] !== undefined || (Array.isArray(this[prop]) && this[prop].length)) {
|
if (this[prop] !== undefined || (Array.isArray(this[prop]) && this[prop].length)) {
|
||||||
|
@ -213,13 +211,13 @@ class Chan {
|
||||||
newChannel[prop] = this[prop].slice(-messagesToSend);
|
newChannel[prop] = this[prop].slice(-messagesToSend);
|
||||||
}
|
}
|
||||||
|
|
||||||
(newChannel as FilteredChannel).totalMessages = this[prop].length;
|
(newChannel as SharedNetworkChan).totalMessages = this[prop].length;
|
||||||
} else {
|
} else {
|
||||||
newChannel[prop] = this[prop];
|
newChannel[prop] = this[prop];
|
||||||
}
|
}
|
||||||
|
|
||||||
return newChannel;
|
return newChannel;
|
||||||
}, {}) as FilteredChannel;
|
}, {}) as SharedNetworkChan;
|
||||||
}
|
}
|
||||||
writeUserLog(client: Client, msg: Msg) {
|
writeUserLog(client: Client, msg: Msg) {
|
||||||
this.messages.push(msg);
|
this.messages.push(msg);
|
||||||
|
|
37
shared/types/network.ts
Normal file
37
shared/types/network.ts
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
import {SharedChan} from "./chan";
|
||||||
|
|
||||||
|
export type SharedPrefixObject = {
|
||||||
|
symbol: string;
|
||||||
|
mode: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SharedNetworkChan = SharedChan & {
|
||||||
|
users: []; // TODO: this thing appears useless
|
||||||
|
totalMessages: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SharedPrefix = {
|
||||||
|
prefix: SharedPrefixObject[];
|
||||||
|
modeToSymbol: {[mode: string]: string};
|
||||||
|
symbols: string[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SharedServerOptions = {
|
||||||
|
CHANTYPES: string[];
|
||||||
|
PREFIX: SharedPrefix;
|
||||||
|
NETWORK: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SharedNetworkStatus = {
|
||||||
|
connected: boolean;
|
||||||
|
secure: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SharedNetwork = {
|
||||||
|
uuid: string;
|
||||||
|
name: string;
|
||||||
|
nick: string;
|
||||||
|
serverOptions: SharedServerOptions;
|
||||||
|
status: SharedNetworkStatus;
|
||||||
|
channels: SharedNetworkChan[];
|
||||||
|
};
|
Loading…
Reference in a new issue