Skip to content

Commit

Permalink
Merge pull request #517 from NicolasConstant/develop
Browse files Browse the repository at this point in the history
1.2.0 PR
  • Loading branch information
NicolasConstant authored Dec 11, 2022
2 parents 78f0f3a + 522c1c0 commit 4599d64
Show file tree
Hide file tree
Showing 28 changed files with 400 additions and 90 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cache:
#- node_modules
environment:
GH_TOKEN:
secure: wRRBU0GXTmTBgZBs2PGSaEJWOflynAyvp3Nc/7e9xmciPfkUCQAXcpOn0jIYmzpb
secure: eXSiJiDFgLi4vixO5GS93lgrqZ+BzQNy7PKPCQCErHjCQD9mWiEtVQQnhvmUq1FPLUc3fNLmOFQu2nIWA9bnkHg5Yw9WiG2m7QSCPRB+xCnvSY6JbLqpzURZp5x5OLj6
matrix:
- nodejs_version: 10.9.0
install:
Expand Down
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": "1.1.6",
"version": "1.2.0",
"license": "AGPL-3.0-or-later",
"main": "main-electron.js",
"description": "A multi-account desktop client for Mastodon and Pleroma",
Expand Down
2 changes: 1 addition & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ const routes: Routes = [
FormsModule,
ReactiveFormsModule,
PickerModule,
OwlDateTimeModule,
OwlDateTimeModule,
OwlNativeDateTimeModule,
OverlayModule,
RouterModule.forRoot(routes),
Expand Down
1 change: 1 addition & 0 deletions src/app/components/common/timeline-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export abstract class TimelineBase extends BrowseBase {
statuses: StatusWrapper[] = [];
bufferStream: Status[] = [];
protected bufferWasCleared: boolean;
numNewItems: number;
streamPositionnedAtTop: boolean = true;
protected isProcessingInfiniteScroll: boolean;

Expand Down
10 changes: 6 additions & 4 deletions src/app/components/create-status/create-status.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@

<div class="status-editor__footer" #footer>
<button type="submit" title="reply" class="status-editor__footer--send-button" *ngIf="statusReplyingToWrapper">
<span *ngIf="!isSending && !scheduleIsActive">REPLY!</span>
<span *ngIf="!isSending && scheduleIsActive">PLAN!</span>
<span *ngIf="!isSending && !scheduleIsActive && !isEditing">REPLY!</span>
<span *ngIf="!isSending && scheduleIsActive && !isEditing">PLAN!</span>
<span *ngIf="!isSending && isEditing">EDIT!</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 && !scheduleIsActive">POST!</span>
<span *ngIf="!isSending && scheduleIsActive">PLAN!</span>
<span *ngIf="!isSending && !scheduleIsActive && !isEditing">POST!</span>
<span *ngIf="!isSending && scheduleIsActive && !isEditing">PLAN!</span>
<span *ngIf="!isSending && isEditing">EDIT!</span>
<app-waiting-animation class="waiting-icon" *ngIf="isSending"></app-waiting-animation>
</button>
<div class="status-editor__footer__counter">
Expand Down
3 changes: 3 additions & 0 deletions src/app/components/create-status/create-status.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ $counter-width: 90px;
}

& span {
position: relative;
top: 1px;

margin: 0;
padding: 0;
}
Expand Down
68 changes: 50 additions & 18 deletions src/app/components/create-status/create-status.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,21 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
return s;
}

@Input('statusToEdit')
set statusToEdit(value: StatusWrapper) {
if (value) {
this.isEditing = true;
this.editingStatusId = value.status.id;
this.redraftedStatus = value;
}
}

