Skip to content

Commit

Permalink
Merge pull request #725 from AiursoftWeb/dev
Browse files Browse the repository at this point in the history
Release 3.8.2?
  • Loading branch information
Anduin2017 authored Oct 28, 2019
2 parents dc0c2d0 + 8dee78b commit 6e85f20
Show file tree
Hide file tree
Showing 31 changed files with 297 additions and 175 deletions.
9 changes: 9 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "firefox",
"request": "launch",
"reAttach": true,
"name": "Launch Firefox against localhost",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}",
"profile": "default"
},
{
"type": "chrome",
"request": "launch",
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
![KahlaLogo](./src/assets/144x144.png)
<p align="center">
<a href="https://www.kahla.app/"><img src="https://raw.githubusercontent.com/AiursoftWeb/Kahla.App/dev/src/assets/144x144.png"></a>
</p>

# Kahla

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

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"/>
<p align="center">
<img src="https://ui.aiursoft.com/images/kahla-demo.png" alt="screenshot" width="500"/>
</p>

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>
<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><a href="//www.microsoft.com/store/apps/9PC6J2LZ180M?cid=storebadge&amp;ocid=badge">
<img src="https://assets.windowsphone.com/85864462-9c82-451e-9355-a3d5f874397a/English_get-it-from-MS_InvariantCulture_Default.png" alt="English badge" height="60"></a>

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

Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.8.1",
"version": "3.8.2",
"description": "Kahla is a cross-platform business messaging app.",
"author": "Aiursoft <postmaster@aiursoft.com> (https://www.aiursoft.com/)",
"build": {
Expand Down
8 changes: 5 additions & 3 deletions src/app/Controllers/add-friend.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FriendsApiService } from '../Services/FriendsApiService';
import { Values } from '../values';
import { SearchResult } from '../Models/SearchResult';
import { FriendshipService } from '../Services/FriendshipService';
import { ProbeService } from '../Services/ProbeService';

@Component({
templateUrl: '../Views/add-friend.html',
Expand All @@ -21,7 +22,8 @@ export class AddFriendComponent implements OnInit {

constructor(
private friendsApiService: FriendsApiService,
public friendshipService: FriendshipService
public friendshipService: FriendshipService,
private probeService: ProbeService,
) {
}

Expand All @@ -47,10 +49,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.iconFilePath;
user.avatarURL = this.probeService.encodeProbeFileUrl(user.iconFilePath);
});
result.groups.forEach(group => {
group.avatarURL = Values.fileAddress + group.imagePath;
group.avatarURL = this.probeService.encodeProbeFileUrl(group.imagePath);
});
this.results = result;
if (this.showUsers && result.usersCount === 0 && result.groupsCount !== 0) {
Expand Down
7 changes: 4 additions & 3 deletions src/app/Controllers/advanced-setting.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { AuthApiService } from '../Services/AuthApiService';
import { KahlaUser } from '../Models/KahlaUser';
import Swal from 'sweetalert2';
import { DevicesApiService } from '../Services/DevicesApiService';
import { Values } from '../values';
import { CacheService } from '../Services/CacheService';
import { ProbeService } from '../Services/ProbeService';

@Component({
templateUrl: '../Views/advanced-settings.html',
Expand All @@ -20,7 +20,8 @@ export class AdvancedSettingComponent implements OnInit {
constructor(
private authApiService: AuthApiService,
private devicesApiService: DevicesApiService,
private cacheService: CacheService
private cacheService: CacheService,
private probeService: ProbeService,
) {
}

Expand All @@ -30,7 +31,7 @@ export class AdvancedSettingComponent implements OnInit {
} else {
this.authApiService.Me().subscribe(p => {
this.me = p.value;
this.me.avatarURL = Values.fileAddress + this.me.iconFilePath;
this.me.avatarURL = this.probeService.encodeProbeFileUrl(this.me.iconFilePath);
});
}
}
Expand Down
7 changes: 5 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 { ProbeService } from '../Services/ProbeService';

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

constructor(
private friendsApiService: FriendsApiService) {
private friendsApiService: FriendsApiService,
private probeService: ProbeService,
) {
}

public ngOnInit(): void {
Expand All @@ -28,7 +31,7 @@ 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.iconFilePath;
item.targetUser.avatarURL = this.probeService.encodeProbeFileUrl(item.targetUser.iconFilePath);
});
const top = window.scrollY;
this.users = users.items;
Expand Down
9 changes: 6 additions & 3 deletions src/app/Controllers/group.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Values } from '../values';
import { GroupConversation } from '../Models/GroupConversation';
import { ConversationApiService } from '../Services/ConversationApiService';
import { MessageService } from '../Services/MessageService';
import { ProbeService } from '../Services/ProbeService';

@Component({
templateUrl: '../Views/group.html',
Expand All @@ -30,7 +31,9 @@ export class GroupComponent implements OnInit {
private conversationApiService: ConversationApiService,
private router: Router,
private cacheService: CacheService,
public messageService: MessageService) {
public messageService: MessageService,
private probeService: ProbeService,
) {
}

public ngOnInit(): void {
Expand All @@ -44,9 +47,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).groupImagePath;
this.conversation.avatarURL = this.probeService.encodeProbeFileUrl((<GroupConversation>this.conversation).groupImagePath);
this.conversation.users.forEach(user => {
user.user.avatarURL = Values.fileAddress + user.user.iconFilePath;
user.user.avatarURL = this.probeService.encodeProbeFileUrl(user.user.iconFilePath);
try {
if (user.userId === this.cacheService.cachedData.me.id) {
this.muted = user.muted;
Expand Down
9 changes: 5 additions & 4 deletions src/app/Controllers/manageGroup.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { GroupConversation } from '../Models/GroupConversation';
import { ConversationApiService } from '../Services/ConversationApiService';
import Swal from 'sweetalert2';
import { TimerService } from '../Services/TimerService';
import { Values } from '../values';
import { UploadService } from '../Services/UploadService';
import { ElectronService } from 'ngx-electron';
import { AiurCollection } from '../Models/AiurCollection';
import { CacheService } from '../Services/CacheService';
import { ProbeService } from '../Services/ProbeService';

@Component({
templateUrl: '../Views/manageGroup.html',
Expand All @@ -34,7 +34,8 @@ export class ManageGroupComponent implements OnInit {
private router: Router,
public timerService: TimerService,
public uploadService: UploadService,
public _electronService: ElectronService
public _electronService: ElectronService,
private probeService: ProbeService,
) {

}
Expand All @@ -50,12 +51,12 @@ export class ManageGroupComponent implements OnInit {
.subscribe(conversation => {
this.messageService.conversation = conversation;
this.conversation = <GroupConversation>conversation;
this.conversation.avatarURL = Values.fileAddress + this.conversation.groupImagePath;
this.conversation.avatarURL = this.probeService.encodeProbeFileUrl(this.conversation.groupImagePath);
this.newGroupName = this.conversation.groupName;
});
} else {
this.conversation = <GroupConversation>this.messageService.conversation;
this.conversation.avatarURL = Values.fileAddress + this.conversation.groupImagePath;
this.conversation.avatarURL = this.probeService.encodeProbeFileUrl(this.conversation.groupImagePath);
this.newGroupName = this.conversation.groupName;
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/app/Controllers/settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Swal from 'sweetalert2';
import { ElectronService } from 'ngx-electron';
import { CacheService } from '../Services/CacheService';
import { HomeService } from '../Services/HomeService';
import { ProbeService } from '../Services/ProbeService';

@Component({
selector: 'app-settings',
Expand All @@ -25,15 +26,17 @@ export class SettingsComponent implements OnInit {
public messageService: MessageService,
public cacheService: CacheService,
private _electronService: ElectronService,
public homeService: HomeService) {
public homeService: HomeService,
private probeService: ProbeService,
) {
}

public ngOnInit(): void {
if (!this.cacheService.cachedData.me) {
this.authApiService.Me().subscribe(p => {
if (p.code === 0) {
this.cacheService.cachedData.me = p.value;
this.cacheService.cachedData.me.avatarURL = Values.fileAddress + p.value.iconFilePath;
this.cacheService.cachedData.me.avatarURL = this.probeService.encodeProbeFileUrl(p.value.iconFilePath);
this.cacheService.saveCache();
}
});
Expand Down
50 changes: 39 additions & 11 deletions src/app/Controllers/talking.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { FriendshipService } from '../Services/FriendshipService';
import { CacheService } from '../Services/CacheService';
import { Conversation } from '../Models/Conversation';
import { FileType } from '../Models/FileType';
import { ProbeService } from '../Services/ProbeService';

declare var MediaRecorder: any;

Expand All @@ -37,7 +38,6 @@ export class TalkingComponent implements OnInit, OnDestroy {
private windowInnerHeight = 0;
private formerWindowInnerHeight = 0;
private keyBoardHeight = 0;
public fileAddress = Values.fileAddress;
private conversationID = 0;
public autoSaveInterval;
public recording = false;
Expand All @@ -52,10 +52,10 @@ export class TalkingComponent implements OnInit, OnDestroy {
public showUserList = false;
public matchedUsers: Array<KahlaUser> = [];

@ViewChild('imageInput', {static: false}) public imageInput;
@ViewChild('videoInput', {static: false}) public videoInput;
@ViewChild('fileInput', {static: false}) public fileInput;
@ViewChild('header', {static: true}) public header: HeaderComponent;
@ViewChild('imageInput', { static: false }) public imageInput;
@ViewChild('videoInput', { static: false }) public videoInput;
@ViewChild('fileInput', { static: false }) public fileInput;
@ViewChild('header', { static: true }) public header: HeaderComponent;

constructor(
private route: ActivatedRoute,
Expand All @@ -67,6 +67,7 @@ export class TalkingComponent implements OnInit, OnDestroy {
public timerService: TimerService,
private friendshipService: FriendshipService,
public _electronService: ElectronService,
public probeService: ProbeService,
) {
}

Expand Down Expand Up @@ -165,7 +166,7 @@ export class TalkingComponent implements OnInit, OnDestroy {
if (this.cacheService.cachedData.conversationDetail[this.conversationID]) {
this.updateConversation(this.cacheService.cachedData.conversationDetail[this.conversationID]);
this.messageService.initMessage(this.conversationID);
this.messageService.getMessages(this.unread, this.conversationID, -1, this.load);
this.messageService.getMessages(this.unread, this.conversationID, -1, this.load, false);
} else {
const listItem = this.cacheService.cachedData.conversations.find(t => t.conversationId === this.conversationID);
if (listItem) {
Expand Down Expand Up @@ -199,11 +200,12 @@ export class TalkingComponent implements OnInit, OnDestroy {
this.updateConversation(conversation);
if (!this.cacheService.cachedData.conversationDetail[this.conversationID]) {
this.messageService.initMessage(this.conversationID);
this.messageService.getMessages(this.unread, this.conversationID, -1, this.load);
this.messageService.getMessages(this.unread, this.conversationID, -1, this.load, false);
}
this.messageService.cleanMessageByTimer();
this.cacheService.cachedData.conversationDetail[this.conversationID] = conversation;
this.cacheService.saveCache();
this.messageService.showFailedMessages();
});
this.windowInnerHeight = window.innerHeight;
}
Expand Down Expand Up @@ -270,10 +272,10 @@ export class TalkingComponent implements OnInit, OnDestroy {
if (unsentMessages.get(_this.conversationID) &&
(<Array<string>>unsentMessages.get(_this.conversationID)).length > 0) {
const tempArray = <Array<string>>unsentMessages.get(_this.conversationID);
tempArray.push(encryptedMessage);
tempArray.push(he.decode(tempMessage.content));
unsentMessages.set(_this.conversationID, tempArray);
} else {
unsentMessages.set(_this.conversationID, [encryptedMessage]);
unsentMessages.set(_this.conversationID, [he.decode(tempMessage.content)]);
}
localStorage.setItem('unsentMessages', JSON.stringify(Array.from(unsentMessages)));
}
Expand All @@ -285,6 +287,32 @@ export class TalkingComponent implements OnInit, OnDestroy {
inputElement.style.height = 34 + 'px';
}

public resend(content: string): void {
const messageIDArry = this.messageService.getAtIDs(content);
const encryptedMessage = AES.encrypt(content, this.messageService.conversation.aesKey).toString();
this.conversationApiService.SendMessage(this.messageService.conversation.id, encryptedMessage, messageIDArry.slice(1))
.subscribe(result => {
if (result.code === 0) {
this.delete(content);
}
});
}

public delete(content: string): void {
for (let i = 0; i < this.messageService.localMessages.length; i++) {
if (this.messageService.localMessages[i].resend && this.messageService.localMessages[i].content === content) {
this.messageService.localMessages.splice(i, 1);
break;
}
}
const unsentMessages = new Map(JSON.parse(localStorage.getItem('unsentMessages')));
const tempArray = <Array<string>>unsentMessages.get(this.conversationID);
const index = tempArray.indexOf(content);
tempArray.splice(index, 1);
unsentMessages.set(this.conversationID, tempArray);
localStorage.setItem('unsentMessages', JSON.stringify(Array.from(unsentMessages)));
}

public startInput(): void {
if (this.showPanel) {
this.showPanel = false;
Expand Down Expand Up @@ -411,7 +439,7 @@ export class TalkingComponent implements OnInit, OnDestroy {
if (this.recording) {
this.mediaRecorder.stop();
} else {
navigator.mediaDevices.getUserMedia({audio: true})
navigator.mediaDevices.getUserMedia({ audio: true })
.then(stream => {
this.recording = true;
this.mediaRecorder = new MediaRecorder(stream);
Expand Down Expand Up @@ -471,7 +499,7 @@ export class TalkingComponent implements OnInit, OnDestroy {


public shareToOther(message: string): void {
this.router.navigate(['share-target', {message: message}]);
this.router.navigate(['share-target', { message: message }]);
}

public getAtListMaxHeight(): number {
Expand Down
Loading

0 comments on commit 6e85f20

Please sign in to comment.