forked from Hellsticks96/da_bubble
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
54 changed files
with
2,053 additions
and
2,505 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ Thumbs.db | |
.firebase | ||
*-debug.log | ||
.runtimeconfig.json | ||
/src/app/app.config.ts | ||
|
||
|
||
#firebase functions | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,17 @@ | ||
import { Injectable, inject } from "@angular/core"; | ||
import { | ||
CanActivateFn, | ||
ActivatedRouteSnapshot, | ||
RouterStateSnapshot, | ||
Router, | ||
} from "@angular/router"; | ||
import { map, catchError } from "rxjs"; | ||
import { CanActivateFn } from "@angular/router"; | ||
import { CurrentuserService } from "./currentuser.service"; | ||
|
||
@Injectable({ | ||
providedIn: "root", | ||
}) | ||
export class AuthGuard { | ||
constructor( | ||
authService: CurrentuserService, | ||
private router: Router, | ||
) { | ||
console.log(authService.isLoggedIn); | ||
} | ||
} | ||
|
||
export const canActivateGuard: CanActivateFn = ( | ||
route: ActivatedRouteSnapshot, | ||
state: RouterStateSnapshot, | ||
) => { | ||
export const canActivateGuard: CanActivateFn = () => { | ||
if (inject(CurrentuserService).isLoggedIn) { | ||
// inject(Router).navigate(['']); | ||
console.log("user is logged in"); | ||
return true; | ||
} else { | ||
// inject(Router).navigate(['login']); | ||
return false; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { CommonFnService } from './common-fn.service'; | ||
|
||
describe('CommonFnService', () => { | ||
let service: CommonFnService; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({}); | ||
service = TestBed.inject(CommonFnService); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { EmojiService } from '@ctrl/ngx-emoji-mart/ngx-emoji'; | ||
import { UsersList } from './interfaces/users-list'; | ||
import { ChatService } from './main/chat/chat.service'; | ||
import { Message } from './interfaces/message'; | ||
import { PofileInfoCardComponent } from './pofile-info-card/pofile-info-card.component'; | ||
import { MatDialog } from '@angular/material/dialog'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class CommonFnService { | ||
recentEmojis: string[] = []; | ||
|
||
|
||
constructor( | ||
private emojiService: EmojiService, | ||
private chatService: ChatService, | ||
private dialog: MatDialog | ||
) { } | ||
|
||
|
||
onMessageClick(event: MouseEvent) { | ||
const target = event.target as HTMLElement; | ||
if (target.classList.contains("highlight-mention")) { | ||
const username = target.getAttribute("data-username"); | ||
if (username) { | ||
this.openProfileCard(username); | ||
} else { | ||
console.error("Kein Benutzername definiert für dieses Element"); | ||
} | ||
} | ||
} | ||
|
||
|
||
openProfileCard(username: string) { | ||
const user = this.chatService.usersList.find( | ||
(u) => u.name === username, | ||
); | ||
if (user) { | ||
this.dialog.open(PofileInfoCardComponent, { | ||
data: user, | ||
}); | ||
} | ||
} | ||
|
||
|
||
noReactions(message: Message): boolean { | ||
return !message.reactions || Object.keys(message.reactions).length === 0; | ||
} | ||
|
||
|
||
padNumber(num: number, size: number) { | ||
let s = num + ""; | ||
while (s.length < size) s = "0" + s; | ||
return s; | ||
} | ||
|
||
|
||
dayTime(timestamp: string): string { | ||
const date = new Date(timestamp); | ||
const options: Intl.DateTimeFormatOptions = { | ||
hour: "2-digit", | ||
minute: "2-digit", | ||
hour12: false, | ||
}; | ||
return date.toLocaleTimeString("de-DE", options); | ||
} | ||
|
||
|
||
dayDate(timestamp: string): string { | ||
const date = new Date(timestamp); | ||
if (this.isToday(date)) return "Heute"; | ||
if (this.isYesterday(date)) return "Gestern"; | ||
return this.formatDate(date); | ||
} | ||
|
||
|
||
private isToday(date: Date): boolean { | ||
const today = new Date(); | ||
today.setHours(0, 0, 0, 0); | ||
return date.setHours(0, 0, 0, 0) === today.getTime(); | ||
} | ||
|
||
|
||
private isYesterday(date: Date): boolean { | ||
const yesterday = new Date(); | ||
yesterday.setDate(yesterday.getDate() - 1); | ||
yesterday.setHours(0, 0, 0, 0); | ||
return date.setHours(0, 0, 0, 0) === yesterday.getTime(); | ||
} | ||
|
||
|
||
private formatDate(date: Date): string { | ||
return date.toLocaleDateString("de-DE", { | ||
weekday: "long", | ||
day: "numeric", | ||
month: "long", | ||
}); | ||
} | ||
|
||
|
||
_filter(value: string): UsersList[] { | ||
if (this.mentionUser(value)) { | ||
const filterValue = value | ||
.slice(value.lastIndexOf("@") + 1) | ||
.toLowerCase(); | ||
return this.chatService.usersList.filter((user) => | ||
user.name.toLowerCase().includes(filterValue), | ||
); | ||
} else { | ||
return []; | ||
} | ||
} | ||
|
||
|
||
mentionUser(value: string): boolean { | ||
const atIndex = value.lastIndexOf("@"); | ||
if (atIndex === -1) return false; | ||
const charAfterAt = value.charAt(atIndex + 1); | ||
return charAfterAt !== " "; | ||
} | ||
|
||
|
||
getEmojiById(emojiId: string) { | ||
const emoji = this.emojiService.getData(emojiId); // Get the emoji by ID | ||
return emoji ? emoji.native : null; // Return the native emoji | ||
} | ||
|
||
|
||
loadRecentEmojis() { | ||
const recentEmojiData = localStorage.getItem('emoji-mart.frequently'); | ||
if (recentEmojiData) { | ||
const recentEmojiObj = JSON.parse(recentEmojiData); | ||
this.recentEmojis = Object.keys(recentEmojiObj).slice(-2).reverse(); // Get the last two emojis and reverse the order | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.