Skip to content

Commit

Permalink
Merge pull request #605 from AiursoftWeb/dev
Browse files Browse the repository at this point in the history
Release 3.6.3
  • Loading branch information
Anduin2017 authored Aug 2, 2019
2 parents ee22bce + f74c1ce commit 45ff914
Show file tree
Hide file tree
Showing 23 changed files with 258 additions and 63 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ To develope Kahla, you need to install the following components:
* Git
* Nodejs and npm

We **strongly suggest** using [Visual Studio Code](https://code.visualstudio.com/) to develope this project.
We **strongly suggest** using [VSCodium](https://github.com/VSCodium/vscodium) to develope this project.

Use `Visual Studio Code` to open the directory directly.
Using VSCodium to open the directory directly.

## How to run

Expand Down
45 changes: 11 additions & 34 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kahla",
"version": "3.6.2",
"version": "3.6.3",
"description": "Kahla is a cross-platform business messaging app.",
"author": "Aiursoft <postmaster@aiursoft.com> (https://www.aiursoft.com/)",
"build": {
Expand Down Expand Up @@ -74,7 +74,7 @@
"@angular/router": "8.0.0",
"autolinker": "^3.0.5",
"blueimp-load-image": "^2.21.0",
"body-scroll-lock": "^2.6.4",
"body-scroll-lock": "^2.6.4",
"cordova-android": "^7.1.4",
"cordova-browser": "^6.0.0",
"cordova-ios": "^5.0.0",
Expand Down
9 changes: 0 additions & 9 deletions src/app/Controllers/friends.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { ContactInfo } from '../Models/ContactInfo';
import { Values } from '../values';
import { MessageService } from '../Services/MessageService';
import { CacheService } from '../Services/CacheService';
Expand Down Expand Up @@ -33,14 +32,6 @@ export class FriendsComponent implements OnInit {
}
}

public detail(info: ContactInfo): void {
if (info.userId == null) {
this.router.navigate(['/group', info.conversationId]);
} else {
this.router.navigate(['/user', info.userId]);
}
}

public createGroup(): void {
if (!this.messageService.me.emailConfirmed) {
Swal.fire('Your email is not verified!', 'You can\'t create group until your email is verified.', 'error');
Expand Down
17 changes: 15 additions & 2 deletions src/app/Controllers/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ import { InitService } from '../Services/InitService';
selector: 'app-header',
templateUrl: '../Views/header.html',
styleUrls: ['../Styles/header.scss',
'../Styles/reddot.scss']
'../Styles/reddot.scss']
})
export class HeaderComponent {
@Input() public title = 'Kahla';
@Input() public returnButton = true;
@Input() public floatingHome = -1;
@Input() public closeDirectly = false;
@Input() public button = false;
@Input() public buttonLink = '';
@Input() public buttonLink: string | number = '';
@Input() public buttonIcon = '';
@Input() public shadow = false;
@Input() public timer = false;
Expand All @@ -32,10 +33,22 @@ export class HeaderComponent {
) {}

public goBack(): void {
if (this.floatingHome !== -1) {
this.homeService.currentPage = this.floatingHome;
return;
}
if (history.length === 1 || history.state.navigationId === 1 || (this.homeService.wideScreenEnabled && this.closeDirectly)) {
this.router.navigate(['/home']);
} else {
history.back();
}
}

public linkClicked() {
if (Number(this.buttonLink)) {
this.homeService.currentPage = Number(this.buttonLink);
} else {
this.router.navigateByUrl(<string>this.buttonLink);
}
}
}
1 change: 1 addition & 0 deletions src/app/Controllers/localSearch.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { CacheService } from '../Services/CacheService';
import { SearchResult } from '../Models/SearchResult';

@Component({
selector: 'app-localsearch',
templateUrl: '../Views/localSearch.html',
styleUrls: ['../Styles/add-friend.scss',
'../Styles/button.scss']
Expand Down
123 changes: 123 additions & 0 deletions src/app/Controllers/share.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { Values } from '../values';
import { MessageService } from '../Services/MessageService';
import { CacheService } from '../Services/CacheService';
import Swal, { SweetAlertResult } from 'sweetalert2';
import { KahlaUser } from '../Models/KahlaUser';
import { GroupsResult } from '../Models/GroupsResults';
import { ConversationApiService } from '../Services/ConversationApiService';
import { AES } from 'crypto-js';
import { FriendsApiService } from '../Services/FriendsApiService';
import { ShareService } from '../Services/ShareService';

@Component({
templateUrl: '../Views/share.html',
styleUrls: [
'../Styles/menu.scss',
'../Styles/add-friend.scss',
'../Styles/friends.scss']

})
export class ShareComponent implements OnInit {
public loadingImgURL = Values.loadingImgURL;
public showUsers = true;
public message: string;
public inApp = false;

constructor(
private router: Router,
private messageService: MessageService,
public cacheService: CacheService,
private conversationApiService: ConversationApiService,
private friendsApiService: FriendsApiService,
private shareService: ShareService) {
}

public ngOnInit(): void {
if (this.shareService.share) {
this.shareService.share = false;
this.message = this.shareService.content;
this.inApp = true;
} else {
const parsedUrl = new URL(location.href);
const text = parsedUrl.searchParams.get('text');
const url = parsedUrl.searchParams.get('url');
this.message = `${text ? text : ''} ${url ? url : ''}`;
}

}

public showUsersResults(selectUsers: boolean): void {
this.showUsers = selectUsers;
}

public share(user: KahlaUser | GroupsResult, group: boolean): void {
let conversationID = group ? (<GroupsResult>user).id : 0;
if (!group) {
this.friendsApiService.UserDetail((<KahlaUser>user).id)
.subscribe(result => {
if (result.code === 0) {
conversationID = result.conversationId;
} else {
return;
}
});
}
const name = group ? (<GroupsResult>user).name : (<KahlaUser>user).nickName;
let dialog: Promise<SweetAlertResult>;
const isResource = this.message.startsWith('[img]') || this.message.startsWith('[video]') || this.message.startsWith('[file]');
if (isResource) {
const msgType = this.message.startsWith('[img]') ? 'image' : (this.message.startsWith('[video]') ? 'video' : 'file');
dialog = Swal.fire({
title: `Share ${msgType}?`,
text: `Are you sure to send this ${msgType} to ${name}?`,
showCancelButton: true,
});
} else {
dialog = Swal.fire({
title: 'Share message to',
text: `Are you sure to send this message to ${name}?`,
input: 'textarea',
inputValue: this.message,
showCancelButton: true,
});
}
dialog.then(input => {
const msg = isResource ? this.message : input.value;
if (!input.dismiss && msg) {
if (this.messageService.conversation &&
this.messageService.conversation.id === conversationID) {
this.sendMessage(msg);
} else {
this.conversationApiService.ConversationDetail(conversationID)
.subscribe(result => {
this.messageService.conversation = result.value;
this.sendMessage(msg);
});
}
}
});
}

private sendMessage(content: string): void {
const encryptedMessage = AES.encrypt(content, this.messageService.conversation.aesKey).toString();
const messageIDArry = this.messageService.getAtIDs(content);
this.conversationApiService.SendMessage(this.messageService.conversation.id,
encryptedMessage, messageIDArry.slice(1))
.subscribe(result => {
if (result.code === 0) {
this.router.navigate(['/home'], {replaceUrl: true});
Swal.fire(
'Send success',
'Your message was sent successfully.',
'success');
} else {
Swal.fire(
'Send failed',
'Something went wrong!',
'error');
}
});
}
}
12 changes: 11 additions & 1 deletion src/app/Controllers/talking.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, ElementRef, HostListener, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Params } from '@angular/router';
import { ActivatedRoute, Params, Router } from '@angular/router';
import { ConversationApiService } from '../Services/ConversationApiService';
import { Message } from '../Models/Message';
import { map, switchMap } from 'rxjs/operators';
Expand All @@ -15,6 +15,7 @@ import { KahlaUser } from '../Models/KahlaUser';
import { ElectronService } from 'ngx-electron';
import { HomeService } from '../Services/HomeService';
import { HeaderComponent } from './header.component';
import { ShareService } from '../Services/ShareService';

declare var MediaRecorder: any;

Expand Down Expand Up @@ -56,12 +57,14 @@ export class TalkingComponent implements OnInit, OnDestroy {

constructor(
private route: ActivatedRoute,
private router: Router,
private conversationApiService: ConversationApiService,
public uploadService: UploadService,
public messageService: MessageService,
private timerService: TimerService,
public _electronService: ElectronService,
private homeService: HomeService,
private shareService: ShareService
) {
}

Expand Down Expand Up @@ -415,6 +418,13 @@ export class TalkingComponent implements OnInit, OnDestroy {
this.autoSaveInterval = null;
}


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

public getAtListMaxHeight(): number {
return window.innerHeight - this.chatInputHeight - 106;
}
Expand Down
1 change: 1 addition & 0 deletions src/app/Models/Message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export class Message {
public sender: KahlaUser;
public sendTime: Date;
public content: string;
public contentRaw: string;
public isEmoji = false;
public read: boolean;
public local = false;
Expand Down
2 changes: 2 additions & 0 deletions src/app/Modules/AppRoutingModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { LocalSearchComponent } from '../Controllers/localSearch.component';
import { AdvancedSettingComponent } from '../Controllers/advanced-setting.component';
import { ManageGroupComponent } from '../Controllers/manageGroup.component';
import { HomeComponent } from '../Controllers/home.component';
import { ShareComponent } from '../Controllers/share.component';

const routes: Routes = [
{path: '', redirectTo: '/home', pathMatch: 'full'},
Expand All @@ -38,6 +39,7 @@ const routes: Routes = [
{ path: 'theme', component: ThemeComponent},
{ path: 'localsearch', component: LocalSearchComponent },
{path: 'advanced-setting', component: AdvancedSettingComponent},
{ path: 'share-target', component: ShareComponent }
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
Expand Down
4 changes: 2 additions & 2 deletions src/app/Services/MessageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class MessageService {
// this.cacheService.cachedData.conversations.splice(0, 0, conversationCache);
// this.cacheService.updateTotalUnread();
// } else {
if (this.homeService.wideScreenEnabled) {
if (this.homeService.wideScreenEnabled || this.router.isActive('home', false)) {
setTimeout(() => this.cacheService.updateConversation(), 1000);
}
// }
Expand Down Expand Up @@ -197,6 +197,7 @@ export class MessageService {
} catch (error) {
t.content = '';
}
t.contentRaw = t.content;
t.timeStamp = new Date(t.sendTime).getTime();
if (t.content.match(/^\[(video|img)\].*/)) {
const fileKey = this.uploadService.getFileKey(t.content);
Expand All @@ -212,7 +213,6 @@ export class MessageService {
imageWidth = realMaxWidth;
imageHeight = Math.floor(realMaxWidth * ratio);
}

t.content = `[img]${Values.fileAddress}${t.content.substring(5).split('-')[0]}-${imageWidth}-${imageHeight}`;
}
} else if (t.content.match(/^\[(file|audio)\].*/)) {
Expand Down
Loading

0 comments on commit 45ff914

Please sign in to comment.