Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 62bc82f158 |
30
ngsw-config.json
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
|
||||||
|
"index": "/index.html",
|
||||||
|
"assetGroups": [
|
||||||
|
{
|
||||||
|
"name": "app",
|
||||||
|
"installMode": "prefetch",
|
||||||
|
"resources": {
|
||||||
|
"files": [
|
||||||
|
"/favicon.ico",
|
||||||
|
"/index.csr.html",
|
||||||
|
"/index.html",
|
||||||
|
"/manifest.webmanifest",
|
||||||
|
"/*.css",
|
||||||
|
"/*.js"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "assets",
|
||||||
|
"installMode": "lazy",
|
||||||
|
"updateMode": "prefetch",
|
||||||
|
"resources": {
|
||||||
|
"files": [
|
||||||
|
"/**/*.(svg|cur|jpg|jpeg|png|apng|webp|avif|gif|otf|ttf|woff|woff2)"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
26
package-lock.json
generated
@@ -16,7 +16,7 @@
|
|||||||
"@angular/platform-browser": "^21.2.0",
|
"@angular/platform-browser": "^21.2.0",
|
||||||
"@angular/router": "^21.2.0",
|
"@angular/router": "^21.2.0",
|
||||||
"@angular/service-worker": "^21.2.0",
|
"@angular/service-worker": "^21.2.0",
|
||||||
"@chatenium/chatenium-sdk": "^1.1.5",
|
"@chatenium/chatenium-sdk": "^1.1.7",
|
||||||
"@fortawesome/angular-fontawesome": "^4.0.0",
|
"@fortawesome/angular-fontawesome": "^4.0.0",
|
||||||
"@fortawesome/free-brands-svg-icons": "^7.1.0",
|
"@fortawesome/free-brands-svg-icons": "^7.1.0",
|
||||||
"@fortawesome/free-solid-svg-icons": "^7.1.0",
|
"@fortawesome/free-solid-svg-icons": "^7.1.0",
|
||||||
@@ -1011,9 +1011,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@chatenium/chatenium-sdk": {
|
"node_modules/@chatenium/chatenium-sdk": {
|
||||||
"version": "1.1.5",
|
"version": "1.1.7",
|
||||||
"resolved": "https://registry.npmjs.org/@chatenium/chatenium-sdk/-/chatenium-sdk-1.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/@chatenium/chatenium-sdk/-/chatenium-sdk-1.1.7.tgz",
|
||||||
"integrity": "sha512-seEsxlRk96WHsE4h6oPPa5nGZioePIZpB5qk0Xs3CaKNbVJKH02/Q5HW2PIi6DHw+djAENWu5zVXIic+9DrqZw==",
|
"integrity": "sha512-8stVVjKwwWZvUfVeWzSK1WGIiSt95Yxr80nfltZSDmqMKQaEA1sL9/2V6pobM4mCs9nzjUQQiniEPVQ0uxPXAg==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@faker-js/faker": "^10.4.0",
|
"@faker-js/faker": "^10.4.0",
|
||||||
"axios": "^1.14.0",
|
"axios": "^1.14.0",
|
||||||
@@ -4969,9 +4969,9 @@
|
|||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
"node_modules/baseline-browser-mapping": {
|
"node_modules/baseline-browser-mapping": {
|
||||||
"version": "2.10.17",
|
"version": "2.10.18",
|
||||||
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.17.tgz",
|
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.18.tgz",
|
||||||
"integrity": "sha512-HdrkN8eVG2CXxeifv/VdJ4A4RSra1DTW8dc/hdxzhGHN8QePs6gKaWM9pHPcpCoxYZJuOZ8drHmbdpLHjCYjLA==",
|
"integrity": "sha512-VSnGQAOLtP5mib/DPyg2/t+Tlv65NTBz83BJBJvmLVHHuKJVaDOBvJJykiT5TR++em5nfAySPccDZDa4oSrn8A==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"bin": {
|
"bin": {
|
||||||
@@ -5045,9 +5045,9 @@
|
|||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
"node_modules/brace-expansion": {
|
"node_modules/brace-expansion": {
|
||||||
"version": "2.0.3",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.0.tgz",
|
||||||
"integrity": "sha512-MCV/fYJEbqx68aE58kv2cA/kiky1G8vux3OR6/jbS+jIMe/6fJWa0DTzJU7dqijOWYwHi1t29FlfYI9uytqlpA==",
|
"integrity": "sha512-TN1kCZAgdgweJhWWpgKYrQaMNHcDULHkWwQIspdtjV4Y5aurRdZpjAqn6yX3FPqTA9ngHCc4hJxMAMgGfve85w==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -7854,9 +7854,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/multimatch/node_modules/brace-expansion": {
|
"node_modules/multimatch/node_modules/brace-expansion": {
|
||||||
"version": "1.1.13",
|
"version": "1.1.14",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.13.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.14.tgz",
|
||||||
"integrity": "sha512-9ZLprWS6EENmhEOpjCYW2c8VkmOvckIJZfkr7rBW6dObmfgJ/L1GpSYW5Hpo9lDz4D1+n0Ckz8rU7FwHDQiG/w==",
|
"integrity": "sha512-MWPGfDxnyzKU7rNOW9SP/c50vi3xrmrua/+6hfPbCS2ABNWfx24vPidzvC7krjU/RTo235sV776ymlsMtGKj8g==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
"@angular/platform-browser": "^21.2.0",
|
"@angular/platform-browser": "^21.2.0",
|
||||||
"@angular/router": "^21.2.0",
|
"@angular/router": "^21.2.0",
|
||||||
"@angular/service-worker": "^21.2.0",
|
"@angular/service-worker": "^21.2.0",
|
||||||
"@chatenium/chatenium-sdk": "^1.1.5",
|
"@chatenium/chatenium-sdk": "^1.1.7",
|
||||||
"@fortawesome/angular-fontawesome": "^4.0.0",
|
"@fortawesome/angular-fontawesome": "^4.0.0",
|
||||||
"@fortawesome/free-brands-svg-icons": "^7.1.0",
|
"@fortawesome/free-brands-svg-icons": "^7.1.0",
|
||||||
"@fortawesome/free-solid-svg-icons": "^7.1.0",
|
"@fortawesome/free-solid-svg-icons": "^7.1.0",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "3.0 Beta 3 (April 11, 2026)",
|
"version": "3.0 Beta 4 (April 11, 2026)",
|
||||||
"ok": "Ok",
|
"ok": "Ok",
|
||||||
"back": "Back",
|
"back": "Back",
|
||||||
"aChatProgram": "A messaging platform that you can trust.",
|
"aChatProgram": "A messaging platform that you can trust.",
|
||||||
@@ -104,9 +104,8 @@
|
|||||||
"changeLogDialog": {
|
"changeLogDialog": {
|
||||||
"label": "Chatenium has been updated",
|
"label": "Chatenium has been updated",
|
||||||
"changeLog": {
|
"changeLog": {
|
||||||
"1": "Fixed WebSocket connection issues",
|
"1": "Added support for text channels inside networks",
|
||||||
"2": "The web is now mobile-friendly",
|
"2": "Bug fixes in message box"
|
||||||
"3": "The web is now a PWA. You can now install it on your home screen"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"chatnav": {
|
"chatnav": {
|
||||||
@@ -117,6 +116,9 @@
|
|||||||
"you": "You: "
|
"you": "You: "
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"networkList": {
|
||||||
|
"newNetwork": "Start new network"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"elements": {
|
"elements": {
|
||||||
|
|||||||
BIN
public/icons/icon-128x128.png
Normal file
|
After Width: | Height: | Size: 635 B |
BIN
public/icons/icon-144x144.png
Normal file
|
After Width: | Height: | Size: 658 B |
BIN
public/icons/icon-152x152.png
Normal file
|
After Width: | Height: | Size: 769 B |
BIN
public/icons/icon-192x192.png
Normal file
|
After Width: | Height: | Size: 836 B |
BIN
public/icons/icon-384x384.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
public/icons/icon-512x512.png
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
BIN
public/icons/icon-72x72.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
public/icons/icon-96x96.png
Normal file
|
After Width: | Height: | Size: 487 B |
57
public/manifest.webmanifest
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
{
|
||||||
|
"name": "Chatenium",
|
||||||
|
"short_name": "Chtn",
|
||||||
|
"display": "standalone",
|
||||||
|
"scope": "./",
|
||||||
|
"start_url": "./",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "icons/icon-72x72.png",
|
||||||
|
"sizes": "72x72",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "maskable any"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "icons/icon-96x96.png",
|
||||||
|
"sizes": "96x96",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "maskable any"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "icons/icon-128x128.png",
|
||||||
|
"sizes": "128x128",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "maskable any"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "icons/icon-144x144.png",
|
||||||
|
"sizes": "144x144",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "maskable any"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "icons/icon-152x152.png",
|
||||||
|
"sizes": "152x152",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "maskable any"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "icons/icon-192x192.png",
|
||||||
|
"sizes": "192x192",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "maskable any"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "icons/icon-384x384.png",
|
||||||
|
"sizes": "384x384",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "maskable any"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "icons/icon-512x512.png",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "maskable any"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,16 +1,18 @@
|
|||||||
import {provideTaiga} from '@taiga-ui/core';
|
import {provideTaiga} from '@taiga-ui/core';
|
||||||
import {ApplicationConfig, provideBrowserGlobalErrorListeners, isDevMode} from '@angular/core';
|
import {ApplicationConfig, provideBrowserGlobalErrorListeners, isDevMode} from '@angular/core';
|
||||||
import {provideRouter} from '@angular/router';
|
import {provideRouter, withRouterConfig} from '@angular/router';
|
||||||
|
|
||||||
import {routes} from './app.routes';
|
import {routes} from './app.routes';
|
||||||
import {provideTranslateService} from '@ngx-translate/core';
|
import {provideTranslateService} from '@ngx-translate/core';
|
||||||
import {provideTranslateHttpLoader} from '@ngx-translate/http-loader';
|
import {provideTranslateHttpLoader} from '@ngx-translate/http-loader';
|
||||||
import { provideServiceWorker } from '@angular/service-worker';
|
import {provideServiceWorker} from '@angular/service-worker';
|
||||||
|
|
||||||
export const appConfig: ApplicationConfig = {
|
export const appConfig: ApplicationConfig = {
|
||||||
providers: [
|
providers: [
|
||||||
provideBrowserGlobalErrorListeners(),
|
provideBrowserGlobalErrorListeners(),
|
||||||
provideRouter(routes),
|
provideRouter(routes, withRouterConfig({
|
||||||
|
paramsInheritanceStrategy: "always"
|
||||||
|
})),
|
||||||
provideTaiga(),
|
provideTaiga(),
|
||||||
provideTranslateService({
|
provideTranslateService({
|
||||||
fallbackLang: "en",
|
fallbackLang: "en",
|
||||||
@@ -19,9 +21,10 @@ export const appConfig: ApplicationConfig = {
|
|||||||
prefix: "/i18n/",
|
prefix: "/i18n/",
|
||||||
suffix: ".json"
|
suffix: ".json"
|
||||||
})
|
})
|
||||||
}), provideServiceWorker('ngsw-worker.js', {
|
}),
|
||||||
enabled: !isDevMode(),
|
provideServiceWorker('ngsw-worker.js', {
|
||||||
registrationStrategy: 'registerWhenStable:30000'
|
enabled: !isDevMode(),
|
||||||
})
|
registrationStrategy: 'registerWhenStable:30000'
|
||||||
|
})
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import {authNeededGuard} from './guards/auth-needed-guard';
|
|||||||
import {Homepage} from './homepage/homepage';
|
import {Homepage} from './homepage/homepage';
|
||||||
import {Privacy} from './privacy/privacy';
|
import {Privacy} from './privacy/privacy';
|
||||||
import {TOS} from './tos/tos';
|
import {TOS} from './tos/tos';
|
||||||
|
import {Network} from './chat/network/network';
|
||||||
|
import {Text} from './chat/network/channel/text/text';
|
||||||
|
|
||||||
export const routes: Routes = [
|
export const routes: Routes = [
|
||||||
{path: '', component: Homepage},
|
{path: '', component: Homepage},
|
||||||
@@ -16,6 +18,11 @@ export const routes: Routes = [
|
|||||||
{
|
{
|
||||||
path: 'chat', component: Chat, canActivate: [authNeededGuard], children: [
|
path: 'chat', component: Chat, canActivate: [authNeededGuard], children: [
|
||||||
{path: 'dm/:chatid', component: Dm},
|
{path: 'dm/:chatid', component: Dm},
|
||||||
|
{
|
||||||
|
path: 'network/:networkId', component: Network, children: [
|
||||||
|
{path: ":categoryId/:channelId", component: Text}
|
||||||
|
]
|
||||||
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<li>{{ "chat.changeLogDialog.changeLog.1"|translate }}</li>
|
<li>{{ "chat.changeLogDialog.changeLog.1"|translate }}</li>
|
||||||
<li>{{ "chat.changeLogDialog.changeLog.2"|translate }}</li>
|
<li>{{ "chat.changeLogDialog.changeLog.2"|translate }}</li>
|
||||||
<li>{{ "chat.changeLogDialog.changeLog.3"|translate }}</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<button tuiButton iconStart="@tui.check"
|
<button tuiButton iconStart="@tui.check"
|
||||||
@@ -21,11 +20,11 @@
|
|||||||
<main id="layout" tuiGroup [collapsed]="true">
|
<main id="layout" tuiGroup [collapsed]="true">
|
||||||
<aside id="chatnav">
|
<aside id="chatnav">
|
||||||
<aside>
|
<aside>
|
||||||
<tui-segmented id="mode_switcher">
|
<tui-segmented id="mode_switcher" [(activeItemIndex)]="navigationActiveIndex">
|
||||||
<button>
|
<button>
|
||||||
<tui-icon icon="@tui.message-circle"/>
|
<tui-icon icon="@tui.message-circle"/>
|
||||||
</button>
|
</button>
|
||||||
<button disabled style="pointer-events: none; opacity: 0.5">
|
<button>
|
||||||
<tui-icon icon="@tui.network"/>
|
<tui-icon icon="@tui.network"/>
|
||||||
</button>
|
</button>
|
||||||
<button disabled style="pointer-events: none; opacity: 0.5">
|
<button disabled style="pointer-events: none; opacity: 0.5">
|
||||||
@@ -39,14 +38,31 @@
|
|||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<app-dm-list [token]="serviceManager.currentSession()!.token"
|
@switch (navigationActiveIndex) {
|
||||||
[userid]="serviceManager.currentSession()!.userData.userid"></app-dm-list>
|
@case (0) {
|
||||||
|
<app-dm-list [token]="serviceManager.currentSession()!.token"
|
||||||
|
[userid]="serviceManager.currentSession()!.userData.userid"></app-dm-list>
|
||||||
|
}
|
||||||
|
@case (1) {
|
||||||
|
<network-list [token]="serviceManager.currentSession()!.token"
|
||||||
|
[userid]="serviceManager.currentSession()!.userData.userid"></network-list>
|
||||||
|
}
|
||||||
|
}
|
||||||
</main>
|
</main>
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<main id="content">
|
<main id="content">
|
||||||
<div id="content_tint">
|
<div id="content_tint">
|
||||||
@defer (when serviceManager.chatsStatus() != LoadStatus.loading) {
|
@if (router.url.startsWith("/chat/dm")) {
|
||||||
|
<!-- To ensure data is loaded -->
|
||||||
|
@defer (when serviceManager.chatsStatus() != LoadStatus.loading) {
|
||||||
|
<router-outlet/>
|
||||||
|
}
|
||||||
|
} @else if (router.url.startsWith("/chat/network")) {
|
||||||
|
@defer (when serviceManager.networksStatus() != LoadStatus.loading) {
|
||||||
|
<router-outlet/>
|
||||||
|
}
|
||||||
|
} @else {
|
||||||
<router-outlet/>
|
<router-outlet/>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@@ -62,6 +78,10 @@
|
|||||||
<app-dm-list [token]="serviceManager.currentSession()!.token"
|
<app-dm-list [token]="serviceManager.currentSession()!.token"
|
||||||
[userid]="serviceManager.currentSession()!.userData.userid"></app-dm-list>
|
[userid]="serviceManager.currentSession()!.userData.userid"></app-dm-list>
|
||||||
}
|
}
|
||||||
|
@case (1) {
|
||||||
|
<network-list [token]="serviceManager.currentSession()!.token"
|
||||||
|
[userid]="serviceManager.currentSession()!.userData.userid"></network-list>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -82,7 +102,16 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
@defer (when serviceManager.chatsStatus() != LoadStatus.loading) {
|
@if (router.url.startsWith("/chat/dm")) {
|
||||||
|
<!-- To ensure data is loaded -->
|
||||||
|
@defer (when serviceManager.chatsStatus() != LoadStatus.loading) {
|
||||||
|
<router-outlet (activate)="routerOutletActive.set(true)" (deactivate)="routerOutletActive.set(false)"/>
|
||||||
|
}
|
||||||
|
} @else if (router.url.startsWith("/chat/network")) {
|
||||||
|
@defer (when serviceManager.networksStatus() != LoadStatus.loading) {
|
||||||
|
<router-outlet (activate)="routerOutletActive.set(true)" (deactivate)="routerOutletActive.set(false)"/>
|
||||||
|
}
|
||||||
|
} @else {
|
||||||
<router-outlet (activate)="routerOutletActive.set(true)" (deactivate)="routerOutletActive.set(false)"/>
|
<router-outlet (activate)="routerOutletActive.set(true)" (deactivate)="routerOutletActive.set(false)"/>
|
||||||
}
|
}
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -61,7 +61,6 @@
|
|||||||
border-radius: 0 20px 20px 0;
|
border-radius: 0 20px 20px 0;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background: var(--tui-background-neutral-2);
|
background: var(--tui-background-neutral-2);
|
||||||
padding: 15px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {WebSocketHandler} from '@chatenium/chatenium-sdk/core/webSocketHandler';
|
|||||||
import {TranslatePipe, TranslateService} from '@ngx-translate/core';
|
import {TranslatePipe, TranslateService} from '@ngx-translate/core';
|
||||||
import {environment} from '../../environments/environment';
|
import {environment} from '../../environments/environment';
|
||||||
import {TuiTabBarComponent, TuiTabBarItem} from '@taiga-ui/addon-mobile';
|
import {TuiTabBarComponent, TuiTabBarItem} from '@taiga-ui/addon-mobile';
|
||||||
|
import {NetworkList} from './network-list/network-list';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-chat',
|
selector: 'app-chat',
|
||||||
@@ -27,7 +28,8 @@ import {TuiTabBarComponent, TuiTabBarItem} from '@taiga-ui/addon-mobile';
|
|||||||
TuiDialog,
|
TuiDialog,
|
||||||
TranslatePipe,
|
TranslatePipe,
|
||||||
TuiTabBarComponent,
|
TuiTabBarComponent,
|
||||||
TuiTabBarItem
|
TuiTabBarItem,
|
||||||
|
NetworkList
|
||||||
],
|
],
|
||||||
templateUrl: './chat.html',
|
templateUrl: './chat.html',
|
||||||
styleUrl: './chat.scss',
|
styleUrl: './chat.scss',
|
||||||
@@ -51,7 +53,7 @@ export class Chat implements OnInit {
|
|||||||
{
|
{
|
||||||
text: "chat.tabBar.tab2",
|
text: "chat.tabBar.tab2",
|
||||||
icon: '@tui.network',
|
icon: '@tui.network',
|
||||||
implemented: false,
|
implemented: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: "chat.tabBar.tab3",
|
text: "chat.tabBar.tab3",
|
||||||
@@ -68,6 +70,10 @@ export class Chat implements OnInit {
|
|||||||
changeLogOpen = signal(false)
|
changeLogOpen = signal(false)
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
|
if (this.router.url.startsWith("/chat/network")) {
|
||||||
|
this.navigationActiveIndex = 1
|
||||||
|
}
|
||||||
|
|
||||||
this.indexedDb.openDatabase().then(async () => {
|
this.indexedDb.openDatabase().then(async () => {
|
||||||
const session = await this.serviceManager.sessionManager.loadPreferredSession()
|
const session = await this.serviceManager.sessionManager.loadPreferredSession()
|
||||||
this.serviceManager.currentSession.set(session)
|
this.serviceManager.currentSession.set(session)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<main [class.mobile]="breakpoint() == 'mobile'">
|
<main [class.mobile]="breakpoint() == 'mobile'">
|
||||||
@defer (when store) {
|
@defer (when store) {
|
||||||
<navbar backButtonDest="/chat">
|
<navbar backButtonDest="/chat">
|
||||||
<div class="items-left">
|
<div class="data">
|
||||||
<oimg [src]="store.chatData().pfp" height="50px" width="50px" [radius]="15"></oimg>
|
<oimg [src]="store.chatData().pfp" height="50px" width="50px" [radius]="15"></oimg>
|
||||||
<div class="chat-data">
|
<div class="chat-data">
|
||||||
@if (store.chatData().displayName == "") {
|
@if (store.chatData().displayName == "") {
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
main {
|
main {
|
||||||
height: 95svh;
|
height: 98svh;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-rows: 70px minmax(0, 1fr) auto;
|
grid-template-rows: 70px minmax(0, 1fr) auto;
|
||||||
|
padding: 15px;
|
||||||
|
|
||||||
&.mobile {
|
&.mobile {
|
||||||
height: 100svh;
|
height: 100svh;
|
||||||
|
|||||||
@@ -163,8 +163,7 @@ export class Dm implements OnInit {
|
|||||||
const chatData = this.serviceManager.chats().find(c => c.chatid === chatid);
|
const chatData = this.serviceManager.chats().find(c => c.chatid === chatid);
|
||||||
|
|
||||||
if (!session || !chatData) {
|
if (!session || !chatData) {
|
||||||
console.warn(`Initialization deferred for ${chatid}: Session or ChatData missing.`);
|
return
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.serviceManager.dmServices()[chatid]) {
|
if (!this.serviceManager.dmServices()[chatid]) {
|
||||||
|
|||||||
@@ -80,12 +80,12 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="items-middle">
|
<div class="items-middle">
|
||||||
<textarea (keydown.enter)="handleEnterKeydown($event); viewModel().onMessageSend(message.value, null)" [style]="'height:'+textareaHeight+'px;'" #message (input)="onTextAreaInput(message)" [(ngModel)]="viewModel().message"></textarea>
|
<textarea (keydown.enter)="viewModel().message.set(''); handleEnterKeydown($event); viewModel().onMessageSend(message.value, null)" [style]="'height:'+textareaHeight+'px;'" #message (input)="onTextAreaInput(message)" [(ngModel)]="viewModel().message"></textarea>
|
||||||
<span class="placeholder"
|
<span class="placeholder"
|
||||||
[class.hidden]="message.value != ''">{{ "chat.elements.messageBox.placeholder"|translate }}</span>
|
[class.hidden]="message.value != ''">{{ "chat.elements.messageBox.placeholder"|translate }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="items-right">
|
<div class="items-right">
|
||||||
<button [disabled]="message.value.trim() == ''" tuiButton appearance="flat" (click)="viewModel().onMessageSend(message.value, null)">
|
<button [disabled]="message.value.trim() == ''" tuiButton appearance="flat" (click)="viewModel().message.set(''); viewModel().onMessageSend(message.value, null)">
|
||||||
<tui-icon icon="@tui.send"/>
|
<tui-icon icon="@tui.send"/>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ export class MessageBox {
|
|||||||
|
|
||||||
sendMessageWithCaption() {
|
sendMessageWithCaption() {
|
||||||
this.viewModel().onMessageSend(this.viewModel().message(), this.viewModel().files())
|
this.viewModel().onMessageSend(this.viewModel().message(), this.viewModel().files())
|
||||||
|
this.viewModel().message.set("")
|
||||||
this.viewModel().files.set([])
|
this.viewModel().files.set([])
|
||||||
this.viewModel().dialogOpen.set(false)
|
this.viewModel().dialogOpen.set(false)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,10 @@
|
|||||||
@for (message of messages(); track message.msgid; let i = $index) {
|
@for (message of messages(); track message.msgid; let i = $index) {
|
||||||
<div
|
<div
|
||||||
class="message"
|
class="message"
|
||||||
[class.author]="message.author == serviceManager.currentSession()!.userData.userid"
|
[class.author]="
|
||||||
|
messageAsDm(message).author == serviceManager.currentSession()!.userData.userid ||
|
||||||
|
messageAsNetwork(message).author.userid == serviceManager.currentSession()!.userData.userid
|
||||||
|
"
|
||||||
[class.chained_start]="isMessageStartOfChain(i)"
|
[class.chained_start]="isMessageStartOfChain(i)"
|
||||||
[class.chained_middle]="isMessageMiddleInChain(i)"
|
[class.chained_middle]="isMessageMiddleInChain(i)"
|
||||||
[class.chained_end]="isMessageEndOfChain(i)"
|
[class.chained_end]="isMessageEndOfChain(i)"
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
.message {
|
.message {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
align-items: start;
|
||||||
|
|
||||||
&.author {
|
&.author {
|
||||||
align-items: end;
|
align-items: end;
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
<nav [class.mobile]="breakpoint() == 'mobile'">
|
<nav [class.includeBackButton]="breakpoint() == showBackButtonAt()" [class.mobile]="breakpoint() == 'mobile'" [class.alignCenter]="dataAlignment() == 'center'">
|
||||||
@if (breakpoint() == "mobile") {
|
@if (breakpoint() == showBackButtonAt()) {
|
||||||
<div>
|
<div>
|
||||||
<button (click)="router.navigate([backButtonDest()])" tuiButton appearance="flat" iconStart="@tui.chevron-left">
|
<button (click)="router.navigate([backButtonDest()])" tuiButton appearance="flat" iconStart="@tui.chevron-left">
|
||||||
{{"back"|translate}}
|
{{"back"|translate}}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
@if (dataAlignment() == "center" && breakpoint() != showBackButtonAt()) {
|
||||||
|
<div></div> <!-- filler to align data to center -->
|
||||||
|
}
|
||||||
<ng-content></ng-content>
|
<ng-content></ng-content>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
@@ -2,18 +2,31 @@ nav {
|
|||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 1fr;
|
grid-template-columns: 1fr 1fr;
|
||||||
|
|
||||||
&.mobile {
|
&.includeBackButton {
|
||||||
zoom: 0.85;
|
|
||||||
grid-template-columns: 1fr 1fr 1fr;
|
grid-template-columns: 1fr 1fr 1fr;
|
||||||
|
|
||||||
::ng-deep .items-left {
|
::ng-deep .data {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
::ng-deep .items-right, ::ng-deep .items-left {
|
&.mobile {
|
||||||
|
zoom: 0.85;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.alignCenter {
|
||||||
|
grid-template-columns: 1fr 1fr 1fr;
|
||||||
|
|
||||||
|
::ng-deep .data {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
::ng-deep .items-right, ::ng-deep .data {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@@ -22,4 +22,6 @@ export class Navbar {
|
|||||||
breakpoint = inject(TUI_BREAKPOINT)
|
breakpoint = inject(TUI_BREAKPOINT)
|
||||||
router = inject(Router)
|
router = inject(Router)
|
||||||
backButtonDest = input.required<string>()
|
backButtonDest = input.required<string>()
|
||||||
|
showBackButtonAt = input<"desktopSmall"|"mobile">("mobile")
|
||||||
|
dataAlignment = input<"left"|"center">("left")
|
||||||
}
|
}
|
||||||
|
|||||||
14
src/app/chat/network-list/network-list.html
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<button disabled tuiButton appearance="secondary" iconStart="@tui.plus">
|
||||||
|
{{ "chat.chatnav.networkList.newNetwork"|translate }}
|
||||||
|
</button>
|
||||||
|
|
||||||
|
@for (network of serviceManager.networks(); track network.networkId) {
|
||||||
|
<button [class.enlarge]="breakpoint() == 'mobile'" tuiButton
|
||||||
|
[appearance]="router.url == '/chat/network/' + network.networkId ? 'primary' : 'flat'"
|
||||||
|
[routerLink]="'/chat/network/' + network.networkId">
|
||||||
|
<oimg [src]="network.picture" height="35px" width="35px" [radius]="10"></oimg>
|
||||||
|
<div class="info">
|
||||||
|
<span>{{ network.name }}</span>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
}
|
||||||
28
src/app/chat/network-list/network-list.scss
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
:host {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 5px;
|
||||||
|
|
||||||
|
button {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: start;
|
||||||
|
font-weight: 600;
|
||||||
|
|
||||||
|
&.enlarge {
|
||||||
|
height: 75px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
text-align: start;
|
||||||
|
|
||||||
|
.latest_message {
|
||||||
|
margin-top: -5px;
|
||||||
|
font-size: 12px;
|
||||||
|
opacity: 50%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
22
src/app/chat/network-list/network-list.spec.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { NetworkList } from './network-list';
|
||||||
|
|
||||||
|
describe('NetworkList', () => {
|
||||||
|
let component: NetworkList;
|
||||||
|
let fixture: ComponentFixture<NetworkList>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [NetworkList],
|
||||||
|
}).compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(NetworkList);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
await fixture.whenStable();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
41
src/app/chat/network-list/network-list.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import {Component, inject, input, OnInit} from '@angular/core';
|
||||||
|
import {IndexedDB} from '../../storage/indexed-db';
|
||||||
|
import {Router, RouterLink} from '@angular/router';
|
||||||
|
import {LoadStatus, ServiceManager} from '../../service-manager';
|
||||||
|
import {TUI_BREAKPOINT, TuiButton} from '@taiga-ui/core';
|
||||||
|
import {ChatService} from '@chatenium/chatenium-sdk/services/chatService';
|
||||||
|
import {NetworkService} from '@chatenium/chatenium-sdk/services/networkService';
|
||||||
|
import {Oimg} from '../elements/oimg/oimg';
|
||||||
|
import {TranslatePipe} from '@ngx-translate/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'network-list',
|
||||||
|
imports: [
|
||||||
|
Oimg,
|
||||||
|
TranslatePipe,
|
||||||
|
TuiButton,
|
||||||
|
RouterLink
|
||||||
|
],
|
||||||
|
templateUrl: './network-list.html',
|
||||||
|
styleUrl: './network-list.scss',
|
||||||
|
})
|
||||||
|
export class NetworkList implements OnInit {
|
||||||
|
userid = input<string>("")
|
||||||
|
token = input<string>("")
|
||||||
|
|
||||||
|
indexedDb = inject(IndexedDB)
|
||||||
|
router = inject(Router)
|
||||||
|
serviceManager = inject(ServiceManager)
|
||||||
|
breakpoint = inject(TUI_BREAKPOINT)
|
||||||
|
|
||||||
|
async ngOnInit() {
|
||||||
|
this.serviceManager.networkService = new NetworkService(this.userid(), this.token(), "", this.indexedDb.getApi(), () => {})
|
||||||
|
try {
|
||||||
|
this.serviceManager.networks.set(await this.serviceManager.networkService.get())
|
||||||
|
this.serviceManager.networksStatus.set(LoadStatus.loaded)
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e)
|
||||||
|
this.serviceManager.networksStatus.set(LoadStatus.error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
34
src/app/chat/network/channel/text/text.html
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<main [class.mobile]="breakpoint() == 'mobile'">
|
||||||
|
@defer (when store) {
|
||||||
|
<navbar backButtonDest="/chat/network/{{networkId}}" showBackButtonAt="desktopSmall">
|
||||||
|
<div class="data">
|
||||||
|
<div class="chat-data">
|
||||||
|
@switch (store!.channelData().type) {
|
||||||
|
@case ("message") {
|
||||||
|
<tui-icon icon="@tui.hash"></tui-icon>
|
||||||
|
}
|
||||||
|
@case ("broadcast") {
|
||||||
|
<tui-icon icon="@tui.radio"></tui-icon>
|
||||||
|
}
|
||||||
|
@case ("voice") {
|
||||||
|
<tui-icon icon="@tui.audio-lines"></tui-icon>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<span class="main-name">{{ store!.channelData().name }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="items-right">
|
||||||
|
<button tuiButton appearance="flat" disabled>
|
||||||
|
<tui-icon icon="@tui.phone"/>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</navbar>
|
||||||
|
|
||||||
|
<messages [messageBoxViewModel]="store!.messageBox" [messages]="store!.messages()" id="scrollContainer"
|
||||||
|
(onDelete)="deleteMessage($event)"/>
|
||||||
|
|
||||||
|
<message-box [viewModel]="store!.messageBox"/>
|
||||||
|
}
|
||||||
|
|
||||||
|
</main>
|
||||||
43
src/app/chat/network/channel/text/text.scss
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
main {
|
||||||
|
height: 98svh;
|
||||||
|
display: grid;
|
||||||
|
grid-template-rows: 70px minmax(0, 1fr) auto;
|
||||||
|
padding: 15px;
|
||||||
|
|
||||||
|
&.mobile {
|
||||||
|
height: 100svh;
|
||||||
|
padding: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile {
|
||||||
|
height: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
navbar {
|
||||||
|
.chat-data {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 5px;
|
||||||
|
|
||||||
|
.main-name {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alt-name {
|
||||||
|
margin-top: -5px;
|
||||||
|
color: gray;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.items-right {
|
||||||
|
margin-top: -10px;
|
||||||
|
|
||||||
|
button {
|
||||||
|
width: 35px;
|
||||||
|
height: 35px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
22
src/app/chat/network/channel/text/text.spec.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { Text } from './text';
|
||||||
|
|
||||||
|
describe('Text', () => {
|
||||||
|
let component: Text;
|
||||||
|
let fixture: ComponentFixture<Text>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [Text],
|
||||||
|
}).compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(Text);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
await fixture.whenStable();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
235
src/app/chat/network/channel/text/text.ts
Normal file
@@ -0,0 +1,235 @@
|
|||||||
|
import {Component, inject, signal} from '@angular/core';
|
||||||
|
import {DmStorage, ServiceManager, TextChannelStorage} from '../../../../service-manager';
|
||||||
|
import {ActivatedRoute} from '@angular/router';
|
||||||
|
import {IndexedDB} from '../../../../storage/indexed-db';
|
||||||
|
import {TUI_BREAKPOINT, TuiButton, TuiIcon} from '@taiga-ui/core';
|
||||||
|
import {FileDataWithPreview, MessageBox} from '../../../elements/message-box/message-box';
|
||||||
|
import {Attachment} from '@chatenium/chatenium-sdk/domain/common.schema';
|
||||||
|
import {FileUploadProgressListener} from '@chatenium/chatenium-sdk/domain/fileUploadService.schema';
|
||||||
|
import {MessageBoxViewModel} from '../../../elements/message-box/message-box-viewmodel';
|
||||||
|
import {TextChannelServiceService} from '@chatenium/chatenium-sdk/services/textChannelService';
|
||||||
|
import {Message} from '@chatenium/chatenium-sdk/domain/textChannelService.schema';
|
||||||
|
import {Messages} from '../../../elements/messages/messages';
|
||||||
|
import {Navbar} from '../../../elements/navbar/navbar';
|
||||||
|
import {Oimg} from '../../../elements/oimg/oimg';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-text',
|
||||||
|
imports: [
|
||||||
|
MessageBox,
|
||||||
|
Messages,
|
||||||
|
Navbar,
|
||||||
|
Oimg,
|
||||||
|
TuiButton,
|
||||||
|
TuiIcon
|
||||||
|
],
|
||||||
|
templateUrl: './text.html',
|
||||||
|
styleUrl: './text.scss',
|
||||||
|
})
|
||||||
|
export class Text {
|
||||||
|
serviceManager = inject(ServiceManager)
|
||||||
|
route = inject(ActivatedRoute)
|
||||||
|
indexedDb = inject(IndexedDB)
|
||||||
|
breakpoint = inject(TUI_BREAKPOINT)
|
||||||
|
|
||||||
|
networkId = ""
|
||||||
|
channelId = ""
|
||||||
|
categoryId = ""
|
||||||
|
|
||||||
|
get store(): TextChannelStorage | null {
|
||||||
|
if (!this.serviceManager.networkServices()[this.networkId]) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return this.serviceManager.networkServices()[this.networkId].textChannels()[this.channelId]
|
||||||
|
}
|
||||||
|
|
||||||
|
async sendMessage(message: string, files: FileDataWithPreview[] | null) {
|
||||||
|
if (!this.store) return
|
||||||
|
if (!files && message.trim() == "") return
|
||||||
|
|
||||||
|
const session = this.serviceManager.currentSession();
|
||||||
|
if (session != null) {
|
||||||
|
const editedMessage = this.store.messageBox.editingMessage()
|
||||||
|
if (editedMessage) {
|
||||||
|
const storedMsg = this.store.messages().find(m => m.msgid == editedMessage.messageId)
|
||||||
|
const originalMessage: Message = JSON.parse(JSON.stringify(storedMsg))
|
||||||
|
if (storedMsg) {
|
||||||
|
storedMsg.message = message
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await this.store.service.editMessage(editedMessage.messageId, message)
|
||||||
|
} catch (e) {
|
||||||
|
if (storedMsg) {
|
||||||
|
storedMsg.message = originalMessage.message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.store.messageBox.editingMessage.set(null)
|
||||||
|
this.store.messageBox.message.set("")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let attachments: Attachment[] = []
|
||||||
|
files?.forEach(file => {
|
||||||
|
const extraMetaData: Record<string, string> = {}
|
||||||
|
extraMetaData["thumbnailMetaData"] = file.videoThumbnail ?? ""
|
||||||
|
|
||||||
|
attachments.push({
|
||||||
|
fileName: file.name,
|
||||||
|
fileId: file.fileId,
|
||||||
|
type: file.type,
|
||||||
|
format: file.extension,
|
||||||
|
path: file.blob,
|
||||||
|
height: file.height,
|
||||||
|
width: file.width,
|
||||||
|
extraMetaData: extraMetaData
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
this.store.messages.update(value => [...value, {
|
||||||
|
author: {
|
||||||
|
userid: session.userData.userid,
|
||||||
|
pfp: session.userData.pfp,
|
||||||
|
username: session.userData.username,
|
||||||
|
displayName: session.userData.displayName
|
||||||
|
},
|
||||||
|
msgid: "",
|
||||||
|
message: message,
|
||||||
|
sent_at: {
|
||||||
|
T: 0,
|
||||||
|
I: 0
|
||||||
|
},
|
||||||
|
isEdited: false,
|
||||||
|
channelId: "",
|
||||||
|
networkId: "",
|
||||||
|
categoryId: "",
|
||||||
|
files: [],
|
||||||
|
seen: false,
|
||||||
|
replyTo: "",
|
||||||
|
replyToId: "",
|
||||||
|
forwardedFrom: "",
|
||||||
|
forwardedFromName: ""
|
||||||
|
}])
|
||||||
|
|
||||||
|
this.scrollToBottom("smooth")
|
||||||
|
|
||||||
|
await this.store.service.sendMessage("", message, null, null, files, <FileUploadProgressListener>{
|
||||||
|
fileProgressUpdate: (tempMsgId, fileId, allChunks, chunksDone) => {
|
||||||
|
this.uploadProgressUpdate(tempMsgId, fileId, allChunks, chunksDone)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
this.store.messageBox.message.set("")
|
||||||
|
}
|
||||||
|
|
||||||
|
async deleteMessage(messageId: string) {
|
||||||
|
if (!this.store) return
|
||||||
|
const i = this.store.messages().findIndex(m => m.msgid == messageId)
|
||||||
|
if (i != -1) {
|
||||||
|
const originalMessage: Message = JSON.parse(JSON.stringify(this.store.messages()[i]))
|
||||||
|
this.store.messages().splice(i, 1)
|
||||||
|
try {
|
||||||
|
await this.store.service.deleteMessages([messageId])
|
||||||
|
} catch (e) {
|
||||||
|
this.store.messages().splice(i, 0, originalMessage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
scrollToBottom(anim: 'instant' | 'smooth'): void {
|
||||||
|
setTimeout(() => {
|
||||||
|
const scrollContainer = <HTMLDivElement>document.querySelector("#scrollContainer")
|
||||||
|
scrollContainer.scroll({
|
||||||
|
top: scrollContainer.scrollHeight,
|
||||||
|
left: 0,
|
||||||
|
behavior: anim
|
||||||
|
});
|
||||||
|
}, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
uploadProgressUpdate(tempMsgId: string, fileId: string, allChunks: number, chunksDone: number) {
|
||||||
|
console.log(fileId, allChunks, chunksDone)
|
||||||
|
}
|
||||||
|
|
||||||
|
// The chatid parameter ensures isolation
|
||||||
|
onWsListen(action: string, message: string, networkId: string, channelId: string) {
|
||||||
|
const data = JSON.parse(message);
|
||||||
|
if (data.channelId === channelId) {
|
||||||
|
const targetStore = this.serviceManager.networkServices()[networkId].textChannels()[channelId];
|
||||||
|
if (targetStore) {
|
||||||
|
switch (action) {
|
||||||
|
case "newMessage":
|
||||||
|
targetStore.messages.update(messages => [...messages, data]);
|
||||||
|
this.scrollToBottom("smooth")
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.route.params.subscribe(async params => {
|
||||||
|
const networkId = params['networkId'];
|
||||||
|
const categoryId = params['categoryId'];
|
||||||
|
const channelId = params['channelId'];
|
||||||
|
this.networkId = networkId;
|
||||||
|
this.categoryId = categoryId;
|
||||||
|
this.channelId = channelId;
|
||||||
|
|
||||||
|
const session = this.serviceManager.currentSession();
|
||||||
|
const networkData = this.serviceManager.networks().find(c => c.networkId === networkId);
|
||||||
|
|
||||||
|
if (!session || !networkData) {
|
||||||
|
console.warn("No network data")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const categoryData = networkData.categories.find(c => c.categoryId === categoryId);
|
||||||
|
if (!categoryData) {
|
||||||
|
console.warn("No category data")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const channelData = categoryData.channels.find(c => c.channelId === channelId);
|
||||||
|
if (!channelData) {
|
||||||
|
console.warn("No channel data")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!this.serviceManager.networkServices()[networkId]) {
|
||||||
|
console.warn("No networkService")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
console.log(this.serviceManager.networkServices())
|
||||||
|
console.log(this.serviceManager.networkServices()[networkId])
|
||||||
|
if (!this.serviceManager.networkServices()[networkId].textChannels()[channelId]) {
|
||||||
|
const newStore = {
|
||||||
|
categoryData: signal(categoryData),
|
||||||
|
channelData: signal(channelData),
|
||||||
|
messages: signal<Message[]>([]),
|
||||||
|
messageBox: new MessageBoxViewModel((msg, files) => this.sendMessage(msg, files)),
|
||||||
|
wsListener: (action, data) => this.onWsListen(action, data, networkId, categoryId),
|
||||||
|
} as TextChannelStorage;
|
||||||
|
|
||||||
|
newStore.service = new TextChannelServiceService(
|
||||||
|
session.userData.userid,
|
||||||
|
session.token,
|
||||||
|
networkId,
|
||||||
|
categoryId,
|
||||||
|
channelId,
|
||||||
|
this.indexedDb.getApi(),
|
||||||
|
(action, data) => newStore.wsListener(action, data)
|
||||||
|
);
|
||||||
|
|
||||||
|
this.serviceManager.networkServices()[networkId].textChannels()[channelId] = newStore;
|
||||||
|
|
||||||
|
const currentStore = this.serviceManager.networkServices()[networkId].textChannels()[channelId]
|
||||||
|
const history = await currentStore.service.get();
|
||||||
|
currentStore.messages.set(history);
|
||||||
|
this.scrollToBottom("instant")
|
||||||
|
|
||||||
|
await currentStore.service.joinWebSocketRoom();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
44
src/app/chat/network/network.html
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
@defer(when store) {
|
||||||
|
<div id="layout" [class.routerOutletActive]="routerOutletActive()" [class.hideNetworkNav]="routerOutletActive() && breakpoint() == 'desktopSmall'">
|
||||||
|
<div id="router">
|
||||||
|
<router-outlet (activate)="routerOutletActive.set(true)" (deactivate)="routerOutletActive.set(false)"></router-outlet>
|
||||||
|
</div>
|
||||||
|
<div id="network-data">
|
||||||
|
<navbar backButtonDest="/chat" dataAlignment="center">
|
||||||
|
<div class="data">
|
||||||
|
<oimg [src]="store.networkData().picture" height="50px" width="50px" [radius]="15"></oimg>
|
||||||
|
<h2>{{store.networkData().name}}</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="items-right"></div>
|
||||||
|
</navbar>
|
||||||
|
|
||||||
|
<main tuiGroup orientation="vertical" style="width: 100%">
|
||||||
|
@for (category of store.networkData().categories; track category) {
|
||||||
|
<div class="category">
|
||||||
|
<h2>{{category.name}}</h2>
|
||||||
|
|
||||||
|
<div tuiGroup orientation="vertical" style="width: 100%">
|
||||||
|
@for (channel of category.channels; track channel) {
|
||||||
|
<button tuiButton class="channel" appearance="secondary" [disabled]="channel.type != 'message'" [routerLink]="'/chat/network/'+store.networkData().networkId+'/'+category.categoryId+'/'+channel.channelId">
|
||||||
|
@switch (channel.type) {
|
||||||
|
@case ("message") {
|
||||||
|
<tui-icon icon="@tui.hash"></tui-icon>
|
||||||
|
}
|
||||||
|
@case ("broadcast") {
|
||||||
|
<tui-icon icon="@tui.radio"></tui-icon>
|
||||||
|
}
|
||||||
|
@case ("voice") {
|
||||||
|
<tui-icon icon="@tui.audio-lines"></tui-icon>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<span>{{channel.name}}</span>
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
45
src/app/chat/network/network.scss
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
#layout {
|
||||||
|
overflow-y: scroll;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 0 100%;
|
||||||
|
overflow-x: hidden;
|
||||||
|
padding: 15px;
|
||||||
|
transition: 0.2s;
|
||||||
|
|
||||||
|
&.routerOutletActive {
|
||||||
|
overflow-y: hidden;
|
||||||
|
padding: 0;
|
||||||
|
grid-template-columns: 1fr 300px;
|
||||||
|
|
||||||
|
#router {
|
||||||
|
background: var(--tui-background-neutral-1-pressed);
|
||||||
|
}
|
||||||
|
|
||||||
|
main {
|
||||||
|
padding: 15px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.hideNetworkNav {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
|
||||||
|
#network-data {
|
||||||
|
&.hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.category {
|
||||||
|
background: var(--tui-background-base-alt);
|
||||||
|
width: 100%;
|
||||||
|
padding: 15px;
|
||||||
|
|
||||||
|
.channel {
|
||||||
|
display: flex;
|
||||||
|
justify-content: start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
22
src/app/chat/network/network.spec.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { Network } from './network';
|
||||||
|
|
||||||
|
describe('Network', () => {
|
||||||
|
let component: Network;
|
||||||
|
let fixture: ComponentFixture<Network>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [Network],
|
||||||
|
}).compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(Network);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
await fixture.whenStable();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
76
src/app/chat/network/network.ts
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
import {Component, inject, OnInit, signal} from '@angular/core';
|
||||||
|
import {ActivatedRoute, RouterLink, RouterOutlet} from '@angular/router';
|
||||||
|
import {Chat} from '@chatenium/chatenium-sdk/domain/chatService.schema';
|
||||||
|
import {Message} from '@chatenium/chatenium-sdk/domain/dmService.schema';
|
||||||
|
import {MessageBoxViewModel} from '../elements/message-box/message-box-viewmodel';
|
||||||
|
import {DmStorage, NetworkStorage, ServiceManager} from '../../service-manager';
|
||||||
|
import {DMService} from '@chatenium/chatenium-sdk/services/dmService';
|
||||||
|
import {Network as NetworkData} from "@chatenium/chatenium-sdk/domain/networkService.schema"
|
||||||
|
import {NetworkService} from '@chatenium/chatenium-sdk/services/networkService';
|
||||||
|
import {IndexedDB} from '../../storage/indexed-db';
|
||||||
|
import {Navbar} from '../elements/navbar/navbar';
|
||||||
|
import {Oimg} from '../elements/oimg/oimg';
|
||||||
|
import {TUI_BREAKPOINT, TuiButton, TuiGroup, TuiIcon} from '@taiga-ui/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-network',
|
||||||
|
imports: [
|
||||||
|
RouterOutlet,
|
||||||
|
Navbar,
|
||||||
|
Oimg,
|
||||||
|
TuiGroup,
|
||||||
|
TuiButton,
|
||||||
|
TuiIcon,
|
||||||
|
RouterLink
|
||||||
|
],
|
||||||
|
templateUrl: './network.html',
|
||||||
|
styleUrl: './network.scss',
|
||||||
|
})
|
||||||
|
export class Network implements OnInit {
|
||||||
|
serviceManager = inject(ServiceManager)
|
||||||
|
route = inject(ActivatedRoute)
|
||||||
|
indexedDb = inject(IndexedDB)
|
||||||
|
breakpoint = inject(TUI_BREAKPOINT)
|
||||||
|
|
||||||
|
routerOutletActive = signal(false)
|
||||||
|
|
||||||
|
networkId = ""
|
||||||
|
get store() {
|
||||||
|
return this.serviceManager.networkServices()[this.networkId]
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.route.params.subscribe(async params => {
|
||||||
|
console.log("Loading network...")
|
||||||
|
const networkId = params['networkId'];
|
||||||
|
this.networkId = networkId;
|
||||||
|
|
||||||
|
const session = this.serviceManager.currentSession();
|
||||||
|
const networkData = this.serviceManager.networks().find(c => c.networkId === networkId);
|
||||||
|
|
||||||
|
if (!session || !networkData) {
|
||||||
|
console.warn(`Initialization deferred for ${networkId}: Session or NetworkData missing.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.serviceManager.networkServices()[networkId]) {
|
||||||
|
const newStore = {
|
||||||
|
networkData: signal<NetworkData>(networkData),
|
||||||
|
textChannels: signal({}),
|
||||||
|
wsListener: (action, data) => {
|
||||||
|
},
|
||||||
|
} as NetworkStorage;
|
||||||
|
|
||||||
|
newStore.service = new NetworkService(
|
||||||
|
session.userData.userid,
|
||||||
|
session.token,
|
||||||
|
networkId,
|
||||||
|
this.indexedDb.getApi(),
|
||||||
|
(action, data) => newStore.wsListener(action, data)
|
||||||
|
);
|
||||||
|
|
||||||
|
this.serviceManager.networkServices()[networkId] = newStore;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,6 +9,10 @@ import {Chat} from '@chatenium/chatenium-sdk/domain/chatService.schema';
|
|||||||
import {DMService} from '@chatenium/chatenium-sdk/services/dmService';
|
import {DMService} from '@chatenium/chatenium-sdk/services/dmService';
|
||||||
import {Message} from '@chatenium/chatenium-sdk/domain/dmService.schema';
|
import {Message} from '@chatenium/chatenium-sdk/domain/dmService.schema';
|
||||||
import {MessageBoxViewModel} from './chat/elements/message-box/message-box-viewmodel';
|
import {MessageBoxViewModel} from './chat/elements/message-box/message-box-viewmodel';
|
||||||
|
import {NetworkService} from '@chatenium/chatenium-sdk/services/networkService';
|
||||||
|
import {Network, NetworkCategory, NetworkChannel} from '@chatenium/chatenium-sdk/domain/networkService.schema';
|
||||||
|
import {TextChannelServiceService} from '@chatenium/chatenium-sdk/services/textChannelService';
|
||||||
|
import {Message as NetworkMessage} from '@chatenium/chatenium-sdk/domain/textChannelService.schema';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
@@ -25,6 +29,12 @@ export class ServiceManager {
|
|||||||
chatsStatus = signal<LoadStatus>(LoadStatus.loading)
|
chatsStatus = signal<LoadStatus>(LoadStatus.loading)
|
||||||
chats = signal<Chat[]>([])
|
chats = signal<Chat[]>([])
|
||||||
|
|
||||||
|
networkService: NetworkService | null = null // Initialized in network-list.ts
|
||||||
|
networksStatus = signal<LoadStatus>(LoadStatus.loading)
|
||||||
|
networks = signal<Network[]>([])
|
||||||
|
// Services for individual networks
|
||||||
|
networkServices = signal<Record<string, NetworkStorage>>({})
|
||||||
|
|
||||||
dmServices = signal<Record<string, DmStorage>>({})
|
dmServices = signal<Record<string, DmStorage>>({})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,3 +52,19 @@ export interface DmStorage {
|
|||||||
messageBox: MessageBoxViewModel
|
messageBox: MessageBoxViewModel
|
||||||
wsListener: (action: string, message: string) => void
|
wsListener: (action: string, message: string) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface NetworkStorage {
|
||||||
|
service: NetworkService
|
||||||
|
networkData: WritableSignal<Network>
|
||||||
|
wsListener: (action: string, message: string) => void
|
||||||
|
textChannels: WritableSignal<Record<string, TextChannelStorage>>
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TextChannelStorage {
|
||||||
|
service: TextChannelServiceService
|
||||||
|
messages: WritableSignal<NetworkMessage[]>
|
||||||
|
channelData: WritableSignal<NetworkChannel>
|
||||||
|
categoryData: WritableSignal<NetworkCategory>
|
||||||
|
messageBox: MessageBoxViewModel
|
||||||
|
wsListener: (action: string, message: string) => void
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {DatabaseAPI} from '@chatenium/chatenium-sdk/storage/database';
|
|||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class IndexedDB {
|
export class IndexedDB {
|
||||||
private dbVersion = 1
|
private dbVersion = 2
|
||||||
private db: IDBDatabase | null = null
|
private db: IDBDatabase | null = null
|
||||||
|
|
||||||
getApi(): DatabaseAPI {
|
getApi(): DatabaseAPI {
|
||||||
@@ -35,6 +35,7 @@ export class IndexedDB {
|
|||||||
db.createObjectStore('networks', { keyPath: 'id' })
|
db.createObjectStore('networks', { keyPath: 'id' })
|
||||||
db.createObjectStore('files', { keyPath: 'id' })
|
db.createObjectStore('files', { keyPath: 'id' })
|
||||||
db.createObjectStore('messages', { keyPath: 'id' })
|
db.createObjectStore('messages', { keyPath: 'id' })
|
||||||
|
db.createObjectStore('networkmessages', { keyPath: 'id' })
|
||||||
}
|
}
|
||||||
|
|
||||||
request.onsuccess = (event: Event) => {
|
request.onsuccess = (event: Event) => {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
export const environment = {
|
export const environment = {
|
||||||
version: "3.0-beta3",
|
version: "3.0-beta4",
|
||||||
api_url: "http://localhost:3000",
|
api_url: "http://localhost:3000",
|
||||||
cdn_url: "http://localhost:4000",
|
cdn_url: "http://localhost:4000",
|
||||||
ws_url: "ws://localhost:3000",
|
ws_url: "ws://localhost:3000",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
export const environment = {
|
export const environment = {
|
||||||
version: "3.0-beta3",
|
version: "3.0-beta4",
|
||||||
api_url: "https://api.chatenium.hu",
|
api_url: "https://api.chatenium.hu",
|
||||||
cdn_url: "https://cdn.chatenium.hu",
|
cdn_url: "https://cdn.chatenium.hu",
|
||||||
ws_url: "wss://api.chatenium.hu",
|
ws_url: "wss://api.chatenium.hu",
|
||||||
|
|||||||