Skip to content

Commit

Permalink
Merge pull request #219 from NicolasConstant/develop
Browse files Browse the repository at this point in the history
0.20.0 PR
  • Loading branch information
NicolasConstant authored Feb 21, 2020
2 parents ccbe9bb + 153dc60 commit 993202b
Show file tree
Hide file tree
Showing 25 changed files with 473 additions and 115 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sengi",
"version": "0.19.4",
"version": "0.20.0",
"license": "AGPL-3.0-or-later",
"main": "main-electron.js",
"description": "A multi-account desktop client for Mastodon and Pleroma",
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/create-status/create-status.component.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<form class="status-editor" (ngSubmit)="onSubmit()">
<input [(ngModel)]="title" type="text" class="form-control form-control-sm status-editor__title" name="title"
<input [(ngModel)]="title" type="text" class="form-control form-control-sm status-editor__title" name="title"
autocomplete="off" placeholder="Title, Content Warning (optional)" title="title, content warning (optional)" dir="auto" />

<a class="status-editor__emoji" title="Insert Emoji"
#emojiButton href (click)="openEmojiPicker($event)">
<img class="status-editor__emoji--image" src="/assets/emoji/72x72/1f636.png">
</a>

<textarea #reply [(ngModel)]="status" name="status" class="form-control form-control-sm status-editor__content"
<textarea #reply [(ngModel)]="status" name="status" class="form-control form-control-sm status-editor__content" (paste)="onPaste($event)"
rows="5" required title="content" placeholder="What's in your mind?" (keydown.control.enter)="onCtrlEnter()"
(keydown)="handleKeyDown($event)" (blur)="statusTextEditorLostFocus()" dir="auto">
</textarea>
Expand Down
16 changes: 14 additions & 2 deletions src/app/components/create-status/create-status.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,18 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
this.accountSub.unsubscribe();
}

onPaste(e: any) {
const items = (e.clipboardData || e.originalEvent.clipboardData).items;
let blobs: File[] = [];
for (const item of items) {
if (item.type.indexOf('image') === 0) {
let blob = item.getAsFile();
blobs.push(blob);
}
}
this.handleFileInput(blobs);
}

