Merge pull request #207 from NicolasConstant/develop

0.19.3 PR
This commit is contained in:
Nicolas Constant 2020-01-01 19:28:11 +01:00 committed by GitHub
commit 92fc1d4831
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 8 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "sengi", "name": "sengi",
"version": "0.19.2", "version": "0.19.3",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"main": "main-electron.js", "main": "main-electron.js",
"description": "A multi-account desktop client for Mastodon and Pleroma", "description": "A multi-account desktop client for Mastodon and Pleroma",

View File

@ -7,7 +7,8 @@
<input type="text" class="form-control form-control-sm form-color" [(ngModel)]="mastodonFullHandle" name="mastodonFullHandle" [class.comrade__input]="isComrade" <input type="text" class="form-control form-control-sm form-color" [(ngModel)]="mastodonFullHandle" name="mastodonFullHandle" [class.comrade__input]="isComrade"
placeholder="@nickname@mastodon.social" /> placeholder="@nickname@mastodon.social" />
<br /> <br />
<button type="submit" class="btn btn-success btn-sm" [class.comrade__button]="isComrade">Submit</button> <button *ngIf="!isLoading" type="submit" class="btn btn-success btn-sm" [class.comrade__button]="isComrade">Submit</button>
<app-waiting-animation *ngIf="isLoading" class="waiting-icon"></app-waiting-animation>
</form> </form>
<div *ngIf="isComrade" class="comrade__video"> <div *ngIf="isComrade" class="comrade__video">

View File

@ -20,6 +20,8 @@ export class AddNewAccountComponent implements OnInit {
private instance: string; private instance: string;
isComrade: boolean; isComrade: boolean;
isLoading: boolean;
private _mastodonFullHandle: string; private _mastodonFullHandle: string;
@Input() @Input()
set mastodonFullHandle(value: string) { set mastodonFullHandle(value: string) {
@ -57,17 +59,20 @@ export class AddNewAccountComponent implements OnInit {
} }
onSubmit(): boolean { onSubmit(): boolean {
// let fullHandle = this.mastodonFullHandle.split('@').filter(x => x != null && x !== '');
// const username = fullHandle[0];
// const instance = fullHandle[1];
this.checkBlockList(this.instance); this.checkBlockList(this.instance);
this.isLoading = true;
this.checkAndCreateApplication(this.instance) this.checkAndCreateApplication(this.instance)
.then((appData: AppData) => { .then((appData: AppData) => {
this.redirectToInstanceAuthPage(this.username, this.instance, appData); this.redirectToInstanceAuthPage(this.username, this.instance, appData);
}) })
.then(x => {
setTimeout(() => {
this.isLoading = false;
}, 1000);
})
.catch((err: HttpErrorResponse) => { .catch((err: HttpErrorResponse) => {
this.isLoading = false;
if (err instanceof HttpErrorResponse) { if (err instanceof HttpErrorResponse) {
this.notificationService.notifyHttpError(err, null); this.notificationService.notifyHttpError(err, null);
} else if ((<Error>err).message === 'CORS') { } else if ((<Error>err).message === 'CORS') {
@ -102,14 +107,20 @@ export class AddNewAccountComponent implements OnInit {
return Promise.resolve(instanceApps[0].app); return Promise.resolve(instanceApps[0].app);
} else { } else {
let redirect_uri = this.getLocalHostname(); let redirect_uri = this.getLocalHostname();
if (process && process.versions && typeof((<any>process.versions).electron) === 'string') {
let userAgent = navigator.userAgent.toLowerCase();
console.log(`userAgent ${userAgent}`);
if (userAgent.includes(' electron/')) {
redirect_uri += '/register'; redirect_uri += '/register';
} }
return this.authService.createNewApplication(instance, 'Sengi', redirect_uri, 'read write follow', 'https://nicolasconstant.github.io/sengi/') return this.authService.createNewApplication(instance, 'Sengi', redirect_uri, 'read write follow', 'https://nicolasconstant.github.io/sengi/')
.then((appData: AppData) => { .then((appData: AppData) => {
return this.saveNewApp(instance, appData) return this.saveNewApp(instance, appData)
.then(() => { return appData; }); .then(() => {
return new Promise<AppData>(resolve => setTimeout(resolve, 1000, appData));
});
}) })
.catch((err: HttpErrorResponse) => { .catch((err: HttpErrorResponse) => {
if (err.status === 0) { if (err.status === 0) {