Skip to content

Commit

Permalink
Merge pull request #160 from NicolasConstant/develop
Browse files Browse the repository at this point in the history
0.16.0 Release PR
  • Loading branch information
NicolasConstant authored Sep 7, 2019
2 parents 5cd5539 + 2d9b48d commit c69ff3d
Show file tree
Hide file tree
Showing 66 changed files with 1,236 additions and 138 deletions.
7 changes: 6 additions & 1 deletion package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sengi",
"version": "0.15.0",
"version": "0.16.0",
"license": "AGPL-3.0-or-later",
"main": "main-electron.js",
"description": "A multi-account desktop client for Mastodon and Pleroma",
Expand Down Expand Up @@ -48,6 +48,7 @@
"bootstrap": "^4.1.3",
"core-js": "^2.5.4",
"emojione": "~4.5.0",
"ng-pick-datetime": "^7.0.0",
"ngx-contextmenu": "^5.2.0",
"rxjs": "^6.4.0",
"tslib": "^1.9.0",
Expand Down
17 changes: 16 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BrowserModule } from "@angular/platform-browser";
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule } from "@angular/forms";
import { HttpModule } from "@angular/http";
import { HttpClientModule } from '@angular/common/http';
Expand All @@ -14,6 +15,7 @@ import { OverlayModule } from '@angular/cdk/overlay';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { ContextMenuModule } from 'ngx-contextmenu';
import { PickerModule } from '@ctrl/ngx-emoji-mart';
import { OwlDateTimeModule, OwlNativeDateTimeModule } from 'ng-pick-datetime';

import { AppComponent } from "./app.component";
import { LeftSideBarComponent } from "./components/left-side-bar/left-side-bar.component";
Expand Down Expand Up @@ -68,6 +70,11 @@ import { TimeLeftPipe } from './pipes/time-left.pipe';
import { AutosuggestComponent } from './components/create-status/autosuggest/autosuggest.component';
import { EmojiPickerComponent } from './components/create-status/emoji-picker/emoji-picker.component';
import { StatusUserContextMenuComponent } from './components/stream/status/action-bar/status-user-context-menu/status-user-context-menu.component';
import { StatusSchedulerComponent } from './components/create-status/status-scheduler/status-scheduler.component';
import { PollEditorComponent } from './components/create-status/poll-editor/poll-editor.component';
import { PollEntryComponent } from './components/create-status/poll-editor/poll-entry/poll-entry.component';
import { ScheduledStatusesComponent } from './components/floating-column/scheduled-statuses/scheduled-statuses.component';
import { ScheduledStatusComponent } from './components/floating-column/scheduled-statuses/scheduled-status/scheduled-status.component';


const routes: Routes = [
Expand Down Expand Up @@ -122,18 +129,26 @@ const routes: Routes = [
TimeLeftPipe,
AutosuggestComponent,
EmojiPickerComponent,
StatusUserContextMenuComponent
StatusUserContextMenuComponent,
StatusSchedulerComponent,
PollEditorComponent,
PollEntryComponent,
ScheduledStatusesComponent,
ScheduledStatusComponent
],
entryComponents: [
EmojiPickerComponent
],
imports: [
FontAwesomeModule,
BrowserModule,
BrowserAnimationsModule,
HttpModule,
HttpClientModule,
FormsModule,
PickerModule,
OwlDateTimeModule,
OwlNativeDateTimeModule,
OverlayModule,
RouterModule.forRoot(routes),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,22 @@ export class AutosuggestComponent implements OnInit, OnDestroy {

if (isAccount) {
for (let account of results.accounts) {
if (account.acct != this.lastPatternUsed) {
//if (account.acct != this.lastPatternUsed) {
this.accounts.push(new SelectableAccount(account));
this.accounts[0].selected = true;
if (this.accounts.length > 7) return;
}
//}
}
}
else {
for (let hashtag of results.hashtags) {
if (hashtag.includes(this.lastPatternUsed) && hashtag !== this.lastPatternUsed) {
//if (hashtag !== this.lastPatternUsed) {
//if (hashtag.includes(this.lastPatternUsed.toLocaleLowerCase()) && hashtag !== this.lastPatternUsed) {
//if (hashtag.includes(this.lastPatternUsed) && hashtag !== this.lastPatternUsed) {
this.hashtags.push(new SelectableHashtag(hashtag));
this.hashtags[0].selected = true;
if (this.hashtags.length > 7) return;
}
//}
}
}
})
Expand All @@ -98,7 +100,7 @@ export class AutosuggestComponent implements OnInit, OnDestroy {
}
})
.catch(err => {
this.notificationService.notifyHttpError(err);
this.notificationService.notifyHttpError(err, selectedAccount);
});
}

Expand Down
18 changes: 16 additions & 2 deletions src/app/components/create-status/create-status.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,19 @@
(suggestionSelectedEvent)="suggestionSelected($event)" (hasSuggestionsEvent)="suggestionsChanged($event)">
</app-autosuggest>

<app-poll-editor *ngIf="pollIsActive"></app-poll-editor>

<app-status-scheduler class="scheduler" *ngIf="scheduleIsActive"></app-status-scheduler>