changePrivacy(value: string): boolean {
this.selectedPrivacy = value;
return false;
Expand All @@ -224,8 +236,8 @@ export class CreateStatusComponent implements OnInit, OnDestroy {

private detectAutosuggestion(status: string) {
if (!this.statusLoaded) return;
if(!status.includes('@') && !status.includes('#')){

if (!status.includes('@') && !status.includes('#')) {
this.autosuggestData = null;
this.hasSuggestions = false;
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
<div class="panel" [class.comrade__background]="isComrade">
<h3 class="panel__title" [class.comrade__text]="isComrade">Add new account</h3>

<h2 class="comrade__title" *ngIf="isComrade">Welcome Comrade!</h2>
<form (ngSubmit)="onSubmit()">
<label [class.comrade__text]="isComrade">Please provide your <span *ngIf="isComrade">comrade</span> account:</label>
<input type="text" class="form-control form-control-sm form-color" [(ngModel)]="mastodonFullHandle" name="mastodonFullHandle" [class.comrade__input]="isComrade"
placeholder="@nickname@mastodon.social" />
<br />
<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>
<div class="panel__content">
<h2 class="comrade__title" *ngIf="isComrade">Welcome Comrade!</h2>
<form (ngSubmit)="onSubmit()">
<label [class.comrade__text]="isComrade">Please provide your <span *ngIf="isComrade">comrade</span>
instance:</label>

<div *ngIf="isComrade" class="comrade__video">
<iframe width="300" height="170" src="https://www.youtube.com/embed/NzBjnoRG7Mo?feature=oembed&autoplay=1&auto_play=1" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<div>
<input type="text" class="form-control form-control-sm form-with-button"
[(ngModel)]="setInstance" name="instance" [class.comrade__input]="isComrade"
placeholder="mastodon.social" />

<button type="submit" class="form-button"
title="add account"
[class.comrade__button]="isComrade">
<span *ngIf="!isLoading">Submit</span>
<app-waiting-animation *ngIf="isLoading" class="waiting-icon"></app-waiting-animation>
</button>

</div>
</form>

<div *ngIf="isComrade" class="comrade__video">
<iframe width="300" height="170"
src="https://www.youtube.com/embed/NzBjnoRG7Mo?feature=oembed&autoplay=1&auto_play=1" frameborder="0"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen></iframe>
</div>

</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,21 +1,74 @@
@import "variables";
@import "mixins";
@import "panel";

$button-size: 70px;

.panel {

padding-left: 0px;
// padding-right: 0px;
background-position: 0 100%;

&__content {
padding-left: 5px;
}
}

.form-color {
background-color: $column-color;
border-color: $button-border-color;
color: #fff;
font-size: $default-font-size;
.form-with-button {
width: calc(100% - #{$button-size});
float: left;

&:focus {
box-shadow: none;
}

font-size: $default-font-size;
height: 29px;
padding: 0 5px 0 5px;

background-color: $status-editor-title-background;
color: $status-editor-color;
border-top-left-radius: 2px;
border-bottom-left-radius: 2px;
border-width: 0;
margin-bottom: 0;

// background-color: $column-color;
// border-color: $button-border-color;
// color: #fff;
// font-size: $default-font-size;
// &:focus {
// box-shadow: none;
// }
// height: 29px;
// padding: 0 5px 0 5px;
}

.waiting-icon {
position: relative;
top:1px;
left: 3px;
}

.form-button {
@include clearButton;
transition: all .2s;
background-color: $status-editor-footer-background;
border-top-right-radius: 2px;
border-bottom-right-radius: 2px;

&:hover {
background-color: lighten($status-editor-footer-background, 20%);
background-color: darken($status-editor-footer-background, 20%);
}

outline: inherit;
&:focus {
background-color: darken($status-editor-footer-background, 20%);
}

width: $button-size;
height: 29px;
padding: 0 5px 0 5px;
}

$comrade_yellow: #ffcc00;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,17 @@ export class AddNewAccountComponent implements OnInit {
private blockList = ['gab.com', 'gab.ai', 'cyzed.com'];
private comradeList = ['juche.town'];

private username: string;
private instance: string;
isComrade: boolean;

isLoading: boolean;

private _mastodonFullHandle: string;
private instance: string;
@Input()
set mastodonFullHandle(value: string) {
this._mastodonFullHandle = value;
set setInstance(value: string) {
this.instance = value;
this.checkComrad();
}
get mastodonFullHandle(): string {
return this._mastodonFullHandle;
get setInstance(): string {
return this.instance;
}

constructor(
Expand All @@ -41,11 +38,7 @@ export class AddNewAccountComponent implements OnInit {
}

checkComrad(): any {
let fullHandle = this.mastodonFullHandle.split('@').filter(x => x != null && x !== '');
this.username = fullHandle[0];
this.instance = fullHandle[1];

if (this.username && this.instance) {
if (this.instance) {
let cleanInstance = this.instance.replace('http://', '').replace('https://', '').toLowerCase();
for (let b of this.comradeList) {
if (cleanInstance == b || cleanInstance.includes(`.${b}`)) {
Expand All @@ -59,12 +52,15 @@ export class AddNewAccountComponent implements OnInit {
}

onSubmit(): boolean {
this.checkBlockList(this.instance);
if(this.isLoading || !this.instance) return false;

this.isLoading = true;

this.isLoading = true;
this.checkBlockList(this.instance);

this.checkAndCreateApplication(this.instance)
.then((appData: AppData) => {
this.redirectToInstanceAuthPage(this.username, this.instance, appData);
this.redirectToInstanceAuthPage(this.instance, appData);
})
.then(x => {
setTimeout(() => {
Expand Down Expand Up @@ -137,8 +133,8 @@ export class AddNewAccountComponent implements OnInit {
return snapshot.apps;
}

private redirectToInstanceAuthPage(username: string, instance: string, app: AppData) {
const appDataTemp = new CurrentAuthProcess(username, instance);
private redirectToInstanceAuthPage(instance: string, app: AppData) {
const appDataTemp = new CurrentAuthProcess(instance);
localStorage.setItem('tempAuth', JSON.stringify(appDataTemp));

let instanceUrl = this.authService.getInstanceLoginUrl(instance, app.client_id, app.redirect_uri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export class FavoritesComponent implements OnInit {
isThread = false;
hasContentWarnings = false;

bufferStream: Status[] = []; //html compatibility only

@Output() browseAccountEvent = new EventEmitter<string>();
@Output() browseHashtagEvent = new EventEmitter<string>();
@Output() browseThreadEvent = new EventEmitter<OpenThreadEvent>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export class MentionsComponent implements OnInit, OnDestroy {
isThread = false;
hasContentWarnings = false;

bufferStream: Status[] = []; //html compatibility only

@Output() browseAccountEvent = new EventEmitter<string>();
@Output() browseHashtagEvent = new EventEmitter<string>();
@Output() browseThreadEvent = new EventEmitter<OpenThreadEvent>();
Expand Down
Loading

0 comments on commit 993202b

Please sign in to comment.