next
ci/woodpecker/push/base Pipeline failed Details

strip2
gapodo 2023-11-21 00:36:09 +01:00
parent 9bb82e3083
commit 6372bff69f
5 changed files with 193 additions and 190 deletions

View File

@ -1,53 +1,49 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head>
<head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, min-zoom=1, max-zoom: 1, user-scalable=no"> <meta name="viewport"
<meta name="description" content="The TeaSpeak Web client is a in the browser running client for the VoIP communication software TeaSpeak." /> content="width=device-width, initial-scale=1, shrink-to-fit=no, min-zoom=1, max-zoom: 1, user-scalable=no">
<meta name="keywords" content="TeaSpeak, TeaWeb, TeaSpeak-Web,Web client TeaSpeak, веб клієнт TeaSpeak, TSDNS, багатомовність, мультимовність, теми, функціонал"/> <meta name="description"
content="The TeaSpeak Web client is a in the browser running client for the VoIP communication software TeaSpeak." />
<meta name="keywords"
content="TeaSpeak, TeaWeb, TeaSpeak-Web,Web client TeaSpeak, веб клієнт TeaSpeak, TSDNS, багатомовність, мультимовність, теми, функціонал" />
<meta name="og:description" content="The TeaSpeak Web client is a in the browser running client for the VoIP communication software TeaSpeak." /> <meta name="og:description"
content="The TeaSpeak Web client is a in the browser running client for the VoIP communication software TeaSpeak." />
<meta name="og:url" content="https://web.teaspeak.de/"> <meta name="og:url" content="https://web.teaspeak.de/">
<% /* TODO: Put in an appropriate image <meta name="og:image" content="https://www.whatsapp.com/img/whatsapp-promo.png"> */ %> <% /* TODO: Put in an appropriate image <meta name="og:image"
content="https://www.whatsapp.com/img/whatsapp-promo.png"> */ %>
<% /* Using an absolute path here since the manifest.json works only with such. */ %> <% /* Using an absolute path here since the manifest.json works only with such. */ %>
<% /* <link rel="manifest" href="/manifest.json"> */ %> <% /* <link rel="manifest" href="/manifest.json"> */ %>
<% if(buildTarget === "client") { %> <% if(buildTarget==="client" ) { %>
<title>TeaClient</title> <title>TeaClient</title>
<meta name='og:title' content='TeaClient'> <meta name='og:title' content='TeaClient'>
<% } else { %> <% } else { %>
<title>TeaSpeak-Web</title> <title>TeaSpeak-Web</title>
<meta name='og:title' content='TeaSpeak-Web'> <meta name='og:title' content='TeaSpeak-Web'>
<link rel='shortcut icon' href='<%= require("./images/favicon_teacup.png") %>' type='image/x-icon' id="favicon"> <link rel='shortcut icon' href='<%= require("./images/favicon_teacup.png") %>'
<% /* <link rel="apple-touch-icon" sizes="194x194" href="/apple-touch-icon.png" type="image/png"> */ %> type='image/x-icon' id="favicon">
<% } %> <% /* <link rel="apple-touch-icon" sizes="194x194" href="/apple-touch-icon.png"
type="image/png"> */ %>
<% } %>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="format-detection" content="telephone=no"> <meta name="format-detection" content="telephone=no">
<!-- Global site tag (gtag.js) - Google Analytics --> <link rel="preload" as="image" href="<%= require(" ./images/initial-sequence.gif") %>">
<script defer async src="https://www.googletagmanager.com/gtag/js?id=UA-113151733-4"></script> <link rel="preload" as="image" href="<%= require(" ./images/bowl.png") %>">
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'UA-113151733-4');
</script>
<link rel="preload" as="image" href="<%= require("./images/initial-sequence.gif") %>">
<link rel="preload" as="image" href="<%= require("./images/bowl.png") %>">
<% /* We don't preload the bowl since it's only a div background */ %> <% /* We don't preload the bowl since it's only a div background */ %>
<link rel="preload" as="image" href="<%= require("./images/text.png") %>"> <link rel="preload" as="image" href="<%= require(" ./images/text.png") %>">
<%= htmlWebpackPlugin.tags.headTags %> <%= htmlWebpackPlugin.tags.headTags %>
</head> </head>
<body>
<body>
<!-- No javascript error --> <!-- No javascript error -->
<noscript> <noscript>
<div id="overlay-no-js"> <div id="overlay-no-js">
@ -66,16 +62,21 @@
<div class="loader" id="loader-overlay"> <div class="loader" id="loader-overlay">
<div class="container"> <div class="container">
<div class="setup"> <div class="setup">
<lazy-img src="<%= require("./images/initial-sequence.gif") %>" alt="initial loading sequence" x-animation-depend="normal"></lazy-img> <lazy-img src="<%= require(" ./images/initial-sequence.gif") %>" alt="initial loading sequence"
<lazy-img src="<%= require("./images/halloween-initial-sequence.gif") %>" alt="initial loading sequence" x-animation-depend="halloween"></lazy-img> x-animation-depend="normal"></lazy-img>
<lazy-img src="<%= require(" ./images/halloween-initial-sequence.gif") %>" alt="initial loading
sequence" x-animation-depend="halloween"></lazy-img>
</div> </div>
<div class="idle animation-normal"> <div class="idle animation-normal">
<lazy-img class="bowl" src="<%= require("./images/bowl.png") %>" alt="bowl" x-animation-depend="normal"></lazy-img> <lazy-img class="bowl" src="<%= require(" ./images/bowl.png") %>" alt="bowl"
<lazy-img class="text" src="<%= require("./images/text.png") %>" alt="TeaSpeak" x-animation-depend="normal"></lazy-img> x-animation-depend="normal"></lazy-img>
<lazy-img class="text" src="<%= require(" ./images/text.png") %>" alt="TeaSpeak"
x-animation-depend="normal"></lazy-img>
<div class="steam"></div> <div class="steam"></div>
</div> </div>
<div class="idle animation-halloween"> <div class="idle animation-halloween">
<lazy-img src="<%= require("./images/halloween-loop.gif") %>" alt="halloween loop" x-animation-depend="halloween"></lazy-img> <lazy-img src="<%= require(" ./images/halloween-loop.gif") %>" alt="halloween loop"
x-animation-depend="halloween"></lazy-img>
</div> </div>
</div> </div>
@ -95,5 +96,6 @@
</div> </div>
<%= htmlWebpackPlugin.tags.bodyTags %> <%= htmlWebpackPlugin.tags.bodyTags %>
</body> </body>
</html> </html>

