Skip to content

Commit

Permalink
Bug fixes, some improvements.
Browse files Browse the repository at this point in the history
refs #76, refs #61, refs #65, refs #73, refs #56, refs #79, refs #82,
refs #78, refs #22
  • Loading branch information
inafact committed Apr 20, 2019
1 parent c964bb4 commit bbce97d
Show file tree
Hide file tree
Showing 60 changed files with 436 additions and 245 deletions.
1 change: 1 addition & 0 deletions App_Resources/Android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:usesCleartextTraffic="true">

<activity
Expand Down
Binary file modified App_Resources/Android/src/main/res/drawable-hdpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified App_Resources/Android/src/main/res/drawable-hdpi/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified App_Resources/Android/src/main/res/drawable-ldpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified App_Resources/Android/src/main/res/drawable-ldpi/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified App_Resources/Android/src/main/res/drawable-mdpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified App_Resources/Android/src/main/res/drawable-mdpi/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified App_Resources/Android/src/main/res/drawable-xhdpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified App_Resources/Android/src/main/res/drawable-xhdpi/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified App_Resources/Android/src/main/res/drawable-xxhdpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified App_Resources/Android/src/main/res/drawable-xxhdpi/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified App_Resources/Android/src/main/res/drawable-xxxhdpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified App_Resources/Android/src/main/res/drawable-xxxhdpi/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 0 additions & 11 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,10 @@ export class AppComponent {
}).then(
(args) => {
console.log(`firebase init done ${args}`);

},
error => {
console.log(`firebase.init error: ${error}`);
}
);

// firebase.getCurrentPushToken().then((token: string) => {
// console.log(`Current push token: ${token}`);
// this.userService.setNotificationToken(token);
// });

}

get isLoggedIn(): boolean {
return this.userService.isLoggedIn;
}
}
17 changes: 9 additions & 8 deletions src/app/home/home.component.tns.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<AbsoluteLayout width="100%" height="100%">
<GridLayout #homepageRoot rows="*" width="100%" height="100%">
<AbsoluteLayout width="100%" height="100%" visibility="{{ autologin ? 'collapsed' : 'visible' }}">
<GridLayout #homepageRoot rows="*" width="100%" height="100%" visibility="{{ autologin ? 'collapsed' : 'visible' }}">

<StackLayout #lottieViewAnchor
width="100%" height="0" verticalAlignment="center" horizontalAlignment="center" class="bg-clear"></StackLayout>
width="100%" height="0" verticalAlignment="center" horizontalAlignment="center"></StackLayout>

<LottieView #lottieView
style="{{ 'margin-top: ' + safeAreaSpan }}"
[width]="ltCalcWidth"
[height]="ltCalcWidth"
[src]="srcData" [loop]="true" [autoPlay]="true"></LottieView>
<!-- <LottieView #lottieView
style="{{ 'margin-top: ' + safeAreaSpan }}"
[width]="ltCalcWidth"
[height]="ltCalcWidth"
[src]="srcData" [loop]="true" [autoPlay]="true"></LottieView> -->

<DockLayout *ngIf="!autologin; else elseBlock"
stretchLasthChild="true" class="bg-theme-secondary">
Expand Down
52 changes: 19 additions & 33 deletions src/app/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
} from '@angular/core';
import { Router, NavigationEnd } from '@angular/router';

import { interval, Subscription } from 'rxjs';
import { skipWhile, delay } from 'rxjs/operators';
import { interval, Subscription, fromEvent } from 'rxjs';
import { skipWhile, delay, take } from 'rxjs/operators';

import { RouterExtensions } from 'nativescript-angular/router';
import { Page } from 'tns-core-modules/ui/page';
Expand Down Expand Up @@ -34,7 +34,6 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit {
safeAreaSpan: number = 12;
@ViewChild('homepageRoot') hRoot: ElementRef;
@ViewChild('lottieViewAnchor') ltAnchor: ElementRef;
@ViewChild('lottieView') lt: ElementRef;

isProd: boolean = environment.production;
useApiBase: string = environment.apiBaseURL;
Expand All @@ -59,46 +58,40 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit {
}
}
});

this.autologin = this.userService.restoreble;
}