<div class="status-editor__footer" #footer>
<button type="submit" title="reply" class="status-editor__footer--send-button" *ngIf="statusReplyingToWrapper">
<span *ngIf="!isSending">REPLY!</span>
<span *ngIf="!isSending && !scheduleIsActive">REPLY!</span>
<span *ngIf="!isSending && scheduleIsActive">PLAN!</span>
<app-waiting-animation class="waiting-icon" *ngIf="isSending"></app-waiting-animation>
</button>
<button type="submit" title="post" class="status-editor__footer--send-button" *ngIf="!statusReplyingToWrapper">
<span *ngIf="!isSending">POST!</span>
<span *ngIf="!isSending && !scheduleIsActive">POST!</span>
<span *ngIf="!isSending && scheduleIsActive">PLAN!</span>
<app-waiting-animation class="waiting-icon" *ngIf="isSending"></app-waiting-animation>
</button>
<div class="status-editor__footer__counter">
Expand All @@ -47,6 +53,14 @@
<fa-icon [icon]="faLock" *ngIf="selectedPrivacy === 'Follows-only'"></fa-icon>
<fa-icon [icon]="faEnvelope" *ngIf="selectedPrivacy === 'DM'"></fa-icon>
</a>

<a href class="status-editor__footer--link status-editor__footer--add-poll" title="add poll" (click)="addPoll()">
<fa-icon [icon]="faPollH"></fa-icon>
</a>

<a href class="status-editor__footer--link" title="schedule" (click)="schedule()">
<fa-icon [icon]="faClock"></fa-icon>
</a>
</div>

<context-menu #contextMenu>
Expand Down
14 changes: 11 additions & 3 deletions src/app/components/create-status/create-status.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ $counter-width: 90px;
margin: 2px 0 0 5px;
}

&--add-poll {
font-size: 16px;
margin: 0 0 0 5px;
position: relative;
top: 0px;
}

&--send-button {
@include clearButton;
transition: all .2s;
Expand Down Expand Up @@ -183,11 +190,12 @@ $counter-width: 90px;
}

.emojipicker {

font-size: $default-font-size !important;
}



.scheduler {
display: block;
margin: 0 5px;
}

@import '~@angular/cdk/overlay-prebuilt.css';
Expand Down
63 changes: 51 additions & 12 deletions src/app/components/create-status/create-status.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { HttpErrorResponse } from '@angular/common/http';
import { Store } from '@ngxs/store';
import { Subscription, Observable } from 'rxjs';
import { UP_ARROW, DOWN_ARROW, ENTER, ESCAPE } from '@angular/cdk/keycodes';
import { faPaperclip, faGlobe, faGlobeAmericas, faLock, faLockOpen, faEnvelope } from "@fortawesome/free-solid-svg-icons";
import { faWindowClose as faWindowCloseRegular } from "@fortawesome/free-regular-svg-icons";
import { faPaperclip, faGlobe, faGlobeAmericas, faLock, faLockOpen, faEnvelope, faPollH } from "@fortawesome/free-solid-svg-icons";
import { faClock, faWindowClose as faWindowCloseRegular } from "@fortawesome/free-regular-svg-icons";
import { ContextMenuService, ContextMenuComponent } from 'ngx-contextmenu';

import { MastodonService, VisibilityEnum } from '../../services/mastodon.service';
import { MastodonService, VisibilityEnum, PollParameters } from '../../services/mastodon.service';
import { Status, Attachment } from '../../services/models/mastodon.interfaces';
import { ToolsService } from '../../services/tools.service';
import { NotificationService } from '../../services/notification.service';
Expand All @@ -19,6 +19,9 @@ import { AutosuggestSelection, AutosuggestUserActionEnum } from './autosuggest/a
import { Overlay, OverlayConfig, FullscreenOverlayContainer, OverlayRef } from '@angular/cdk/overlay';
import { ComponentPortal, TemplatePortal } from '@angular/cdk/portal';
import { EmojiPickerComponent } from './emoji-picker/emoji-picker.component';
import { PollEditorComponent } from './poll-editor/poll-editor.component';
import { StatusSchedulerComponent } from './status-scheduler/status-scheduler.component';
import { ScheduledStatusService } from '../../services/scheduled-status.service';