View File

@ -1,14 +1,14 @@
import * as loader from "tc-loader"; import * as loader from "tc-loader";
import {Stage} from "tc-loader"; import { Stage } from "tc-loader";
import {ignorePromise, WritableKeys} from "tc-shared/proto"; import { ignorePromise, WritableKeys } from "tc-shared/proto";
import {LogCategory, logDebug, logError, logInfo, logTrace, logWarn} from "tc-shared/log"; import { LogCategory, logDebug, logError, logInfo, logTrace, logWarn } from "tc-shared/log";
import {guid} from "tc-shared/crypto/uid"; import { guid } from "tc-shared/crypto/uid";
import {Registry} from "tc-events"; import { Registry } from "tc-events";
import {server_connections} from "tc-shared/ConnectionManager"; import { server_connections } from "tc-shared/ConnectionManager";
import {defaultConnectProfile, findConnectProfile} from "tc-shared/profiles/ConnectionProfile"; import { defaultConnectProfile, findConnectProfile } from "tc-shared/profiles/ConnectionProfile";
import {ConnectionState} from "tc-shared/ConnectionHandler"; import { ConnectionState } from "tc-shared/ConnectionHandler";
import * as _ from "lodash"; import * as _ from "lodash";
import {getStorageAdapter} from "tc-shared/StorageAdapter"; import { getStorageAdapter } from "tc-shared/StorageAdapter";
type BookmarkBase = { type BookmarkBase = {
readonly uniqueId: string, readonly uniqueId: string,
@ -64,9 +64,9 @@ export class BookmarkManager {
async loadBookmarks() { async loadBookmarks() {
const bookmarksJson = await getStorageAdapter().get(kStorageKey); const bookmarksJson = await getStorageAdapter().get(kStorageKey);
if(typeof bookmarksJson !== "string") { if (typeof bookmarksJson !== "string") {
const oldBookmarksJson = await getStorageAdapter().get("bookmarks"); const oldBookmarksJson = await getStorageAdapter().get("bookmarks");
if(typeof oldBookmarksJson === "string") { if (typeof oldBookmarksJson === "string") {
logDebug(LogCategory.BOOKMARKS, tr("Found no new bookmarks but found old bookmarks. Trying to import.")); logDebug(LogCategory.BOOKMARKS, tr("Found no new bookmarks but found old bookmarks. Trying to import."));
try { try {
this.importOldBookmarks(oldBookmarksJson); this.importOldBookmarks(oldBookmarksJson);
@ -83,7 +83,7 @@ export class BookmarkManager {
} else { } else {
try { try {
const storageData = JSON.parse(bookmarksJson); const storageData = JSON.parse(bookmarksJson);
if(storageData.version !== 2) { if (storageData.version !== 2) {
throw tr("bookmark storage has an invalid version"); throw tr("bookmark storage has an invalid version");
} }
@ -99,7 +99,7 @@ export class BookmarkManager {
} }
} }
if(!this.defaultBookmarkCreated && this.registeredBookmarks.length === 0) { if (!this.defaultBookmarkCreated && this.registeredBookmarks.length === 0) {
this.defaultBookmarkCreated = true; this.defaultBookmarkCreated = true;
logDebug(LogCategory.BOOKMARKS, tr("No bookmarks found. Registering default bookmark.")); logDebug(LogCategory.BOOKMARKS, tr("No bookmarks found. Registering default bookmark."));
@ -107,12 +107,12 @@ export class BookmarkManager {
connectOnStartup: false, connectOnStartup: false,
connectProfile: "default", connectProfile: "default",
displayName: "Official TeaSpeak - Test server", displayName: "Our LanPart<",
parentEntry: undefined, parentEntry: undefined,
previousEntry: undefined, previousEntry: undefined,
serverAddress: "ts.teaspeak.de", serverAddress: "tea.lp.kle.li",
serverPasswordHash: undefined, serverPasswordHash: undefined,
defaultChannel: undefined, defaultChannel: undefined,
@ -123,21 +123,21 @@ export class BookmarkManager {
private importOldBookmarks(jsonData: string) { private importOldBookmarks(jsonData: string) {
const data = JSON.parse(jsonData); const data = JSON.parse(jsonData);
if(typeof data?.root_bookmark !== "object") { if (typeof data?.root_bookmark !== "object") {
throw tr("missing root bookmark"); throw tr("missing root bookmark");
} }
if(!Array.isArray(data?.root_bookmark?.content)) { if (!Array.isArray(data?.root_bookmark?.content)) {
throw tr("Missing root bookmarks content"); throw tr("Missing root bookmarks content");
} }
const registerBookmarks = (parentEntry: string, previousEntry: string, entry: any) : string | undefined => { const registerBookmarks = (parentEntry: string, previousEntry: string, entry: any): string | undefined => {
if(typeof entry.display_name !== "string") { if (typeof entry.display_name !== "string") {
logWarn(LogCategory.BOOKMARKS, tr("Missing display_name in old bookmark entry. Skipping entry.")); logWarn(LogCategory.BOOKMARKS, tr("Missing display_name in old bookmark entry. Skipping entry."));
return undefined; return undefined;
} }
if("content" in entry) { if ("content" in entry) {
/* it was a directory */ /* it was a directory */
const directory = this.createDirectory({ const directory = this.createDirectory({
previousEntry, previousEntry,
@ -152,23 +152,23 @@ export class BookmarkManager {
}); });
} else { } else {
/* it was a normal entry */ /* it was a normal entry */
if(typeof entry.connect_profile !== "string") { if (typeof entry.connect_profile !== "string") {
logWarn(LogCategory.BOOKMARKS, tr("Missing connect_profile in old bookmark entry. Skipping entry.")); logWarn(LogCategory.BOOKMARKS, tr("Missing connect_profile in old bookmark entry. Skipping entry."));
return undefined; return undefined;
} }
if(typeof entry.server_properties?.server_address !== "string") { if (typeof entry.server_properties?.server_address !== "string") {
logWarn(LogCategory.BOOKMARKS, tr("Missing server_address in old bookmark entry. Skipping entry.")); logWarn(LogCategory.BOOKMARKS, tr("Missing server_address in old bookmark entry. Skipping entry."));
return undefined; return undefined;
} }
if(typeof entry.server_properties?.server_port !== "number") { if (typeof entry.server_properties?.server_port !== "number") {
logWarn(LogCategory.BOOKMARKS, tr("Missing server_port in old bookmark entry. Skipping entry.")); logWarn(LogCategory.BOOKMARKS, tr("Missing server_port in old bookmark entry. Skipping entry."));
return undefined; return undefined;
} }
let serverAddress; let serverAddress;
if(entry.server_properties.server_address.indexOf(":") !== -1) { if (entry.server_properties.server_address.indexOf(":") !== -1) {
serverAddress = `[${entry.server_properties.server_address}]`; serverAddress = `[${entry.server_properties.server_address}]`;
} else { } else {
serverAddress = entry.server_properties.server_address; serverAddress = entry.server_properties.server_address;
@ -209,23 +209,23 @@ export class BookmarkManager {
})); }));
} }
getRegisteredBookmarks() : BookmarkEntry[] { getRegisteredBookmarks(): BookmarkEntry[] {
return this.registeredBookmarks; return this.registeredBookmarks;
} }
getOrderedRegisteredBookmarks() : OrderedBookmarkEntry[] { getOrderedRegisteredBookmarks(): OrderedBookmarkEntry[] {
const unorderedBookmarks = this.registeredBookmarks.slice(0); const unorderedBookmarks = this.registeredBookmarks.slice(0);
const orderedBookmarks: OrderedBookmarkEntry[] = []; const orderedBookmarks: OrderedBookmarkEntry[] = [];
const orderTreeLayer = (entries: BookmarkEntry[]): BookmarkEntry[] => { const orderTreeLayer = (entries: BookmarkEntry[]): BookmarkEntry[] => {
if(entries.length === 0) { if (entries.length === 0) {
return []; return [];
} }
const result = []; const result = [];
while(entries.length > 0) { while (entries.length > 0) {
let head = entries.find(entry => !entry.previousEntry) || entries[0]; let head = entries.find(entry => !entry.previousEntry) || entries[0];
while(head) { while (head) {
result.push(head); result.push(head);
entries.remove(head); entries.remove(head);
head = entries.find(entry => entry.previousEntry === head.uniqueId); head = entries.find(entry => entry.previousEntry === head.uniqueId);
@ -240,7 +240,7 @@ export class BookmarkManager {
children.forEach(child => unorderedBookmarks.remove(child)); children.forEach(child => unorderedBookmarks.remove(child));
const childCount = children.length; const childCount = children.length;
for(const entry of orderTreeLayer(children)) { for (const entry of orderTreeLayer(children)) {
let orderedEntry: OrderedBookmarkEntry = { let orderedEntry: OrderedBookmarkEntry = {
entry: entry, entry: entry,
depth: depth, depth: depth,
@ -264,11 +264,11 @@ export class BookmarkManager {
return orderedBookmarks; return orderedBookmarks;
} }
findBookmark(uniqueId: string) : BookmarkEntry | undefined { findBookmark(uniqueId: string): BookmarkEntry | undefined {
return this.registeredBookmarks.find(entry => entry.uniqueId === uniqueId); return this.registeredBookmarks.find(entry => entry.uniqueId === uniqueId);
} }
createBookmark(properties: Pick<BookmarkInfo, WritableKeys<BookmarkInfo>>) : BookmarkInfo { createBookmark(properties: Pick<BookmarkInfo, WritableKeys<BookmarkInfo>>): BookmarkInfo {
this.validateHangInPoint(properties); this.validateHangInPoint(properties);
const bookmark = Object.assign(properties, { const bookmark = Object.assign(properties, {
uniqueId: guid(), uniqueId: guid(),
@ -284,7 +284,7 @@ export class BookmarkManager {
this.doEditBookmark(uniqueId, newValues); this.doEditBookmark(uniqueId, newValues);
} }
createDirectory(properties: Pick<BookmarkInfo, WritableKeys<BookmarkDirectory>>) : BookmarkDirectory { createDirectory(properties: Pick<BookmarkInfo, WritableKeys<BookmarkDirectory>>): BookmarkDirectory {
this.validateHangInPoint(properties); this.validateHangInPoint(properties);
const bookmark = Object.assign(properties, { const bookmark = Object.assign(properties, {
uniqueId: guid(), uniqueId: guid(),
@ -300,20 +300,20 @@ export class BookmarkManager {
this.doEditBookmark(uniqueId, newValues); this.doEditBookmark(uniqueId, newValues);
} }
directoryContents(uniqueId: string) : BookmarkEntry[] { directoryContents(uniqueId: string): BookmarkEntry[] {
return this.registeredBookmarks.filter(bookmark => bookmark.parentEntry === uniqueId); return this.registeredBookmarks.filter(bookmark => bookmark.parentEntry === uniqueId);
} }
deleteEntry(uniqueId: string) { deleteEntry(uniqueId: string) {
const index = this.registeredBookmarks.findIndex(entry => entry.uniqueId === uniqueId); const index = this.registeredBookmarks.findIndex(entry => entry.uniqueId === uniqueId);
if(index === -1) { if (index === -1) {
return; return;
} }
const [ entry ] = this.registeredBookmarks.splice(index, 1); const [entry] = this.registeredBookmarks.splice(index, 1);
const children = [], pendingChildren = [ entry ]; const children = [], pendingChildren = [entry];
while(pendingChildren[0]) { while (pendingChildren[0]) {
const child = pendingChildren.pop_front(); const child = pendingChildren.pop_front();
children.push(child); children.push(child);
@ -329,12 +329,12 @@ export class BookmarkManager {
executeConnect(uniqueId: string, newTab: boolean) { executeConnect(uniqueId: string, newTab: boolean) {
const bookmark = this.findBookmark(uniqueId); const bookmark = this.findBookmark(uniqueId);
if(!bookmark || bookmark.type !== "entry") { if (!bookmark || bookmark.type !== "entry") {
return; return;
} }
const connection = newTab ? server_connections.spawnConnectionHandler() : server_connections.getActiveConnectionHandler(); const connection = newTab ? server_connections.spawnConnectionHandler() : server_connections.getActiveConnectionHandler();
if(!connection) { if (!connection) {
return; return;
} }
@ -360,12 +360,12 @@ export class BookmarkManager {
executeAutoConnect() { executeAutoConnect() {
let newTab = server_connections.getActiveConnectionHandler().connection_state !== ConnectionState.UNCONNECTED; let newTab = server_connections.getActiveConnectionHandler().connection_state !== ConnectionState.UNCONNECTED;
for(const entry of this.getOrderedRegisteredBookmarks()) { for (const entry of this.getOrderedRegisteredBookmarks()) {
if(entry.entry.type !== "entry") { if (entry.entry.type !== "entry") {
continue; continue;
} }
if(!entry.entry.connectOnStartup) { if (!entry.entry.connectOnStartup) {
continue; continue;
} }
@ -374,14 +374,14 @@ export class BookmarkManager {
} }
} }
exportBookmarks() : string { exportBookmarks(): string {
return JSON.stringify({ return JSON.stringify({
version: 1, version: 1,
bookmarks: this.registeredBookmarks bookmarks: this.registeredBookmarks
}); });
} }
importBookmarks(filePayload: string) : number { importBookmarks(filePayload: string): number {
let data; let data;
try { try {
data = JSON.parse(filePayload) data = JSON.parse(filePayload)
@ -389,26 +389,26 @@ export class BookmarkManager {
throw tr("failed to parse bookmarks"); throw tr("failed to parse bookmarks");
} }
if(data?.version !== 1) { if (data?.version !== 1) {
throw tr("supplied data contains invalid version"); throw tr("supplied data contains invalid version");
} }
const newBookmarks = data.bookmarks as BookmarkEntry[]; const newBookmarks = data.bookmarks as BookmarkEntry[];
if(!Array.isArray(newBookmarks)) { if (!Array.isArray(newBookmarks)) {
throw tr("missing bookmarks"); throw tr("missing bookmarks");
} }
/* TODO: Validate integrity? */ /* TODO: Validate integrity? */
for(const knownBookmark of this.registeredBookmarks) { for (const knownBookmark of this.registeredBookmarks) {
const index = newBookmarks.findIndex(entry => entry.uniqueId === knownBookmark.uniqueId); const index = newBookmarks.findIndex(entry => entry.uniqueId === knownBookmark.uniqueId);
if(index === -1) { if (index === -1) {
continue; continue;
} }
newBookmarks.splice(index, 1); newBookmarks.splice(index, 1);
} }
if(newBookmarks.length === 0) { if (newBookmarks.length === 0) {
return; return;
} }
@ -420,26 +420,26 @@ export class BookmarkManager {
private doEditBookmark(uniqueId: string, newValues: any) { private doEditBookmark(uniqueId: string, newValues: any) {
const bookmarkInfo = this.findBookmark(uniqueId); const bookmarkInfo = this.findBookmark(uniqueId);
if(!bookmarkInfo) { if (!bookmarkInfo) {
return; return;
} }
const originalProperties = _.cloneDeep(bookmarkInfo); const originalProperties = _.cloneDeep(bookmarkInfo);
for(const key of Object.keys(newValues)) { for (const key of Object.keys(newValues)) {
bookmarkInfo[key] = newValues[key]; bookmarkInfo[key] = newValues[key];
} }
this.validateHangInPoint(bookmarkInfo); this.validateHangInPoint(bookmarkInfo);
const editedKeys = []; const editedKeys = [];
for(const key of Object.keys(newValues)) { for (const key of Object.keys(newValues)) {
if(_.isEqual(bookmarkInfo[key], originalProperties[key])) { if (_.isEqual(bookmarkInfo[key], originalProperties[key])) {
continue; continue;
} }
editedKeys.push(key); editedKeys.push(key);
} }
if(editedKeys.length === 0) { if (editedKeys.length === 0) {
return; return;
} }
@ -448,12 +448,12 @@ export class BookmarkManager {
} }
private validateHangInPoint(entry: Partial<BookmarkBase>) { private validateHangInPoint(entry: Partial<BookmarkBase>) {
if(entry.previousEntry) { if (entry.previousEntry) {
const previousEntry = this.findBookmark(entry.previousEntry); const previousEntry = this.findBookmark(entry.previousEntry);
if(!previousEntry) { if (!previousEntry) {
logError(LogCategory.BOOKMARKS, tr("New bookmark previous entry does not exists. Clearing it.")); logError(LogCategory.BOOKMARKS, tr("New bookmark previous entry does not exists. Clearing it."));
entry.previousEntry = undefined; entry.previousEntry = undefined;
} else if(previousEntry.parentEntry !== entry.parentEntry) { } else if (previousEntry.parentEntry !== entry.parentEntry) {
logWarn(LogCategory.BOOKMARKS, tr("Previous entries parent does not match our entries parent. Updating our parent from %s to %s"), entry.parentEntry, previousEntry.parentEntry); logWarn(LogCategory.BOOKMARKS, tr("Previous entries parent does not match our entries parent. Updating our parent from %s to %s"), entry.parentEntry, previousEntry.parentEntry);
entry.parentEntry = previousEntry.parentEntry; entry.parentEntry = previousEntry.parentEntry;
} }
@ -461,13 +461,13 @@ export class BookmarkManager {
const openList = this.registeredBookmarks.filter(e1 => e1.parentEntry === entry.parentEntry); const openList = this.registeredBookmarks.filter(e1 => e1.parentEntry === entry.parentEntry);
let currentEntry = entry; let currentEntry = entry;
while(true) { while (true) {
if(!currentEntry.previousEntry) { if (!currentEntry.previousEntry) {
break; break;
} }
const previousEntry = openList.find(entry => entry.uniqueId === currentEntry.previousEntry); const previousEntry = openList.find(entry => entry.uniqueId === currentEntry.previousEntry);
if(!previousEntry) { if (!previousEntry) {
logError(LogCategory.BOOKMARKS, tr("Found circular dependency within the previous entry or one of the previous entries does not exists. Clearing out previous entry.")); logError(LogCategory.BOOKMARKS, tr("Found circular dependency within the previous entry or one of the previous entries does not exists. Clearing out previous entry."));
entry.previousEntry = undefined; entry.previousEntry = undefined;
break; break;
@ -478,22 +478,22 @@ export class BookmarkManager {
} }
} }
if(entry.parentEntry) { if (entry.parentEntry) {
const parentEntry = this.findBookmark(entry.parentEntry); const parentEntry = this.findBookmark(entry.parentEntry);
if(!parentEntry) { if (!parentEntry) {
logError(LogCategory.BOOKMARKS, tr("Missing parent entry %s. Clearing it."), entry.parentEntry); logError(LogCategory.BOOKMARKS, tr("Missing parent entry %s. Clearing it."), entry.parentEntry);
entry.parentEntry = undefined; entry.parentEntry = undefined;
} }
const openList = this.registeredBookmarks.slice(); const openList = this.registeredBookmarks.slice();
let currentEntry = entry; let currentEntry = entry;
while(true) { while (true) {
if(!currentEntry.parentEntry) { if (!currentEntry.parentEntry) {
break; break;
} }
const parentEntry = openList.find(entry => entry.uniqueId === currentEntry.parentEntry); const parentEntry = openList.find(entry => entry.uniqueId === currentEntry.parentEntry);
if(!parentEntry) { if (!parentEntry) {
logError(LogCategory.BOOKMARKS, tr("Found circular dependency within a parent or one of the parents does not exists. Clearing out parent.")); logError(LogCategory.BOOKMARKS, tr("Found circular dependency within a parent or one of the parents does not exists. Clearing out parent."));
entry.parentEntry = undefined; entry.parentEntry = undefined;
break; break;
@ -504,9 +504,9 @@ export class BookmarkManager {
} }
} }
if(entry.previousEntry) { if (entry.previousEntry) {
this.registeredBookmarks.forEach(bookmark => { this.registeredBookmarks.forEach(bookmark => {
if(bookmark.previousEntry === entry.previousEntry && bookmark !== entry) { if (bookmark.previousEntry === entry.previousEntry && bookmark !== entry) {
bookmark.previousEntry = bookmark.uniqueId; bookmark.previousEntry = bookmark.uniqueId;
} }
}); });

View File

@ -364,7 +364,7 @@ export class Settings {
static readonly KEY_I18N_DEFAULT_REPOSITORY: ValuedRegistryKey<string> = { static readonly KEY_I18N_DEFAULT_REPOSITORY: ValuedRegistryKey<string> = {
key: "i18n.default_repository", key: "i18n.default_repository",
valueType: "string", valueType: "string",
defaultValue: "https://web.teaspeak.de/i18n/" defaultValue: "i18n/"
}; };
/* Default client states */ /* Default client states */

View File

@ -1,25 +1,25 @@
import {Registry} from "tc-shared/events"; import { Registry } from "tc-shared/events";
import { import {
ConnectUiEvents, ConnectUiEvents,
ConnectUiVariables, ConnectUiVariables,
} from "tc-shared/ui/modal/connect/Definitions"; } from "tc-shared/ui/modal/connect/Definitions";
import {LogCategory, logError, logWarn} from "tc-shared/log"; import { LogCategory, logError, logWarn } from "tc-shared/log";
import { import {
availableConnectProfiles, availableConnectProfiles,
ConnectionProfile, ConnectionProfile,
defaultConnectProfile, defaultConnectProfile,
findConnectProfile findConnectProfile
} from "tc-shared/profiles/ConnectionProfile"; } from "tc-shared/profiles/ConnectionProfile";
import {Settings, settings} from "tc-shared/settings"; import { Settings, settings } from "tc-shared/settings";
import {connectionHistory, ConnectionHistoryEntry} from "tc-shared/connectionlog/History"; import { connectionHistory, ConnectionHistoryEntry } from "tc-shared/connectionlog/History";
import {createErrorModal} from "tc-shared/ui/elements/Modal"; import { createErrorModal } from "tc-shared/ui/elements/Modal";
import {ConnectionHandler} from "tc-shared/ConnectionHandler"; import { ConnectionHandler } from "tc-shared/ConnectionHandler";
import {server_connections} from "tc-shared/ConnectionManager"; import { server_connections } from "tc-shared/ConnectionManager";
import {parseServerAddress} from "tc-shared/tree/Server"; import { parseServerAddress } from "tc-shared/tree/Server";
import {spawnSettingsModal} from "tc-shared/ui/modal/ModalSettings"; import { spawnSettingsModal } from "tc-shared/ui/modal/ModalSettings";
import {UiVariableProvider} from "tc-shared/ui/utils/Variable"; import { UiVariableProvider } from "tc-shared/ui/utils/Variable";
import {createIpcUiVariableProvider} from "tc-shared/ui/utils/IpcVariable"; import { createIpcUiVariableProvider } from "tc-shared/ui/utils/IpcVariable";
import {spawnModal} from "tc-shared/ui/react-elements/modal"; import { spawnModal } from "tc-shared/ui/react-elements/modal";
import ipRegex from "ip-regex"; import ipRegex from "ip-regex";
const kRegexDomain = /^(localhost|((([a-zA-Z0-9_-]{0,63}\.){0,253})?[a-zA-Z0-9_-]{0,63}\.[a-zA-Z]{2,64}))$/i; const kRegexDomain = /^(localhost|((([a-zA-Z0-9_-]{0,63}\.){0,253})?[a-zA-Z0-9_-]{0,63}\.[a-zA-Z]{2,64}))$/i;
@ -61,7 +61,8 @@ class ConnectController {
private validateNickname: boolean; private validateNickname: boolean;
private validateAddress: boolean; private validateAddress: boolean;
constructor(uiVariables: UiVariableProvider<ConnectUiVariables>) {7 constructor(uiVariables: UiVariableProvider<ConnectUiVariables>) {
7
this.uiEvents = new Registry<ConnectUiEvents>(); this.uiEvents = new Registry<ConnectUiEvents>();
this.uiEvents.enableDebug("modal-connect"); this.uiEvents.enableDebug("modal-connect");
@ -71,7 +72,7 @@ class ConnectController {
this.validateNickname = false; this.validateNickname = false;
this.validateAddress = false; this.validateAddress = false;
this.defaultAddress = "ts.teaspeak.de"; this.defaultAddress = "tea.lp.kle.li";
this.historyShown = settings.getValue(Settings.KEY_CONNECT_SHOW_HISTORY); this.historyShown = settings.getValue(Settings.KEY_CONNECT_SHOW_HISTORY);
this.currentAddress = settings.getValue(Settings.KEY_CONNECT_ADDRESS); this.currentAddress = settings.getValue(Settings.KEY_CONNECT_ADDRESS);
@ -109,11 +110,11 @@ class ConnectController {
})); }));
this.uiVariables.setVariableProvider("server_address_valid", () => { this.uiVariables.setVariableProvider("server_address_valid", () => {
if(this.validateAddress) { if (this.validateAddress) {
const address = this.currentAddress || this.defaultAddress || ""; const address = this.currentAddress || this.defaultAddress || "";
const parsedAddress = parseServerAddress(address); const parsedAddress = parseServerAddress(address);
if(parsedAddress) { if (parsedAddress) {
kRegexDomain.lastIndex = 0; kRegexDomain.lastIndex = 0;
return kRegexDomain.test(parsedAddress.host) || ipRegex({ exact: true }).test(parsedAddress.host); return kRegexDomain.test(parsedAddress.host) || ipRegex({ exact: true }).test(parsedAddress.host);
} else { } else {
@ -125,7 +126,7 @@ class ConnectController {
}); });
this.uiVariables.setVariableEditor("server_address", newValue => { this.uiVariables.setVariableEditor("server_address", newValue => {
if(this.currentAddress === newValue.currentAddress) { if (this.currentAddress === newValue.currentAddress) {
return false; return false;
} }
@ -139,7 +140,7 @@ class ConnectController {
})); }));
this.uiVariables.setVariableProvider("nickname_valid", () => { this.uiVariables.setVariableProvider("nickname_valid", () => {
if(this.validateNickname) { if (this.validateNickname) {
const nickname = this.currentNickname || this.currentProfile?.connectUsername() || ""; const nickname = this.currentNickname || this.currentProfile?.connectUsername() || "";
return nickname.length >= 3 && nickname.length <= 30; return nickname.length >= 3 && nickname.length <= 30;
} else { } else {
@ -148,7 +149,7 @@ class ConnectController {
}); });
this.uiVariables.setVariableEditor("nickname", newValue => { this.uiVariables.setVariableEditor("nickname", newValue => {
if(this.currentNickname === newValue.currentNickname) { if (this.currentNickname === newValue.currentNickname) {
return false; return false;
} }
@ -166,7 +167,7 @@ class ConnectController {
})); }));
this.uiVariables.setVariableEditor("password", newValue => { this.uiVariables.setVariableEditor("password", newValue => {
if(this.currentPassword === newValue.password) { if (this.currentPassword === newValue.password) {
return false; return false;
} }
@ -179,7 +180,7 @@ class ConnectController {
this.uiVariables.setVariableProvider("historyShown", () => this.historyShown); this.uiVariables.setVariableProvider("historyShown", () => this.historyShown);
this.uiVariables.setVariableEditor("historyShown", newValue => { this.uiVariables.setVariableEditor("historyShown", newValue => {
if(this.historyShown === newValue) { if (this.historyShown === newValue) {
return false; return false;
} }
@ -188,8 +189,8 @@ class ConnectController {
return true; return true;
}); });
this.uiVariables.setVariableProvider("history",async () => { this.uiVariables.setVariableProvider("history", async () => {
if(!this.history) { if (!this.history) {
this.history = await connectionHistory.lastConnectedServers(10); this.history = await connectionHistory.lastConnectedServers(10);
} }
@ -237,7 +238,7 @@ class ConnectController {
this.uiVariables.setVariableEditor("profiles", newValue => { this.uiVariables.setVariableEditor("profiles", newValue => {
const profile = findConnectProfile(newValue.selected); const profile = findConnectProfile(newValue.selected);
if(!profile) { if (!profile) {
createErrorModal(tr("Invalid profile"), tr("Target connect profile is missing.")).open(); createErrorModal(tr("Invalid profile"), tr("Target connect profile is missing.")).open();
return false; return false;
} }
@ -252,16 +253,16 @@ class ConnectController {
this.uiVariables.destroy(); this.uiVariables.destroy();
} }
generateConnectParameters() : ConnectParameters | undefined { generateConnectParameters(): ConnectParameters | undefined {
if(!this.uiVariables.getVariableSync("nickname_valid", undefined, true)) { if (!this.uiVariables.getVariableSync("nickname_valid", undefined, true)) {
return undefined; return undefined;
} }
if(!this.uiVariables.getVariableSync("server_address_valid", undefined, true)) { if (!this.uiVariables.getVariableSync("server_address_valid", undefined, true)) {
return undefined; return undefined;
} }
if(!this.uiVariables.getVariableSync("profile_valid", undefined, true)) { if (!this.uiVariables.getVariableSync("profile_valid", undefined, true)) {
return undefined; return undefined;
} }
@ -279,7 +280,7 @@ class ConnectController {
} }
setSelectedHistoryId(id: number | -1) { setSelectedHistoryId(id: number | -1) {
if(this.selectedHistoryId === id) { if (this.selectedHistoryId === id) {
return; return;
} }
@ -287,7 +288,7 @@ class ConnectController {
this.uiVariables.sendVariable("history"); this.uiVariables.sendVariable("history");
const historyEntry = this.history?.find(entry => entry.id === id); const historyEntry = this.history?.find(entry => entry.id === id);
if(!historyEntry) { return; } if (!historyEntry) { return; }
this.currentAddress = historyEntry.targetAddress; this.currentAddress = historyEntry.targetAddress;
this.currentNickname = historyEntry.nickname; this.currentNickname = historyEntry.nickname;
@ -300,12 +301,12 @@ class ConnectController {
} }
setSelectedAddress(address: string | undefined, validate: boolean, updateUi: boolean) { setSelectedAddress(address: string | undefined, validate: boolean, updateUi: boolean) {
if(this.currentAddress !== address) { if (this.currentAddress !== address) {
this.currentAddress = address; this.currentAddress = address;
settings.setValue(Settings.KEY_CONNECT_ADDRESS, address); settings.setValue(Settings.KEY_CONNECT_ADDRESS, address);
this.setSelectedHistoryId(-1); this.setSelectedHistoryId(-1);
if(updateUi) { if (updateUi) {
this.uiVariables.sendVariable("server_address"); this.uiVariables.sendVariable("server_address");
} }
} }
@ -315,7 +316,7 @@ class ConnectController {
} }
setSelectedProfile(profile: ConnectionProfile | undefined) { setSelectedProfile(profile: ConnectionProfile | undefined) {
if(this.currentProfile === profile) { if (this.currentProfile === profile) {
return; return;
} }
@ -347,11 +348,11 @@ export function spawnConnectModalNew(options: ConnectModalOptions) {
const variableProvider = createIpcUiVariableProvider(); const variableProvider = createIpcUiVariableProvider();
const controller = new ConnectController(variableProvider); const controller = new ConnectController(variableProvider);
if(typeof options.selectedAddress === "string") { if (typeof options.selectedAddress === "string") {
controller.setSelectedAddress(options.selectedAddress, false, true); controller.setSelectedAddress(options.selectedAddress, false, true);
} }
if(typeof options.selectedProfile === "object") { if (typeof options.selectedProfile === "object") {
controller.setSelectedProfile(options.selectedProfile); controller.setSelectedProfile(options.selectedProfile);
} }
@ -363,7 +364,7 @@ export function spawnConnectModalNew(options: ConnectModalOptions) {
controller.uiEvents.on("action_connect", event => { controller.uiEvents.on("action_connect", event => {
const parameters = controller.generateConnectParameters(); const parameters = controller.generateConnectParameters();
if(!parameters) { if (!parameters) {
/* invalid parameters detected */ /* invalid parameters detected */
return; return;
} }
@ -371,14 +372,14 @@ export function spawnConnectModalNew(options: ConnectModalOptions) {
modal.destroy(); modal.destroy();
let connection: ConnectionHandler; let connection: ConnectionHandler;
if(event.newTab) { if (event.newTab) {
connection = server_connections.spawnConnectionHandler(); connection = server_connections.spawnConnectionHandler();
server_connections.setActiveConnectionHandler(connection); server_connections.setActiveConnectionHandler(connection);
} else { } else {
connection = server_connections.getActiveConnectionHandler(); connection = server_connections.getActiveConnectionHandler();
} }
if(!connection) { if (!connection) {
return; return;
} }

View File

@ -30,9 +30,9 @@ interface ChatBoxEvents {
} }
const LastUsedEmoji = () => { const LastUsedEmoji = () => {
const le = new Emoji({ id: 'smiley', set: 'native' }); // const le = new Emoji({ id: 'smiley', set: 'native' });
return le.component; // return le.component;
return (<p>+*+</p>)
} }
const EmojiButton = (props: { events: Registry<ChatBoxEvents> }) => { const EmojiButton = (props: { events: Registry<ChatBoxEvents> }) => {