ngOnInit() {
this.autologin = this.userService.restoreble;

if (this.userService.restoreble) {
this.userService.restore().pipe(delay(600)).subscribe(_ => {
this.userService.restore().subscribe(_ => {
const cl = this.userService.getCommunities();
this.routerExt.navigate([(cl && cl.length > 0) ? 'user' : 'newuser'], {
clearHistory: true,
transition: { name: 'fade', duration: 300 }
animated: false,
// transition: { name: 'fade', duration: 150 }
})
}, (err: any) => {
console.error(err);
this.userService.logout(false).subscribe(_ => this.routerExt.navigate(['signin']));
});
}
}

// TODO:
const sb = interval(30).pipe(skipWhile(() => {
return this.ltAnchor.nativeElement.getMeasuredWidth() < 1;
})).subscribe(() => {
const lCW = this.ltAnchor.nativeElement.getMeasuredWidth() / screen.mainScreen.scale;

if (isIOS) {
if (application.ios.window.safeAreaInsets) {
this.safeAreaSpan = (<number>application.ios.window.safeAreaInsets.top) * -1;
console.log('--> ios safeAreaSpan?', this.safeAreaSpan);
}
}

if (lCW < 321) {
this.ltCalcWidth = 64.853 * (320 / lCW);
} else {
this.ltCalcWidth = 76 * (375 / lCW);
}
ngAfterViewInit() {
fromEvent(this.hRoot.nativeElement, 'loaded').pipe(
take(1), delay(1)
).subscribe(_ => {
// if (isIOS) {
// if (application.ios.window.safeAreaInsets) {
// this.safeAreaSpan = (<number>application.ios.window.safeAreaInsets.top) * -1;
// }
// }

//
const aH = this.hRoot.nativeElement.getMeasuredHeight() / screen.mainScreen.scale;
const sc: number = 1 / screen.mainScreen.scale;

if (isIOS) {
let safeAreaSpan: number = 0;
if (application.ios.window.safeAreaInsets) {
Expand All @@ -108,14 +101,7 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit {
} else {
this.trayService.trayPosition = aH;
}
//

sb.unsubscribe();
});
// --
}

ngAfterViewInit() {
}

ngOnDestroy() {
Expand All @@ -132,7 +118,7 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit {

// --
gotoDemo () {
this.routerExt.navigate(['demo'])
// this.routerExt.navigate(['demo'])
}
// ~~
}
2 changes: 2 additions & 0 deletions src/app/shared/snackbar-like/snackbar-like.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ export class SnackbarLikeComponent implements OnInit, OnDestroy, AfterViewInit {
this.doneMessage = 'すでに使用されているメールアドレスです';
} else if (data.error.key == 'usernameTaken' || data.error.key == 'error.usernameTaken') {
this.doneMessage = 'すでに使用されているユーザー名です';
} else if (data.error.key == 'error.beneficiaryIsNotCommunityMember') {
this.doneMessage = '送信先がコミュニティに所属していません';
} else {
this.doneMessage = 'アプリケーションエラー';
}
Expand Down
76 changes: 32 additions & 44 deletions src/app/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export class UserService {
private updateRequestSource = new Subject<string>();
updateRequest$ = this.updateRequestSource.asObservable();

// TODO: move int userpage/community-validator.servie
draftCommunityIds: number[] = [];
draftCommunities: any[] = [];

Expand Down Expand Up @@ -137,12 +138,6 @@ export class UserService {
tap((data: unknown) => {
console.log('standard logged in', data);
this.parseUser(<User>data, true);

// if (this._pushNotificationToken.length > 0) {
// this.http.post(`${this.apiUrl}users/${this.user.id}/mobile-device`, {
// pushNotificationToken: this._pushNotificationToken
// }).subscribe(_ => console.log('token is set -> ', this._pushNotificationToken));
// }
})
);
}
Expand All @@ -154,16 +149,11 @@ export class UserService {
restore(): Observable<any> {
this.loginData.username = this._sStorage.getSync({ key: 'username' });
this.loginData.password = this._sStorage.getSync({ key: 'password' });

return this.http.post(`${this.apiUrl}login`, this.loginData).pipe(
tap((data: unknown) => {
console.log('restore logged in', data);
this.parseUser(<User>data, true);

// if (this._pushNotificationToken.length > 0) {
// this.http.post(`${this.apiUrl}users/${this.user.id}/mobile-device`, {
// pushNotificationToken: this._pushNotificationToken
// }).subscribe(_ => console.log('token is set -> ', this._pushNotificationToken));
// }
})
);
}
Expand Down Expand Up @@ -198,10 +188,6 @@ export class UserService {
}

createAccount(data): Observable<any> {
// return zip(
// from(this._sStorage.removeAll()),
// this.http.post(`${this.apiUrl}create-account`, data)
// );
return this.http.post(`${this.apiUrl}create-account`, data)
}

Expand Down Expand Up @@ -285,31 +271,35 @@ export class UserService {
}

searchUsers(targetCommunity?:number, query?:string): any {
// TODO: performance, error handling, etc
// const t: number = targetCommunity || this._currentCommunityId;
// const allowChar: string = 'abcdefghijklnmopqrstuvwxyzABCDEFGHIJKLNMOPQRSTUVWXYZ0123456789_';
// let q: string = query ? `&q=${query}` : '';
// if (q == '') {
// const ob: Observable<any>[] = [];
// for (let i = 0; i < allowChar.length; i++) {
// ob.push(this.http.get(`${this.apiUrl}users?communityId=${t}&q=${allowChar[i]}`));
// }
// return forkJoin(...ob).pipe(mergeAll());
// } else {
// return this.http.get(`${this.apiUrl}users?communityId=${t}${q}`);
// }

const t: number = targetCommunity || this._currentCommunityId;
const allowChar: string = '0123456789aAbBcCdDeEfFgGhHiIjJkKlLnNmMoOpPqQrRsStTuUvVwWxXyYzZ_';

let q: string = query || '';

if (q == '') {
const hParam: string = [
`communityId=${t}`,
`q=`,
// `pagination[page]=0&pagenation[size]=10&pagenation[sort]=ASC`
].join('&');

return this.http.get(`${this.apiUrl}users?${hParam}`).pipe(
map((res: any) => res.userList ? res.userList : res)
);
} else {
const hParams: string[] = [];
for (const c of allowChar) {
let sQuery: string[];

if(q.split(',').length > 1) {
sQuery = q.split(',').map((c) => `q=${c}`);
} else {
sQuery = [`q=${q}`];
}

for (const ql of sQuery) {
hParams.push(
[
`communityId=${t}`,
`q=${c}`,
ql,
// TODO: paging??
// `pagination[page]=0&pagenation[size]=10&pagenation[sort]=ASC`
].join('&')
);
Expand All @@ -322,16 +312,6 @@ export class UserService {
distinct((el: any) => el.id),
toArray()
);
} else {
const hParam: string = [
`communityId=${t}`,
`q=${q}`,
// `pagination[page]=0&pagenation[size]=10&pagenation[sort]=ASC`
].join('&');

return this.http.get(`${this.apiUrl}users?${hParam}`).pipe(
map((res: any) => res.userList ? res.userList : res)
);
}
}

Expand Down Expand Up @@ -551,6 +531,10 @@ export class UserService {
return this.http.post(`${this.apiUrl}message-threads/${id}/group`, data);
}

updateGroupMessageThreadPersonalTitle(id: number, data: any): Observable<any> {
return this.http.post(`${this.apiUrl}message-threads/${id}/title`, data);
}

unsubscribeGroupMessageThread(id: number): Observable<any> {
return this.http.post(`${this.apiUrl}message-threads/${id}/unsubscribe`, null);
}
Expand Down Expand Up @@ -594,6 +578,10 @@ export class UserService {
return ret;
}

getCurrentMessageThread(id: number): Observable<any> {
return this.http.get(`${this.apiUrl}message-threads/${id}`);
}

getMessages(id: number, paging?: any): Observable<any> {
let params = [];
let _paging: any = {
Expand Down
12 changes: 12 additions & 0 deletions src/app/userpage/community-validator.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { TestBed } from '@angular/core/testing';

import { CommunityValidatorService } from './community-validator.service';

describe('CommunityValidatorService', () => {
beforeEach(() => TestBed.configureTestingModule({}));

it('should be created', () => {
const service: CommunityValidatorService = TestBed.get(CommunityValidatorService);
expect(service).toBeTruthy();
});
});
17 changes: 17 additions & 0 deletions src/app/userpage/community-validator.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Injectable } from '@angular/core';
// import { AbstractControl, FormControl, FormGroup, FormBuilder, Validators, ValidatorFn } from '@angular/forms';

import { UserpageModule } from './userpage.module';

@Injectable({
providedIn: UserpageModule
})
export class CommunityValidatorService {

draftCommunityIds: number[] = [];
draftCommunities: any[] = [];

addOnlyMode: boolean = false;

constructor() { }
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<DockLayout #communityList width="100%" height="100%">
<StackLayout dock="top" class="bg-theme-secondary" height="60">
<CustomActionBar *ngIf="mode == 'switch'; else elseBlock"
<CustomActionBar *ngIf="editorContext == 'switch'; else elseBlock"
[title]="title" leftIcon="&#xea02;" rightIcon="{{ selected == draft ? '&#xe9b1;' : '&#xe92b;' }}"
(onCancel)="cancelAction(communityList)"
(onAprove)="switchModeOrSubmitChange()"></CustomActionBar>
<ng-template #elseBlock>
<CustomActionBar [title]="title" leftIcon="&#xe92f;" rightIcon="{{ (mode == 'edit' && draftIsChanged) ? '&#xe92b;' : '' }}"
<CustomActionBar [title]="title" leftIcon="&#xe92f;" rightIcon="{{ (editorContext == 'edit' && draftIsChanged) ? '&#xe92b;' : '' }}"
(onCancel)="cancelAction(communityList)"
(onAprove)="confirmChange()"></CustomActionBar>
</ng-template>
Expand All @@ -14,7 +14,7 @@
<ScrollView class="bg-theme-secondary">
<StackLayout>

<StackLayout *ngIf="mode != 'submit'"
<StackLayout *ngIf="editorContext != 'submit'"
padding="20 20 15">
<SearchboxLike *ngIf="!isSearchMode"
placeholder="名前で絞り込む"
Expand All @@ -40,7 +40,7 @@
<StackLayout col="1" orientation="horizontal" class="p-10">
<Label class="h3" text="{{ item.name }}" virticalAlignment="stretch"></Label>
</StackLayout>
<Label *ngIf="mode == 'switch'; else elseBlock2"
<Label *ngIf="editorContext == 'switch'; else elseBlock2"
col="2" class="h2 p-10 icon"
[class.text-theme]="draft == item.id"
text="{{ draft == item.id ? '&#xe92c;' : '&#xe937;' }}" style="vertical-align:center;"></Label>
Expand Down
Loading

0 comments on commit bbce97d

Please sign in to comment.