@Component({
selector: 'app-create-status',
Expand All @@ -32,6 +35,8 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
faLock = faLock;
faLockOpen = faLockOpen;
faEnvelope = faEnvelope;
faPollH = faPollH;
faClock = faClock;

autoSuggestUserActionsStream = new EventEmitter<AutosuggestUserActionEnum>();

Expand Down Expand Up @@ -89,7 +94,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {

})
.catch(err => {
this.notificationService.notifyHttpError(err);
this.notificationService.notifyHttpError(err, value.provider);
})
.then(() => {
this.isSending = false;
Expand All @@ -113,6 +118,8 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
@ViewChild('fileInput') fileInputElement: ElementRef;
@ViewChild('footer') footerElement: ElementRef;
@ViewChild(ContextMenuComponent) public contextMenu: ContextMenuComponent;
@ViewChild(PollEditorComponent) pollEditor: PollEditorComponent;
@ViewChild(StatusSchedulerComponent) statusScheduler: StatusSchedulerComponent;

private _isDirectMention: boolean;
@Input('isDirectMention')
Expand Down Expand Up @@ -148,6 +155,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
private selectedAccount: AccountInfo;

constructor(
private readonly scheduledStatusService: ScheduledStatusService,
private readonly contextMenuService: ContextMenuService,
private readonly store: Store,
private readonly notificationService: NotificationService,
Expand Down Expand Up @@ -280,7 +288,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
this.countStatusChar(this.status);
})
.catch((err: HttpErrorResponse) => {
this.notificationService.notifyHttpError(err);
this.notificationService.notifyHttpError(err, this.selectedAccount);
});
}

Expand All @@ -296,7 +304,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
this.setVisibility(defaultPrivacy);
})
.catch((err: HttpErrorResponse) => {
this.notificationService.notifyHttpError(err);
this.notificationService.notifyHttpError(err, this.selectedAccount);
});
}

Expand Down Expand Up @@ -432,17 +440,35 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
usableStatus = Promise.resolve(null);
}

let poll: PollParameters = null;
if (this.pollIsActive) {
poll = this.pollEditor.getPollParameters();
}

let scheduledTime = null;
if(this.scheduleIsActive){
scheduledTime = this.statusScheduler.getScheduledDate();
if(!scheduledTime || scheduledTime === '') {
this.isSending = false;
return;
}
}

usableStatus
.then((status: Status) => {
return this.sendStatus(acc, this.status, visibility, this.title, status, mediaAttachments);
return this.sendStatus(acc, this.status, visibility, this.title, status, mediaAttachments, poll, scheduledTime);
})
.then((res: Status) => {
this.title = '';
this.status = '';
this.onClose.emit();

if(this.scheduleIsActive){
this.scheduledStatusService.statusAdded(acc);
}
})
.catch((err: HttpErrorResponse) => {
this.notificationService.notifyHttpError(err);
this.notificationService.notifyHttpError(err, acc);
})
.then(() => {
this.isSending = false;
Expand All @@ -451,7 +477,8 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
return false;
}

private sendStatus(account: AccountInfo, status: string, visibility: VisibilityEnum, title: string, previousStatus: Status, attachments: Attachment[]): Promise<Status> {

private sendStatus(account: AccountInfo, status: string, visibility: VisibilityEnum, title: string, previousStatus: Status, attachments: Attachment[], poll: PollParameters, scheduledAt: string): Promise<Status> {
let parsedStatus = this.parseStatus(status);
let resultPromise = Promise.resolve(previousStatus);

Expand All @@ -465,13 +492,13 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
}

if (i === 0) {
return this.mastodonService.postNewStatus(account, s, visibility, title, inReplyToId, attachments.map(x => x.id))
return this.mastodonService.postNewStatus(account, s, visibility, title, inReplyToId, attachments.map(x => x.id), poll, scheduledAt)
.then((status: Status) => {
this.mediaService.clearMedia();
return status;
});
} else {
return this.mastodonService.postNewStatus(account, s, visibility, title, inReplyToId, []);
return this.mastodonService.postNewStatus(account, s, visibility, title, inReplyToId, [], null, scheduledAt);
}
})
.then((status: Status) => {
Expand Down Expand Up @@ -611,7 +638,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
let scrolling = (this.replyElement.nativeElement.scrollHeight);

if (scrolling > 110) {
const isVisible = this.checkVisible(this.footerElement.nativeElement);
const isVisible = this.checkVisible(this.footerElement.nativeElement);
//this.replyElement.nativeElement.style.height = `0px`;
this.replyElement.nativeElement.style.height = `${this.replyElement.nativeElement.scrollHeight}px`;

Expand Down Expand Up @@ -705,4 +732,16 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
this.overlayRef.dispose();
return false;
}

pollIsActive: boolean;
addPoll(): boolean {
this.pollIsActive = !this.pollIsActive;
return false;
}

scheduleIsActive: boolean;
schedule(): boolean {
this.scheduleIsActive = !this.scheduleIsActive;
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class EmojiPickerComponent implements OnInit {
this.customEmojis = emojis.map(x => this.convertEmoji(x));
})
.catch(err => {
this.notificationService.notifyHttpError(err);
this.notificationService.notifyHttpError(err, currentAccount);
})
.then(() => {
this.loaded = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<div class="poll-editor">
<div class="poll-editor__entries">
<div *ngFor="let e of entries">
<app-poll-entry class="poll-editor__entry" [entry]="e" (removeEvent)="removeElement(e)"
(toogleMultiEvent)="toogleMulti()"></app-poll-entry>
</div>
</div>

<div class="poll-editor__footer">
<select [(ngModel)]="selectedId" class="poll-editor__footer--select-duration">
<option *ngFor="let d of delayChoice" [ngValue]="d.id">{{d.label}}</option>
</select>

<a href (click)="addEntry()" class="poll-editor__footer--add-choice">
<fa-icon [icon]="faPlus"></fa-icon> Add a choice
</a>


</div>
</div>
Loading

0 comments on commit c69ff3d

Please sign in to comment.