@Input('redraftedStatus')
set redraftedStatus(value: StatusWrapper) {
if (value) {
this.isRedrafting = true;
this.statusLoaded = false;

if (value.status && value.status.media_attachments) {
for (const m of value.status.media_attachments) {
this.mediaService.addExistingMedia(new MediaWrapper(m.id, null, m));
Expand Down Expand Up @@ -141,6 +150,8 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
autosuggestData: string = null;
instanceSupportsPoll = true;
instanceSupportsScheduling = true;
isEditing: boolean;
editingStatusId: string;
private statusLoaded: boolean;
private hasSuggestions: boolean;

Expand Down Expand Up @@ -198,7 +209,8 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
private readonly instancesInfoService: InstancesInfoService,
private readonly mediaService: MediaService,
private readonly overlay: Overlay,
public viewContainerRef: ViewContainerRef) {
public viewContainerRef: ViewContainerRef,
private readonly statusesStateService: StatusesStateService) {

this.accounts$ = this.store.select(state => state.registeredaccounts.accounts);
}
Expand Down Expand Up @@ -308,7 +320,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
};

const word = this.getWordByPos(currentSection, caretPosition - offset);
if (!lastCharIsSpace && word && word.length > 0 && (word.startsWith('@') || word.startsWith('#'))) {
if (!lastCharIsSpace && word && word.length > 1 && (word.startsWith('@') || word.startsWith('#'))) {
this.autosuggestData = word;
return;
}
Expand Down Expand Up @@ -436,7 +448,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
}

private setVisibility(defaultPrivacy: VisibilityEnum) {
if(this.selectedPrivacySetByRedraft) return;
if (this.selectedPrivacySetByRedraft) return;

switch (defaultPrivacy) {
case VisibilityEnum.Public:
Expand Down Expand Up @@ -494,14 +506,14 @@ export class CreateStatusComponent implements OnInit, OnDestroy {

private getMentions(status: Status): string[] {
let acct = status.account.acct;
if(!acct.includes('@')) {
if (!acct.includes('@')) {
acct += `@${status.account.url.replace('https://', '').split('/')[0]}`
}

const mentions = [acct];
status.mentions.forEach(m => {
let mentionAcct = m.acct;
if(!mentionAcct.includes('@')){
if (!mentionAcct.includes('@')) {
mentionAcct += `@${m.url.replace('https://', '').split('/')[0]}`;
}
mentions.push(mentionAcct);
Expand Down Expand Up @@ -572,7 +584,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {

usableStatus
.then((status: Status) => {
return this.sendStatus(acc, this.status, visibility, this.title, status, mediaAttachments, poll, scheduledTime);
return this.sendStatus(acc, this.status, visibility, this.title, status, mediaAttachments, poll, scheduledTime, this.editingStatusId);
})
.then((res: Status) => {
this.title = '';
Expand All @@ -599,7 +611,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
return false;
}

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

Expand All @@ -613,13 +625,25 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
}

if (i === 0) {
return this.mastodonService.postNewStatus(account, s, visibility, title, inReplyToId, attachments.map(x => x.id), poll, scheduledAt)
let postPromise: Promise<Status>;

if (this.isEditing) {
postPromise = this.mastodonService.editStatus(account, editingStatusId, s, visibility, title, inReplyToId, attachments.map(x => x.id), poll, scheduledAt);
} else {
postPromise = this.mastodonService.postNewStatus(account, s, visibility, title, inReplyToId, attachments.map(x => x.id), poll, scheduledAt);
}

return postPromise
.then((status: Status) => {
this.mediaService.clearMedia();
return status;
});
} else {
return this.mastodonService.postNewStatus(account, s, visibility, title, inReplyToId, [], null, scheduledAt);
if (this.isEditing) {
return this.mastodonService.editStatus(account, editingStatusId, s, visibility, title, inReplyToId, [], null, scheduledAt);
} else {
return this.mastodonService.postNewStatus(account, s, visibility, title, inReplyToId, [], null, scheduledAt);
}
}
})
.then((status: Status) => {
Expand All @@ -628,6 +652,16 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
this.notificationService.newStatusPosted(this.statusReplyingToWrapper.status.id, new StatusWrapper(cwPolicy.status, account, cwPolicy.applyCw, cwPolicy.hide));
}

return status;
})
.then((status: Status) => {
if (this.isEditing) {
let cwPolicy = this.toolsService.checkContentWarning(status);
let statusWrapper = new StatusWrapper(status, account, cwPolicy.applyCw, cwPolicy.hide);

this.statusesStateService.statusEditedStatusChanged(status.url, account.id, statusWrapper);
}

return status;
});
}
Expand All @@ -636,8 +670,6 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
}

private parseStatus(status: string): string[] {
//console.error(status.toString());

let mentionExtraChars = this.getMentionExtraChars(status);
let urlExtraChar = this.getLinksExtraChars(status);
let trucatedStatus = `${status}`;
Expand All @@ -654,8 +686,8 @@ export class CreateStatusComponent implements OnInit, OnDestroy {

while (trucatedStatus.length > currentMaxCharLength) {
const nextIndex = trucatedStatus.lastIndexOf(' ', maxChars);
if(nextIndex === -1){

if (nextIndex === -1) {
break;
}

Expand Down Expand Up @@ -706,8 +738,8 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
suggestionSelected(selection: AutosuggestSelection) {
if (this.status.includes(selection.pattern)) {
this.status = this.replacePatternWithAutosuggest(this.status, selection.pattern, selection.autosuggest);
let cleanStatus = this.status.replace(/\r?\n/g, ' ');

let cleanStatus = this.status.replace(/\r?\n/g, ' ');
let newCaretPosition = cleanStatus.indexOf(`${selection.autosuggest}`) + selection.autosuggest.length;
if (newCaretPosition > cleanStatus.length) newCaretPosition = cleanStatus.length;

Expand Down Expand Up @@ -756,7 +788,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
w++;
result += `${word}`;

if(w < wordCount || i === nberLines){
if (w < wordCount || i === nberLines) {
result += ' ';
}
});
Expand All @@ -768,7 +800,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
result = result.replace(' ', ' ');

let endRegex = new RegExp(`${autosuggest} $`, 'i');
if(!result.match(endRegex)){
if (!result.match(endRegex)) {
result = result.substring(0, result.length - 1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ <h3 class="panel__title">new message</h3>

<div class=" new-message-body flexcroll">
<app-create-status (onClose)="closeColumn()" [isDirectMention]="isDirectMention"
[replyingUserHandle]="userHandle" [redraftedStatus]="redraftedStatus"></app-create-status>

[replyingUserHandle]="userHandle" [statusToEdit]="statusToEdit" [redraftedStatus]="redraftedStatus"></app-create-status>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class AddNewStatusComponent implements OnInit {
@Input() isDirectMention: boolean;
@Input() userHandle: string;
@Input() redraftedStatus: StatusWrapper;
@Input() statusToEdit: StatusWrapper;

constructor(private readonly navigationService: NavigationService) {
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<div class="floating-column">
<div class="floating-column__inner">
<div class="sliding-column" [class.sliding-column__right-display]="overlayActive">
<app-stream-overlay class="stream-overlay" *ngIf="overlayActive"
<app-stream-overlay class="stream-overlay" *ngIf="overlayActive"
(closeOverlay)="closeOverlay()"
[browseAccountData]="overlayAccountToBrowse"
[browseAccountData]="overlayAccountToBrowse"
[browseHashtagData]="overlayHashtagToBrowse"
[browseThreadData]="overlayThreadToBrowse"></app-stream-overlay>

Expand All @@ -15,15 +15,17 @@
</div>

<app-manage-account *ngIf="openPanel === 'manageAccount'" [account]="userAccountUsed"
(browseAccountEvent)="browseAccount($event)"
(browseAccountEvent)="browseAccount($event)"
(browseHashtagEvent)="browseHashtag($event)"
(browseThreadEvent)="browseThread($event)"></app-manage-account>
<app-add-new-status *ngIf="openPanel === 'createNewStatus'" [isDirectMention]="isDirectMention"
[userHandle]="userHandle" [redraftedStatus]="redraftedStatus"></app-add-new-status>
[userHandle]="userHandle"
[redraftedStatus]="redraftedStatus"
[statusToEdit]="statusToEdit"></app-add-new-status>
<app-add-new-account *ngIf="openPanel === 'addNewAccount'"></app-add-new-account>
<app-search *ngIf="openPanel === 'search'"
<app-search *ngIf="openPanel === 'search'"
(browseAccountEvent)="browseAccount($event)"
(browseHashtagEvent)="browseHashtag($event)"
(browseHashtagEvent)="browseHashtag($event)"
(browseThreadEvent)="browseThread($event)">
</app-search>
<app-settings *ngIf="openPanel === 'settings'"></app-settings>
Expand Down
12 changes: 11 additions & 1 deletion src/app/components/floating-column/floating-column.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class FloatingColumnComponent implements OnInit, OnDestroy {
isDirectMention: boolean;
userHandle: string;
redraftedStatus: StatusWrapper;
statusToEdit: StatusWrapper;

openPanel: string = '';

Expand All @@ -49,12 +50,21 @@ export class FloatingColumnComponent implements OnInit, OnDestroy {
}
break;
case LeftPanelType.CreateNewStatus:
case LeftPanelType.EditStatus:
if (this.openPanel === 'createNewStatus' && !event.userHandle) {
this.closePanel();
} else {
this.isDirectMention = event.action === LeftPanelAction.DM;
this.userHandle = event.userHandle;
this.redraftedStatus = event.status;

if(event.type === LeftPanelType.CreateNewStatus){
this.redraftedStatus = event.status;
this.statusToEdit = null;
} else {
this.redraftedStatus = null;
this.statusToEdit = event.status;
}

this.openPanel = 'createNewStatus';
}
break;
Expand Down
9 changes: 5 additions & 4 deletions src/app/components/stream/hashtag/hashtag.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
<div class="hashtag-header">
<a href (click)="goToTop()" class="hashtag-header__gototop" title="go to top">
<h3 class="hashtag-header__title">#{{hashtagElement.tag}}</h3>

<button *ngIf="isHashtagFollowingAvailable && !isFollowingHashtag" class="btn-custom-secondary hashtag-header__follow-button" (click)="followThisHashtag($event)" title="follow hashtag" [disabled]="followingLoading">follow</button>
<button *ngIf="isHashtagFollowingAvailable && isFollowingHashtag" class="btn-custom-secondary hashtag-header__follow-button" (click)="unfollowThisHashtag($event)" title="unfollow hashtag" [disabled]="unfollowingLoading">unfollow</button>
<button class="btn-custom-secondary hashtag-header__add-column" (click)="addColumn($event)" title="add column to board" [hidden]="columnAdded">add column</button>
</a>
</div>
<app-stream-statuses #appStreamStatuses class="hashtag-stream" *ngIf="hashtagElement"
[streamElement]="hashtagElement"
<app-stream-statuses #appStreamStatuses class="hashtag-stream" *ngIf="hashtagElement"
[streamElement]="hashtagElement"
[goToTop]="goToTopSubject.asObservable()"
[userLocked]="false"
(browseAccountEvent)="browseAccount($event)"
(browseAccountEvent)="browseAccount($event)"
(browseHashtagEvent)="browseHashtag($event)"
(browseThreadEvent)="browseThread($event)"></app-stream-statuses>
</div>
8 changes: 8 additions & 0 deletions src/app/components/stream/hashtag/hashtag.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ $inner-column-size: 320px;
border: 1px solid black;
color: white;
}
&__follow-button {
position: absolute;
top: 7px;
right: 100px;
padding: 0 10px 0 10px;
border: 1px solid black;
color: white;
}
}

.hashtag-stream {
Expand Down
Loading

0 comments on commit 4599d64

Please sign in to comment.