Skip to content

Commit

Permalink
Merge pull request #623 from AiursoftWeb/dev
Browse files Browse the repository at this point in the history
Release 3.6.4
  • Loading branch information
Anduin2017 authored Aug 9, 2019
2 parents 45ff914 + 8bea6d0 commit 4205e18
Show file tree
Hide file tree
Showing 39 changed files with 172 additions and 198 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

[![Build status](https://aiursoft.visualstudio.com/Star/_apis/build/status/Kahla%20App%20Build)](https://aiursoft.visualstudio.com/Star/_build/latest?definitionId=4)

<a href='https://play.google.com/store/apps/details?id=com.aiursoft.kahla'><img alt='Get it on Google Play' src='https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png' height="80"/></a>

Welcome to Kahla. Kahla is a cross-platform business messaging app. Kahla also achieved one target to use one copy of code and target all platforms.

<img src="https://ui.cdn.aiursoft.com/images/kahla-demo.png" alt="screenshot" width="500"/>

Try it here: [web.kahla.app](https://web.kahla.app)

Or <a href='https://play.google.com/store/apps/details?id=com.aiursoft.kahla'><img alt='Get it on Google Play' src='https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png' height="80"/></a>

Kahla currently targets Windows, Linux, macOS, Android, and iOS.

Kahla is built with Angular 8 and typescript. And [Kahla Server](https://github.com/AiursoftWeb/Kahla) is built with .NET Core.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kahla",
"version": "3.6.3",
"version": "3.6.4",
"description": "Kahla is a cross-platform business messaging app.",
"author": "Aiursoft <postmaster@aiursoft.com> (https://www.aiursoft.com/)",
"build": {
Expand Down
13 changes: 13 additions & 0 deletions src/app/Controllers/about.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component } from '@angular/core';
import { CheckService } from '../Services/CheckService';
import { Values } from '../values';
import { HomeService } from '../Services/HomeService';

@Component({
templateUrl: '../Views/about.html',
Expand All @@ -14,10 +15,22 @@ export class AboutComponent {
public sourceCodeURL = Values.sourceCodeURL;
constructor(
public checkService: CheckService,
public homeService: HomeService
) {
}

public check(): void {
this.checkService.checkVersion(true);
}

public pwaAddHomeScreen(): void {
this.homeService.pwaHomeScreenPrompt.prompt();
this.homeService.pwaHomeScreenPrompt.userChoice
.then((choiceResult) => {
if (choiceResult.outcome === 'accepted') {
this.homeService.pwaHomeScreenSuccess = true;
}
this.homeService.pwaHomeScreenPrompt = null;
});
}
}
4 changes: 2 additions & 2 deletions src/app/Controllers/add-friend.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ export class AddFriendComponent implements OnInit {
this.friendsApiService.SearchEverything(term.trim(), this.searchNumbers).subscribe(result => {
if (result.code === 0) {
result.users.forEach(user => {
user.avatarURL = Values.fileAddress + user.headImgFileKey;
user.avatarURL = Values.fileAddress + user.iconFilePath;
});
result.groups.forEach(group => {
group.avatarURL = Values.fileAddress + group.imageKey;
group.avatarURL = Values.fileAddress + group.imagePath;
});
this.results = result;
if (this.showUsers && result.usersCount === 0 && result.groupsCount !== 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/Controllers/advanced-setting.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class AdvancedSettingComponent implements OnInit {
} else {
this.authApiService.Me().subscribe(p => {
this.me = p.value;
this.me.avatarURL = Values.fileAddress + this.me.headImgFileKey;
this.me.avatarURL = Values.fileAddress + this.me.iconFilePath;
});
}
}
Expand Down
15 changes: 14 additions & 1 deletion src/app/Controllers/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { MessageService } from '../Services/MessageService';

export class AppComponent implements OnInit, AfterViewInit {

public iosHeightFix = false;

constructor(
private initService: InitService,
private elementRef: ElementRef,
Expand All @@ -31,6 +33,13 @@ export class AppComponent implements OnInit, AfterViewInit {
Swal.close();
}

@HostListener('window:resize')
onResize() {
// in safari and the address bar is shown...
this.iosHeightFix = window.navigator.platform && /iP(ad|hone|od)/.test(window.navigator.platform) &&
document.body.scrollHeight - window.innerHeight >= 50;
}

@HostListener('window:load', [])
onLoad() {
if ('Notification' in window && 'serviceWorker' in navigator) {
Expand All @@ -50,6 +59,11 @@ export class AppComponent implements OnInit, AfterViewInit {
}
}

@HostListener('window:beforeinstallprompt', ['$event'])
onbeforeinstallprompt(e: any) {
this.homeService.pwaHomeScreenPrompt = e;
}

public ngOnInit(): void {
// Temporary apply the local theme setting
this.themeService.ApplyThemeFromLocal(this.elementRef);
Expand All @@ -60,7 +74,6 @@ export class AppComponent implements OnInit, AfterViewInit {
// disable body scroll for ios
if (window.navigator.platform && /iP(ad|hone|od)/.test(window.navigator.platform)) {
this.homeService.updateIosDisableScroll();

new MutationObserver(() => {
this.homeService.updateIosDisableScroll();
})
Expand Down
8 changes: 6 additions & 2 deletions src/app/Controllers/discover.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FriendsApiService } from '../Services/FriendsApiService';
import { DiscoverUser } from '../Models/DiscoverUser';
import { Values } from '../values';
import Swal from 'sweetalert2';
import { HomeService } from '../Services/HomeService';

@Component({
templateUrl: '../Views/discover.html',
Expand All @@ -17,7 +18,8 @@ export class DiscoverComponent implements OnInit {
public loadingImgURL = Values.loadingImgURL;

constructor(
private friendsApiService: FriendsApiService) {
private friendsApiService: FriendsApiService,
private homeService: HomeService) {
}

public ngOnInit(): void {
Expand All @@ -28,13 +30,15 @@ export class DiscoverComponent implements OnInit {
this.loading = true;
this.friendsApiService.Discover(this.amount).subscribe(users => {
users.items.forEach(item => {
item.targetUser.avatarURL = Values.fileAddress + item.targetUser.headImgFileKey;
item.targetUser.avatarURL = Values.fileAddress + item.targetUser.iconFilePath;
});
const top = this.homeService.contentWrapper.scrollTop;
this.users = users.items;
if (this.users.length < this.amount) {
this.noMoreUsers = true;
}
this.loading = false;
setTimeout(() => this.homeService.contentWrapper.scrollTo(0, top), 0);
this.amount += 15;
}, () => {
this.loading = false;
Expand Down
4 changes: 0 additions & 4 deletions src/app/Controllers/friends.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ export class FriendsComponent implements OnInit {
showCancelButton: true,
}).then(input => {
if (input.value) {
if (input.value.includes(' ')) {
Swal.fire('Try again', 'Group name can\'t contain whitespaces.', 'error');
return;
}
if (input.value.length < 3 || input.value.length > 25) {
Swal.fire('Try again', 'Group name length must between three and twenty five.', 'error');
return;
Expand Down
4 changes: 2 additions & 2 deletions src/app/Controllers/group.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ export class GroupComponent implements OnInit {
this.messageService.conversation = conversation;
this.conversation = <GroupConversation>conversation;
this.groupMembers = conversation.users.length;
this.conversation.avatarURL = Values.fileAddress + (<GroupConversation>this.conversation).groupImageKey;
this.conversation.avatarURL = Values.fileAddress + (<GroupConversation>this.conversation).groupImagePath;
this.conversation.users.forEach(user => {
user.user.avatarURL = Values.fileAddress + user.user.headImgFileKey;
user.user.avatarURL = Values.fileAddress + user.user.iconFilePath;
try {
if (user.userId === this.messageService.me.id) {
this.muted = user.muted;
Expand Down
6 changes: 3 additions & 3 deletions src/app/Controllers/manageGroup.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ export class ManageGroupComponent implements OnInit {
.subscribe(conversation => {
this.messageService.conversation = conversation;
this.conversation = <GroupConversation>conversation;
this.conversation.avatarURL = Values.fileAddress + this.conversation.groupImageKey;
this.conversation.avatarURL = Values.fileAddress + this.conversation.groupImagePath;
this.newGroupName = this.conversation.groupName;
});
} else {
this.conversation = <GroupConversation>this.messageService.conversation;
this.conversation.avatarURL = Values.fileAddress + this.conversation.groupImageKey;
this.conversation.avatarURL = Values.fileAddress + this.conversation.groupImagePath;
this.newGroupName = this.conversation.groupName;
}
}
Expand Down Expand Up @@ -132,7 +132,7 @@ export class ManageGroupComponent implements OnInit {
}

public saveInfo() {
this.groupsApiService.UpdateGroupInfo(this.conversation.groupName, this.conversation.groupImageKey, this.newGroupName)
this.groupsApiService.UpdateGroupInfo(this.conversation.groupName, this.conversation.groupImagePath, this.newGroupName)
.subscribe(res => {
if (res.code === 0) {
Swal.fire('Success', res.message, 'success');
Expand Down
2 changes: 1 addition & 1 deletion src/app/Controllers/settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class SettingsComponent implements OnInit {
this.authApiService.Me().subscribe(p => {
if (p.code === 0) {
this.messageService.me = p.value;
this.messageService.me.avatarURL = Values.fileAddress + p.value.headImgFileKey;
this.messageService.me.avatarURL = Values.fileAddress + p.value.iconFilePath;
}
});
}
Expand Down
10 changes: 4 additions & 6 deletions src/app/Controllers/talking.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,9 @@ export class TalkingComponent implements OnInit, OnDestroy {
for (let i = 0; i < items.length; i++) {
if (items[i].kind === 'file') {
this.preventDefault(event);
const blob = items[i].getAsFile();
const originalFile = items[i].getAsFile();
const blob = new File([originalFile],
`clipboardImg_${new Date().getTime()}.${originalFile.name.substring(originalFile.name.lastIndexOf('.') + 1)}`);
if (blob != null) {
const urlString = URL.createObjectURL(blob);
Swal.fire({
Expand Down Expand Up @@ -365,7 +367,7 @@ export class TalkingComponent implements OnInit, OnDestroy {
});
this.mediaRecorder.addEventListener('stop', () => {
this.recording = false;
const audioBlob = new File(audioChunks, 'audio');
const audioBlob = new File(audioChunks, `voiceMsg_${new Date().getTime()}.opus`);
this.uploadService.upload(audioBlob, this.conversationID, this.messageService.conversation.aesKey, 3);
clearTimeout(this.forceStopTimeout);
stream.getTracks().forEach(track => track.stop());
Expand Down Expand Up @@ -398,10 +400,6 @@ export class TalkingComponent implements OnInit, OnDestroy {
this.showUserList = false;
}

public getHeadImgUrl(fileKey: number): string {
return Values.fileAddress + fileKey;
}

public ngOnDestroy(): void {
this.destroyCurrent();
this.homeService.contentWrapper.onscroll = null;
Expand Down
2 changes: 1 addition & 1 deletion src/app/Controllers/user.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class UserComponent implements OnInit {
this.conversationId = response.conversationId;
this.sentRequest = response.sentRequest;
this.pendingRequest = response.pendingRequest;
this.info.avatarURL = Values.fileAddress + this.info.headImgFileKey;
this.info.avatarURL = Values.fileAddress + this.info.iconFilePath;
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/Controllers/userDetail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class UserDetailComponent implements OnInit {
if (!this.messageService.me) {
this.authApiService.Me().subscribe(p => {
this.user = p.value;
this.user.avatarURL = Values.fileAddress + this.user.headImgFileKey;
this.user.avatarURL = Values.fileAddress + this.user.iconFilePath;
});
} else {
this.user = Object.assign({}, this.messageService.me);
Expand All @@ -57,7 +57,7 @@ export class UserDetailComponent implements OnInit {
saveButton.textContent = 'Saving...';
const hideEmail = (<HTMLInputElement>document.querySelector('#toggleHideEmail')).checked;
this.user.makeEmailPublic = !hideEmail;
this.authApiService.UpdateInfo(this.user.nickName, this.user.bio, this.user.headImgFileKey, hideEmail)
this.authApiService.UpdateInfo(this.user.nickName, this.user.bio, this.user.iconFilePath, hideEmail)
.subscribe((response) => {
if (response.code === 0) {
this.messageService.me = Object.assign({}, this.user);
Expand Down
2 changes: 1 addition & 1 deletion src/app/Models/ContactInfo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

export class ContactInfo {
public displayName: string;
public displayImageKey: number;
public displayImagePath: string;
public latestMessage: string;
public latestMessageTime: Date;
public unReadAmount: number;
Expand Down
2 changes: 1 addition & 1 deletion src/app/Models/Conversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export class Conversation {
public discriminator: string;
public conversationCreateTime: Date;
public displayName: string;
public displayImageKey: number;
public displayImagePath: string;
public anotherUserId: string;
public aesKey: string;
public users: UserGroupRelation[];
Expand Down
6 changes: 0 additions & 6 deletions src/app/Models/FilePath.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/app/Models/GroupConversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Conversation } from './Conversation';

export class GroupConversation extends Conversation {
public groupName: string;
public groupImageKey: number;
public groupImagePath: string;
public hasPassword: boolean;
public ownerId: string;
}
2 changes: 1 addition & 1 deletion src/app/Models/GroupsResults.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export class GroupsResult {
public imageKey: number;
public imagePath: string;
public name: string;
public hasPassword: boolean;
public ownerId: string;
Expand Down
2 changes: 1 addition & 1 deletion src/app/Models/KahlaUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
public bio: string;
public email: string;
public emailConfirmed: boolean;
public headImgFileKey: number;
public iconFilePath: string;
public id: string;
public nickName: string;
public preferedLanguage: string;
Expand Down
10 changes: 10 additions & 0 deletions src/app/Models/Timers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export enum Timers {
'5s' = 5,
'30s' = 30,
'1m' = 60,
'10m' = 600,
'1h' = 3600,
'1d' = 3600 * 24,
'1w' = 3600 * 24 * 7,
'off' = Math.pow(2, 31) - 1
}
4 changes: 1 addition & 3 deletions src/app/Models/UploadFile.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { AiurProtocal } from './AiurProtocal';

export class UploadFile extends AiurProtocal {
public savedFileName: string;
public fileKey: number;
public filePath: string;
public fileSize: number;
public downloadPath: string;
}
4 changes: 2 additions & 2 deletions src/app/Services/AuthApiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ export class AuthApiService {
return this.apiService.Get(AuthApiService.serverPath + '/Me');
}

public UpdateInfo(nickName: string, bio: string, headImgKey: number, hideMyEmail: boolean): Observable<AiurProtocal> {
public UpdateInfo(nickName: string, bio: string, headIconPath: string, hideMyEmail: boolean): Observable<AiurProtocal> {
return this.apiService.Post(AuthApiService.serverPath + '/UpdateInfo', {
nickName: nickName,
bio: bio,
headImgKey: headImgKey,
headIconPath: headIconPath,
hideMyEmail: hideMyEmail
});
}
Expand Down
8 changes: 4 additions & 4 deletions src/app/Services/CacheService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class CacheService {
}
e.latestMessage = this.modifyMessage(e.latestMessage);
}
e.avatarURL = Values.fileAddress + e.displayImageKey;
e.avatarURL = Values.fileAddress + e.displayImagePath;
});
this.cachedData.conversations = info;
this.updateTotalUnread();
Expand All @@ -54,10 +54,10 @@ export class CacheService {
.subscribe(result => {
if (result.code === 0) {
result.users.forEach(user => {
user.avatarURL = Values.fileAddress + user.headImgFileKey;
user.avatarURL = Values.fileAddress + user.iconFilePath;
});
result.groups.forEach(group => {
group.avatarURL = Values.fileAddress + group.imageKey;
group.avatarURL = Values.fileAddress + group.imagePath;
});

this.cachedData.friends = result;
Expand All @@ -69,7 +69,7 @@ export class CacheService {
this.friendsApiService.MyRequests().subscribe(response => {
this.cachedData.requests = response.items;
response.items.forEach(item => {
item.creator.avatarURL = Values.fileAddress + item.creator.headImgFileKey;
item.creator.avatarURL = Values.fileAddress + item.creator.iconFilePath;
});
this.totalRequests = response.items.filter(t => !t.completed).length;
});
Expand Down
Loading

0 comments on commit 4205e18

Please sign in to comment.