Skip to content

Commit

Permalink
Merge pull request #194 from AiursoftWeb/dev
Browse files Browse the repository at this point in the history
Publish 2.5.0
  • Loading branch information
Anduin2017 authored Dec 24, 2018
2 parents fa8f871 + 32df385 commit 12f7f82
Show file tree
Hide file tree
Showing 38 changed files with 344 additions and 159 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kahla",
"version": "2.4.0",
"version": "2.5.0",
"description": "Kahla is a cross-platform business messaging app.",
"author": "Aiursoft <postmaster@aiursoft.com> (https://www.aiursoft.com/)",
"build": {
Expand Down Expand Up @@ -83,7 +83,6 @@
"crypto-js": "^3.1.9-1",
"font-awesome": "^4.7.0",
"he": "^1.2.0",
"pulltorefreshjs": "^0.1.14",
"rxjs": "^6.3.3",
"sweetalert2": "^7.28.2",
"zone.js": "^0.8.26"
Expand Down
2 changes: 1 addition & 1 deletion publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ echo '}' >> ./www/package.json
cp ./package.json ./dist/

# rename built files to avoid space in file names.
for f in dist/*\ *; do mv "$f" "${f// /.}"; done
for f in dist/*\ *; do mv "$f" "${f// /.}"; done || true
1 change: 1 addition & 0 deletions src/app/Controllers/about.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class AboutComponent {
this.headerService.title = 'About';
this.headerService.returnButton = true;
this.headerService.button = false;
this.headerService.shadow = false;
}

public check(): void {
Expand Down
3 changes: 2 additions & 1 deletion src/app/Controllers/add-friend.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export class AddFriendComponent implements OnInit {
this.headerService.title = 'Add Friend';
this.headerService.returnButton = true;
this.headerService.button = false;
}
this.headerService.shadow = false;
}

public ngOnInit(): void {
this.users = this.searchTerms.pipe(
Expand Down
1 change: 1 addition & 0 deletions src/app/Controllers/changePassword.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class ChangePasswordComponent {
this.headerService.title = 'Change Password';
this.headerService.returnButton = true;
this.headerService.button = false;
this.headerService.shadow = false;
}

public checkValid(): void {
Expand Down
18 changes: 2 additions & 16 deletions src/app/Controllers/conversations.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { AuthApiService } from '../Services/AuthApiService';
import { ContactInfo } from '../Models/ContactInfo';
import { Router } from '@angular/router';
import { CacheService } from '../Services/CacheService';
import * as PullToRefresh from 'pulltorefreshjs';
import { Values } from '../values';
import { MessageService } from '../Services/MessageService';
import { HeaderService } from '../Services/HeaderService';
Expand All @@ -25,21 +24,10 @@ export class ConversationsComponent implements OnInit, OnDestroy {
this.headerService.button = true;
this.headerService.routerLink = '/addfriend';
this.headerService.buttonIcon = 'search';
}
this.headerService.shadow = false;
}

public ngOnInit(): void {
PullToRefresh.destroyAll();
PullToRefresh.init({
distMax: 120,
mainElement: '#main',
// passive: true,
refreshTimeout: 200,
onRefresh: done => {
this.cacheService.autoUpdateConversation(function () {
done();
});
}
});
if (this.messaageService.me) {
this.cacheService.autoUpdateConversation(null);
}
Expand All @@ -57,12 +45,10 @@ export class ConversationsComponent implements OnInit, OnDestroy {
}

public talk(id: number): void {
PullToRefresh.destroyAll();
this.router.navigate(['/talking', id]);
}

public ngOnDestroy(): void {
PullToRefresh.destroyAll();
this.loadingImgURL = null;
}
}
40 changes: 31 additions & 9 deletions src/app/Controllers/create-group.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { Component } from '@angular/core';
import { Router } from '@angular/router';
import Swal from 'sweetalert2';
import { GroupsApiService } from '../Services/GroupsApiService';
import { AiurProtocal } from '../Models/AiurProtocal';
import { AiurCollection } from '../Models/AiurCollection';
import { HeaderService } from '../Services/HeaderService';

@Component({
Expand All @@ -24,9 +22,10 @@ export class CreateGroupComponent {
this.headerService.title = 'Create Group';
this.headerService.returnButton = true;
this.headerService.button = false;
this.headerService.shadow = false;
}

public createGroup(): void {
public createGroup(privateGroup: boolean): void {
if (this.groupName.includes(' ')) {
Swal('Try again', 'Group name can\'t contain whitespaces.', 'error');
return;
Expand All @@ -35,15 +34,38 @@ export class CreateGroupComponent {
Swal('Try again', 'Group name length must between three and twenty five.', 'error');
return;
}
this.groupsApiService.CreateGroup(this.groupName.trim()).subscribe((response) => {
if (privateGroup) {
Swal({
title: 'Enter your group password if you want to create a private group.',
input: 'text',
inputAttributes: {
maxlength: '100'
},
showCancelButton: true
}).then((result) => {
if (result.value) {
this.createPrivateGroup(result.value);
}
});
} else {
Swal({
title: 'Are you sure to create this group?',
type: 'question',
showCancelButton: true
}).then((result) => {
if (result.value) {
this.createPrivateGroup('');
}
});
}
}

private createPrivateGroup(password: string): void {
this.groupsApiService.CreateGroup(this.groupName, password).subscribe((response) => {
if (response.code === 0) {
this.router.navigate(['/talking', response.value]);
} else if (response.code === -7) {
Swal('Can not create group', response.message, 'error');
} else if (response.code === -10) {
Swal(response.message, (response as AiurProtocal as AiurCollection<string>).items[0], 'error');
} else {
Swal('Invalid group', response.message, 'error');
Swal('Can\'t create group', response.message, 'error');
}
});
}
Expand Down
1 change: 1 addition & 0 deletions src/app/Controllers/friendrequests.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class FriendRequestsComponent implements OnInit, OnDestroy {
this.headerService.title = 'Friend Requests';
this.headerService.returnButton = true;
this.headerService.button = false;
this.headerService.shadow = false;
}

public ngOnInit(): void {
Expand Down
15 changes: 1 addition & 14 deletions src/app/Controllers/friends.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Router } from '@angular/router';
import { ContactInfo } from '../Models/ContactInfo';
import * as PullToRefresh from 'pulltorefreshjs';
import { Values } from '../values';
import { MessageService } from '../Services/MessageService';
import { CacheService } from '../Services/CacheService';
Expand All @@ -25,20 +24,9 @@ export class FriendsComponent implements OnInit, OnDestroy {
this.headerService.button = true;
this.headerService.routerLink = '/addfriend';
this.headerService.buttonIcon = 'plus';
this.headerService.shadow = false;
}
public ngOnInit(): void {
PullToRefresh.destroyAll();
PullToRefresh.init({
distMax: 120,
mainElement: '#main',
passive: true,
refreshTimeout: 200,
onRefresh: done => {
this.messageService.updateFriends(function () {
done();
});
}
});
this.messageService.updateFriends(null);
}

Expand All @@ -51,6 +39,5 @@ export class FriendsComponent implements OnInit, OnDestroy {
}

public ngOnDestroy(): void {
PullToRefresh.destroyAll();
}
}
13 changes: 10 additions & 3 deletions src/app/Controllers/group.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { MessageService } from '../Services/MessageService';

export class GroupComponent implements OnInit {
public conversation: Conversation;
public groupMumbers: number;
public groupMembers: number;
public loadingImgURL = Values.loadingImgURL;
public muted: boolean;
public muting = false;
Expand All @@ -38,6 +38,7 @@ export class GroupComponent implements OnInit {
this.headerService.title = 'Group Info';
this.headerService.returnButton = true;
this.headerService.button = false;
this.headerService.shadow = false;
}

public ngOnInit(): void {
Expand All @@ -48,7 +49,7 @@ export class GroupComponent implements OnInit {
)
.subscribe(conversation => {
this.conversation = conversation;
this.groupMumbers = conversation.users.length;
this.groupMembers = conversation.users.length;
this.conversation.avatarURL = Values.fileAddress + (<GroupConversation>this.conversation).groupImageKey;
this.conversation.users.forEach(user => {
user.user.avatarURL = Values.fileAddress + user.user.headImgFileKey;
Expand All @@ -68,8 +69,14 @@ export class GroupComponent implements OnInit {
}

public leaveGroup(groupName: string): void {
let alertTitle = '';
if (this.groupMembers === 1) {
alertTitle = 'This group will be deleted, are you sure?';
} else {
alertTitle = 'Are you sure to leave this group?';
}
Swal({
title: 'Are you sure to leave this group?',
title: alertTitle,
type: 'warning',
showCancelButton: true
}).then((willDelete) => {
Expand Down
25 changes: 23 additions & 2 deletions src/app/Controllers/join-group.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export class JoinGroupComponent implements OnInit {
this.headerService.title = 'Join Group';
this.headerService.returnButton = true;
this.headerService.button = false;
this.headerService.shadow = false;
}

public ngOnInit(): void {
Expand Down Expand Up @@ -74,8 +75,28 @@ export class JoinGroupComponent implements OnInit {
}
}

public joinGroup(groupName: string) {
this.groupsApiService.JoinGroup(groupName).subscribe((response) => {
public joinGroup(groupName: string, privateGroup: boolean) {
if (privateGroup) {
Swal({
title: 'Enter group password.',
input: 'text',
inputAttributes: {
maxlength: '100'
},
showCancelButton: true,
confirmButtonText: 'Join'
}).then((result) => {
if (result.value) {
this.joinGroupWithPassword(groupName, result.value);
}
});
} else {
this.joinGroupWithPassword(groupName, '');
}
}

private joinGroupWithPassword(groupName: string, password: string) {
this.groupsApiService.JoinGroup(groupName, password).subscribe((response) => {
if (response.code === 0) {
this.router.navigate(['/']);
} else {
Expand Down
1 change: 1 addition & 0 deletions src/app/Controllers/settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class SettingsComponent {
this.headerService.title = 'Me';
this.headerService.returnButton = false;
this.headerService.button = false;
this.headerService.shadow = false;
}

public GetMe(): KahlaUser {
Expand Down
Loading

0 comments on commit 12f7f82

Please sign in to comment.