clean code

This commit is contained in:
Chneemann 2024-06-11 21:01:47 +02:00
parent d394a78e20
commit 37fb795594
18 changed files with 40 additions and 41 deletions

View file

@ -2,7 +2,7 @@ import { CommonModule } from '@angular/common';
import { Component, EventEmitter, Input, Output } from '@angular/core'; import { Component, EventEmitter, Input, Output } from '@angular/core';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
import { Channel } from '../../../interface/channel.interface'; import { Channel } from '../../../interface/channel.interface';
import { ChannleService } from '../../../service/channle.service'; import { ChannelService } from '../../../service/channel.service';
import { UserService } from '../../../service/user.service'; import { UserService } from '../../../service/user.service';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { User } from '../../../interface/user.interface'; import { User } from '../../../interface/user.interface';
@ -40,7 +40,7 @@ export class ChannelInformationsComponent {
constructor( constructor(
private route: Router, private route: Router,
public channelService: ChannleService, public channelService: ChannelService,
public userService: UserService, public userService: UserService,
private sharedService: SharedService private sharedService: SharedService
) {} ) {}

View file

@ -14,7 +14,7 @@ import { SingleChatComponent } from '../single-chat/single-chat.component';
import { ChatMsgBoxComponent } from '../chat-msg-box/chat-msg-box.component'; import { ChatMsgBoxComponent } from '../chat-msg-box/chat-msg-box.component';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { DownloadFilesService } from '../../../service/download-files.service'; import { DownloadFilesService } from '../../../service/download-files.service';
import { ChannleService } from '../../../service/channle.service'; import { ChannelService } from '../../../service/channel.service';
import { InfoComponent } from '../info/info.component'; import { InfoComponent } from '../info/info.component';
@Component({ @Component({
@ -45,7 +45,7 @@ export class ChatContentComponent implements AfterViewInit, AfterViewChecked {
constructor( constructor(
private chatService: ChatService, private chatService: ChatService,
private userService: UserService, private userService: UserService,
public channelService: ChannleService, public channelService: ChannelService,
private downloadFilesService: DownloadFilesService, private downloadFilesService: DownloadFilesService,
private renderer: Renderer2 private renderer: Renderer2
) {} ) {}

View file

@ -16,7 +16,7 @@ import { EmojiPickerComponent } from '../../../shared/components/emoji-picker/em
import { SmallBtnComponent } from '../../../shared/components/small-btn/small-btn.component'; import { SmallBtnComponent } from '../../../shared/components/small-btn/small-btn.component';
import { ChatService } from '../../../service/chat.service'; import { ChatService } from '../../../service/chat.service';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { ChannleService } from '../../../service/channle.service'; import { ChannelService } from '../../../service/channel.service';
import { ToggleBooleanService } from '../../../service/toggle-boolean.service'; import { ToggleBooleanService } from '../../../service/toggle-boolean.service';
import { User } from '../../../interface/user.interface'; import { User } from '../../../interface/user.interface';
import { MessageData } from '../../../interface/chat.interface'; import { MessageData } from '../../../interface/chat.interface';
@ -69,7 +69,7 @@ export class ChatMsgBoxComponent {
private firestore: Firestore, private firestore: Firestore,
public userService: UserService, public userService: UserService,
private chatService: ChatService, private chatService: ChatService,
public channelService: ChannleService, public channelService: ChannelService,
public toggleBoolean: ToggleBooleanService, public toggleBoolean: ToggleBooleanService,
private sharedService: SharedService private sharedService: SharedService
) {} ) {}

View file

@ -1,5 +1,5 @@
import { Component, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { ChannleService } from '../../../service/channle.service'; import { ChannelService } from '../../../service/channel.service';
import { UserService } from '../../../service/user.service'; import { UserService } from '../../../service/user.service';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
@ -14,7 +14,7 @@ export class InfoComponent {
@Input() currentChannel: string = ''; @Input() currentChannel: string = '';
constructor( constructor(
private channelService: ChannleService, private channelService: ChannelService,
public userService: UserService public userService: UserService
) {} ) {}

View file

@ -1,5 +1,5 @@
import { Component, ElementRef, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { ChannleService } from '../../service/channle.service'; import { ChannelService } from '../../service/channel.service';
import { MainComponent } from '../main/main.component'; import { MainComponent } from '../main/main.component';
import { ChatService } from '../../service/chat.service'; import { ChatService } from '../../service/chat.service';
import { UserService } from '../../service/user.service'; import { UserService } from '../../service/user.service';
@ -9,7 +9,6 @@ import {
PrvChannel, PrvChannel,
publicChannels, publicChannels,
} from '../../interface/channel.interface'; } from '../../interface/channel.interface';
import { Chat } from '../../interface/chat.interface';
import { NavigationStart, Router } from '@angular/router'; import { NavigationStart, Router } from '@angular/router';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { ChatContentComponent } from './chat-content/chat-content.component'; import { ChatContentComponent } from './chat-content/chat-content.component';
@ -61,7 +60,7 @@ export class MainChatComponent {
constructor( constructor(
private route: Router, private route: Router,
public userService: UserService, public userService: UserService,
public channelService: ChannleService, public channelService: ChannelService,
public chatService: ChatService, public chatService: ChatService,
public toggleBoolean: ToggleBooleanService, public toggleBoolean: ToggleBooleanService,
private sharedService: SharedService private sharedService: SharedService

View file

@ -2,7 +2,7 @@ import { CommonModule } from '@angular/common';
import { Component, EventEmitter, Input, Output } from '@angular/core'; import { Component, EventEmitter, Input, Output } from '@angular/core';
import { User } from '../../../../interface/user.interface'; import { User } from '../../../../interface/user.interface';
import { ToggleBooleanService } from '../../../../service/toggle-boolean.service'; import { ToggleBooleanService } from '../../../../service/toggle-boolean.service';
import { ChannleService } from '../../../../service/channle.service'; import { ChannelService } from '../../../../service/channel.service';
import { UserService } from '../../../../service/user.service'; import { UserService } from '../../../../service/user.service';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
@ -25,7 +25,7 @@ export class OpenSendPrvMessageWindowComponent {
constructor( constructor(
public toggleBoolean: ToggleBooleanService, public toggleBoolean: ToggleBooleanService,
private channelService: ChannleService, private channelService: ChannelService,
public userService: UserService, public userService: UserService,
private route: Router private route: Router
) {} ) {}

View file

@ -4,7 +4,7 @@ import { CommonModule } from '@angular/common';
import { SmallBtnComponent } from '../../../shared/components/small-btn/small-btn.component'; import { SmallBtnComponent } from '../../../shared/components/small-btn/small-btn.component';
import { User } from '../../../interface/user.interface'; import { User } from '../../../interface/user.interface';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
import { ChannleService } from '../../../service/channle.service'; import { ChannelService } from '../../../service/channel.service';
import { UserService } from '../../../service/user.service'; import { UserService } from '../../../service/user.service';
import { OpenSendPrvMessageWindowComponent } from './open-send-prv-message-window/open-send-prv-message-window.component'; import { OpenSendPrvMessageWindowComponent } from './open-send-prv-message-window/open-send-prv-message-window.component';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
@ -40,7 +40,7 @@ export class ShowChannelMemberComponent {
constructor( constructor(
public toggleBoolean: ToggleBooleanService, public toggleBoolean: ToggleBooleanService,
public channelService: ChannleService, public channelService: ChannelService,
public userService: UserService public userService: UserService
) {} ) {}

View file

@ -15,7 +15,7 @@ import { SidebarComponent } from '../sidebar/sidebar.component';
import { MainChatComponent } from '../main-chat/main-chat.component'; import { MainChatComponent } from '../main-chat/main-chat.component';
import { SecondaryChatComponent } from '../secondary-chat/secondary-chat.component'; import { SecondaryChatComponent } from '../secondary-chat/secondary-chat.component';
import { ChatService } from '../../service/chat.service'; import { ChatService } from '../../service/chat.service';
import { ChannleService } from '../../service/channle.service'; import { ChannelService } from '../../service/channel.service';
import { SidebarToggleComponent } from '../sidebar/sidebar-toggle/sidebar-toggle.component'; import { SidebarToggleComponent } from '../sidebar/sidebar-toggle/sidebar-toggle.component';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { AddNewChannelComponent } from '../sidebar/sidebar-channels/add-new-channel/add-new-channel.component'; import { AddNewChannelComponent } from '../sidebar/sidebar-channels/add-new-channel/add-new-channel.component';
@ -44,7 +44,7 @@ export class MainComponent implements OnInit {
constructor( constructor(
public userService: UserService, public userService: UserService,
public chatService: ChatService, public chatService: ChatService,
public channelService: ChannleService, public channelService: ChannelService,
private router: Router, private router: Router,
private route: ActivatedRoute, private route: ActivatedRoute,
public toggleAllBooleans: ToggleBooleanService, public toggleAllBooleans: ToggleBooleanService,

View file

@ -7,7 +7,7 @@ import {
ViewChild, ViewChild,
} from '@angular/core'; } from '@angular/core';
import { UserService } from '../../service/user.service'; import { UserService } from '../../service/user.service';
import { ChannleService } from '../../service/channle.service'; import { ChannelService } from '../../service/channel.service';
import { ChatService } from '../../service/chat.service'; import { ChatService } from '../../service/chat.service';
import { MainComponent } from '../main/main.component'; import { MainComponent } from '../main/main.component';
import { SingleChatComponent } from '../main-chat/single-chat/single-chat.component'; import { SingleChatComponent } from '../main-chat/single-chat/single-chat.component';
@ -38,7 +38,7 @@ export class SecondaryChatComponent implements AfterViewChecked {
constructor( constructor(
public userService: UserService, public userService: UserService,
public channelService: ChannleService, public channelService: ChannelService,
public chatService: ChatService, public chatService: ChatService,
private renderer: Renderer2 private renderer: Renderer2
) {} ) {}

View file

@ -2,7 +2,7 @@ import { Component, EventEmitter, Input, Output } from '@angular/core';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { UserService } from '../../../service/user.service'; import { UserService } from '../../../service/user.service';
import { User } from '../../../interface/user.interface'; import { User } from '../../../interface/user.interface';
import { ChannleService } from '../../../service/channle.service'; import { ChannelService } from '../../../service/channel.service';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { SmallBtnComponent } from '../../../shared/components/small-btn/small-btn.component'; import { SmallBtnComponent } from '../../../shared/components/small-btn/small-btn.component';
import { ChatService } from '../../../service/chat.service'; import { ChatService } from '../../../service/chat.service';
@ -24,7 +24,7 @@ export class ShowAllUsersComponent {
constructor( constructor(
public userService: UserService, public userService: UserService,
private route: Router, private route: Router,
private channelService: ChannleService, private channelService: ChannelService,
private chatService: ChatService, private chatService: ChatService,
public toggleBoolean: ToggleBooleanService, public toggleBoolean: ToggleBooleanService,
private sharedService: SharedService private sharedService: SharedService

View file

@ -1,6 +1,6 @@
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { Component, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { ChannleService } from '../../../../service/channle.service'; import { ChannelService } from '../../../../service/channel.service';
import { SmallBtnComponent } from '../../../../shared/components/small-btn/small-btn.component'; import { SmallBtnComponent } from '../../../../shared/components/small-btn/small-btn.component';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
import { UserService } from '../../../../service/user.service'; import { UserService } from '../../../../service/user.service';
@ -37,7 +37,7 @@ export class AddNewChannelComponent {
showNextWindowMobile: boolean = false; showNextWindowMobile: boolean = false;
constructor( constructor(
public channelService: ChannleService, public channelService: ChannelService,
public userService: UserService, public userService: UserService,
public route: Router, public route: Router,
private sharedService: SharedService, private sharedService: SharedService,

View file

@ -1,5 +1,5 @@
import { Component, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { ChannleService } from '../../../service/channle.service'; import { ChannelService } from '../../../service/channel.service';
import { Channel, publicChannels } from '../../../interface/channel.interface'; import { Channel, publicChannels } from '../../../interface/channel.interface';
import { RouterLink } from '@angular/router'; import { RouterLink } from '@angular/router';
import { ChatService } from '../../../service/chat.service'; import { ChatService } from '../../../service/chat.service';
@ -33,7 +33,7 @@ export class SidebarChannelsComponent {
minimizeChannels: boolean = true; minimizeChannels: boolean = true;
constructor( constructor(
public channelService: ChannleService, public channelService: ChannelService,
public chatService: ChatService, public chatService: ChatService,
public userService: UserService, public userService: UserService,
public toggleBoolean: ToggleBooleanService, public toggleBoolean: ToggleBooleanService,

View file

@ -1,7 +1,7 @@
import { Component, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { UserService } from '../../../service/user.service'; import { UserService } from '../../../service/user.service';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { ChannleService } from '../../../service/channle.service'; import { ChannelService } from '../../../service/channel.service';
import { RouterLink } from '@angular/router'; import { RouterLink } from '@angular/router';
import { ChatService } from '../../../service/chat.service'; import { ChatService } from '../../../service/chat.service';
import { ToggleBooleanService } from '../../../service/toggle-boolean.service'; import { ToggleBooleanService } from '../../../service/toggle-boolean.service';
@ -22,7 +22,7 @@ export class SidebarDirectMessagesUserComponent {
constructor( constructor(
public userService: UserService, public userService: UserService,
private channelService: ChannleService, private channelService: ChannelService,
public chatService: ChatService, public chatService: ChatService,
public toggleBoolean: ToggleBooleanService, public toggleBoolean: ToggleBooleanService,
private sharedService: SharedService private sharedService: SharedService

View file

@ -4,7 +4,7 @@ import { SidebarChannelsComponent } from './sidebar-channels/sidebar-channels.co
import { SidebarDirectMessagesComponent } from './sidebar-direct-messages/sidebar-direct-messages.component'; import { SidebarDirectMessagesComponent } from './sidebar-direct-messages/sidebar-direct-messages.component';
import { SmallBtnComponent } from '../../shared/components/small-btn/small-btn.component'; import { SmallBtnComponent } from '../../shared/components/small-btn/small-btn.component';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { ChannleService } from '../../service/channle.service'; import { ChannelService } from '../../service/channel.service';
import { ToggleBooleanService } from '../../service/toggle-boolean.service'; import { ToggleBooleanService } from '../../service/toggle-boolean.service';
import { ChatService } from '../../service/chat.service'; import { ChatService } from '../../service/chat.service';
import { SharedService } from '../../service/shared.service'; import { SharedService } from '../../service/shared.service';
@ -30,7 +30,7 @@ export class SidebarComponent implements OnInit {
currentChannel: string = ''; currentChannel: string = '';
constructor( constructor(
public channelService: ChannleService, public channelService: ChannelService,
public toggleBoolean: ToggleBooleanService, public toggleBoolean: ToggleBooleanService,
private router: ActivatedRoute, private router: ActivatedRoute,
public chatService: ChatService, public chatService: ChatService,

View file

@ -17,7 +17,7 @@ import { ChatService } from './chat.service';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
}) })
export class ChannleService implements OnDestroy { export class ChannelService implements OnDestroy {
firestore: Firestore = inject(Firestore); firestore: Firestore = inject(Firestore);
allChannels: Channel[] = []; allChannels: Channel[] = [];
@ -44,7 +44,7 @@ export class ChannleService implements OnDestroy {
* @param path Path of the collection in Firestore. * @param path Path of the collection in Firestore.
* @returns Firestore collection reference. * @returns Firestore collection reference.
*/ */
firesorePath(path: string) { firestorePath(path: string) {
return collection(this.firestore, path); return collection(this.firestore, path);
} }
@ -53,7 +53,7 @@ export class ChannleService implements OnDestroy {
* @returns Unsubscribe function. * @returns Unsubscribe function.
*/ */
subChannelList() { subChannelList() {
return onSnapshot(this.firesorePath('channels'), (list) => { return onSnapshot(this.firestorePath('channels'), (list) => {
this.allChannels = []; this.allChannels = [];
list.forEach((element) => { list.forEach((element) => {
const channelWithId = { id: element.id, ...element.data() } as Channel; const channelWithId = { id: element.id, ...element.data() } as Channel;
@ -67,7 +67,7 @@ export class ChannleService implements OnDestroy {
* @returns Unsubscribe function. * @returns Unsubscribe function.
*/ */
subPrvChannelList() { subPrvChannelList() {
return onSnapshot(this.firesorePath('prv-channels'), (list) => { return onSnapshot(this.firestorePath('prv-channels'), (list) => {
this.allPrvChannels = []; this.allPrvChannels = [];
list.forEach((element) => { list.forEach((element) => {
const channelWithId = { const channelWithId = {
@ -107,7 +107,7 @@ export class ChannleService implements OnDestroy {
path: string path: string
): Promise<string | undefined> { ): Promise<string | undefined> {
try { try {
const docRef = await addDoc(this.firesorePath(path), newChannel); const docRef = await addDoc(this.firestorePath(path), newChannel);
this.chatService.getPrvChatId = docRef.id; this.chatService.getPrvChatId = docRef.id;
return docRef.id; return docRef.id;
} catch (err) { } catch (err) {

View file

@ -7,7 +7,7 @@ import {
updateDoc, updateDoc,
} from '@angular/fire/firestore'; } from '@angular/fire/firestore';
import { User } from '../interface/user.interface'; import { User } from '../interface/user.interface';
import { ChannleService } from './channle.service'; import { ChannelService } from './channel.service';
import { getAuth, signOut } from 'firebase/auth'; import { getAuth, signOut } from 'firebase/auth';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import CryptoJS from 'crypto-es'; import CryptoJS from 'crypto-es';
@ -28,7 +28,7 @@ export class UserService implements OnDestroy {
unsubUser; unsubUser;
constructor(private channelService: ChannleService, private route: Router) { constructor(private channelService: ChannelService, private route: Router) {
this.unsubUser = this.subUserList(); this.unsubUser = this.subUserList();
} }

View file

@ -10,7 +10,7 @@ import {
import { EditUserComponent } from '../edit-user.component'; import { EditUserComponent } from '../edit-user.component';
import { UserService } from '../../../../../service/user.service'; import { UserService } from '../../../../../service/user.service';
import { FormsModule, NgForm } from '@angular/forms'; import { FormsModule, NgForm } from '@angular/forms';
import { ChannleService } from '../../../../../service/channle.service'; import { ChannelService } from '../../../../../service/channel.service';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { SmallBtnComponent } from '../../../small-btn/small-btn.component'; import { SmallBtnComponent } from '../../../small-btn/small-btn.component';
@ -43,7 +43,7 @@ export class EditUserDetailsComponent {
constructor( constructor(
public userService: UserService, public userService: UserService,
public channelService: ChannleService public channelService: ChannelService
) {} ) {}
/** Filters whether the user is a guest. */ /** Filters whether the user is a guest. */

View file

@ -5,7 +5,7 @@ import { Channel } from '../../../../interface/channel.interface';
import { Chat } from '../../../../interface/chat.interface'; import { Chat } from '../../../../interface/chat.interface';
import { UserService } from '../../../../service/user.service'; import { UserService } from '../../../../service/user.service';
import { ToggleBooleanService } from '../../../../service/toggle-boolean.service'; import { ToggleBooleanService } from '../../../../service/toggle-boolean.service';
import { ChannleService } from '../../../../service/channle.service'; import { ChannelService } from '../../../../service/channel.service';
import { ChatService } from '../../../../service/chat.service'; import { ChatService } from '../../../../service/chat.service';
import { DomSanitizer } from '@angular/platform-browser'; import { DomSanitizer } from '@angular/platform-browser';
import { Router, RouterLink } from '@angular/router'; import { Router, RouterLink } from '@angular/router';
@ -43,7 +43,7 @@ export class SearchBarComponent {
constructor( constructor(
public userService: UserService, public userService: UserService,
public toggleBoolean: ToggleBooleanService, public toggleBoolean: ToggleBooleanService,
private channelService: ChannleService, private channelService: ChannelService,
private chatService: ChatService, private chatService: ChatService,
public sanitizer: DomSanitizer, public sanitizer: DomSanitizer,
private route: Router, private route: Router,