mirror of
https://github.com/NicolasConstant/sengi
synced 2025-02-02 19:46:59 +01:00
added edition notification logic
This commit is contained in:
parent
0ce8be99bd
commit
57f863e2a1
@ -209,7 +209,8 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
|||||||
private readonly instancesInfoService: InstancesInfoService,
|
private readonly instancesInfoService: InstancesInfoService,
|
||||||
private readonly mediaService: MediaService,
|
private readonly mediaService: MediaService,
|
||||||
private readonly overlay: Overlay,
|
private readonly overlay: Overlay,
|
||||||
public viewContainerRef: ViewContainerRef) {
|
public viewContainerRef: ViewContainerRef,
|
||||||
|
private readonly statusesStateService: StatusesStateService) {
|
||||||
|
|
||||||
this.accounts$ = this.store.select(state => state.registeredaccounts.accounts);
|
this.accounts$ = this.store.select(state => state.registeredaccounts.accounts);
|
||||||
}
|
}
|
||||||
@ -679,6 +680,15 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
|||||||
this.notificationService.newStatusPosted(this.statusReplyingToWrapper.status.id, new StatusWrapper(cwPolicy.status, account, cwPolicy.applyCw, cwPolicy.hide));
|
this.notificationService.newStatusPosted(this.statusReplyingToWrapper.status.id, new StatusWrapper(cwPolicy.status, account, cwPolicy.applyCw, cwPolicy.hide));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
})
|
||||||
|
.then((status: Status) => {
|
||||||
|
let cwPolicy = this.toolsService.checkContentWarning(status);
|
||||||
|
let statusWrapper = new StatusWrapper(status, account, cwPolicy.applyCw, cwPolicy.hide);
|
||||||
|
|
||||||
|
//TODO: foreach account
|
||||||
|
this.statusesStateService.statusEditedStatusChanged(status.url, account.id, statusWrapper);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,9 @@
|
|||||||
<div class="status__labels--label status__labels--remote" title="this status isn't federated with this instance" *ngIf="isRemote">
|
<div class="status__labels--label status__labels--remote" title="this status isn't federated with this instance" *ngIf="isRemote">
|
||||||
remote
|
remote
|
||||||
</div>
|
</div>
|
||||||
|
<div class="status__labels--label status__labels--edited" title="this status was edited" *ngIf="statusWrapper.status.edited_at">
|
||||||
|
edited
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@ -105,6 +105,17 @@
|
|||||||
background-color: rgb(33, 69, 136);
|
background-color: rgb(33, 69, 136);
|
||||||
background-color: rgb(38, 77, 148);
|
background-color: rgb(38, 77, 148);
|
||||||
}
|
}
|
||||||
|
&--edited {
|
||||||
|
background-color: rgb(167, 0, 153);
|
||||||
|
background-color: rgb(0, 128, 167);
|
||||||
|
background-color: rgb(65, 65, 71);
|
||||||
|
background-color: rgb(144, 184, 0);
|
||||||
|
background-color: rgb(82, 105, 0);
|
||||||
|
|
||||||
|
background-color: rgb(95, 95, 95);
|
||||||
|
|
||||||
|
// color: black;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
&__name {
|
&__name {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { Component, OnInit, Input, Output, EventEmitter, ViewChild, ElementRef } from "@angular/core";
|
import { Component, OnInit, Input, Output, EventEmitter, ViewChild, ElementRef } from "@angular/core";
|
||||||
import { faStar, faRetweet, faList, faThumbtack } from "@fortawesome/free-solid-svg-icons";
|
import { faStar, faRetweet, faList, faThumbtack } from "@fortawesome/free-solid-svg-icons";
|
||||||
|
import { Subscription } from "rxjs";
|
||||||
|
|
||||||
import { Status, Account } from "../../../services/models/mastodon.interfaces";
|
import { Status, Account } from "../../../services/models/mastodon.interfaces";
|
||||||
import { OpenThreadEvent, ToolsService } from "../../../services/tools.service";
|
import { OpenThreadEvent, ToolsService } from "../../../services/tools.service";
|
||||||
@ -7,7 +8,8 @@ import { ActionBarComponent } from "./action-bar/action-bar.component";
|
|||||||
import { StatusWrapper } from '../../../models/common.model';
|
import { StatusWrapper } from '../../../models/common.model';
|
||||||
import { EmojiConverter, EmojiTypeEnum } from '../../../tools/emoji.tools';
|
import { EmojiConverter, EmojiTypeEnum } from '../../../tools/emoji.tools';
|
||||||
import { ContentWarningPolicyEnum } from '../../../states/settings.state';
|
import { ContentWarningPolicyEnum } from '../../../states/settings.state';
|
||||||
import { stat } from 'fs';
|
import { StatusesStateService, StatusState } from "../../../services/statuses-state.service";
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-status",
|
selector: "app-status",
|
||||||
@ -56,6 +58,8 @@ export class StatusComponent implements OnInit {
|
|||||||
private _statusWrapper: StatusWrapper;
|
private _statusWrapper: StatusWrapper;
|
||||||
status: Status;
|
status: Status;
|
||||||
|
|
||||||
|
private statusesStateServiceSub: Subscription;
|
||||||
|
|
||||||
@Input('statusWrapper')
|
@Input('statusWrapper')
|
||||||
set statusWrapper(value: StatusWrapper) {
|
set statusWrapper(value: StatusWrapper) {
|
||||||
this._statusWrapper = value;
|
this._statusWrapper = value;
|
||||||
@ -97,9 +101,19 @@ export class StatusComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public elem: ElementRef,
|
public elem: ElementRef,
|
||||||
private readonly toolsService: ToolsService) { }
|
private readonly toolsService: ToolsService,
|
||||||
|
private readonly statusesStateService: StatusesStateService) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.statusesStateServiceSub = this.statusesStateService.stateNotification.subscribe(notification => {
|
||||||
|
if(this._statusWrapper.status.url === notification.statusId && notification.isEdited) {
|
||||||
|
this.statusWrapper = notification.editedStatus;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnDestroy(){
|
||||||
|
if(this.statusesStateServiceSub) this.statusesStateServiceSub.unsubscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ensureMentionAreDisplayed(data: string): string {
|
private ensureMentionAreDisplayed(data: string): string {
|
||||||
|
@ -172,6 +172,7 @@ export interface Status {
|
|||||||
reblog: Status;
|
reblog: Status;
|
||||||
content: string;
|
content: string;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
|
edited_at: string;
|
||||||
reblogs_count: number;
|
reblogs_count: number;
|
||||||
replies_count: number;
|
replies_count: number;
|
||||||
favourites_count: string;
|
favourites_count: string;
|
||||||
|
@ -31,7 +31,7 @@ export class StatusesStateService {
|
|||||||
this.cachedStatusStates[statusId] = {};
|
this.cachedStatusStates[statusId] = {};
|
||||||
|
|
||||||
if (!this.cachedStatusStates[statusId][accountId]) {
|
if (!this.cachedStatusStates[statusId][accountId]) {
|
||||||
this.cachedStatusStates[statusId][accountId] = new StatusState(statusId, accountId, isFavorited, null, null);
|
this.cachedStatusStates[statusId][accountId] = new StatusState(statusId, accountId, isFavorited, null, null, null, null, null);
|
||||||
} else {
|
} else {
|
||||||
this.cachedStatusStates[statusId][accountId].isFavorited = isFavorited;
|
this.cachedStatusStates[statusId][accountId].isFavorited = isFavorited;
|
||||||
}
|
}
|
||||||
@ -44,7 +44,7 @@ export class StatusesStateService {
|
|||||||
this.cachedStatusStates[statusId] = {};
|
this.cachedStatusStates[statusId] = {};
|
||||||
|
|
||||||
if (!this.cachedStatusStates[statusId][accountId]) {
|
if (!this.cachedStatusStates[statusId][accountId]) {
|
||||||
this.cachedStatusStates[statusId][accountId] = new StatusState(statusId, accountId, null, isRebloged, null);
|
this.cachedStatusStates[statusId][accountId] = new StatusState(statusId, accountId, null, isRebloged, null, null, null, null);
|
||||||
} else {
|
} else {
|
||||||
this.cachedStatusStates[statusId][accountId].isRebloged = isRebloged;
|
this.cachedStatusStates[statusId][accountId].isRebloged = isRebloged;
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ export class StatusesStateService {
|
|||||||
this.cachedStatusStates[statusId] = {};
|
this.cachedStatusStates[statusId] = {};
|
||||||
|
|
||||||
if (!this.cachedStatusStates[statusId][accountId]) {
|
if (!this.cachedStatusStates[statusId][accountId]) {
|
||||||
this.cachedStatusStates[statusId][accountId] = new StatusState(statusId, accountId, null, null, isBookmarked);
|
this.cachedStatusStates[statusId][accountId] = new StatusState(statusId, accountId, null, null, isBookmarked, null, null, null);
|
||||||
} else {
|
} else {
|
||||||
this.cachedStatusStates[statusId][accountId].isBookmarked = isBookmarked;
|
this.cachedStatusStates[statusId][accountId].isBookmarked = isBookmarked;
|
||||||
}
|
}
|
||||||
@ -65,6 +65,21 @@ export class StatusesStateService {
|
|||||||
this.stateNotification.next(this.cachedStatusStates[statusId][accountId]);
|
this.stateNotification.next(this.cachedStatusStates[statusId][accountId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
statusEditedStatusChanged(statusId: string, accountId: string, editedStatus: StatusWrapper) {
|
||||||
|
if (!this.cachedStatusStates[statusId])
|
||||||
|
this.cachedStatusStates[statusId] = {};
|
||||||
|
|
||||||
|
if (!this.cachedStatusStates[statusId][accountId]) {
|
||||||
|
this.cachedStatusStates[statusId][accountId] = new StatusState(statusId, accountId, null, null, null, true, new Date().toISOString(), editedStatus);
|
||||||
|
} else {
|
||||||
|
this.cachedStatusStates[statusId][accountId].isEdited = true;
|
||||||
|
this.cachedStatusStates[statusId][accountId].editionTime = new Date().toISOString();
|
||||||
|
this.cachedStatusStates[statusId][accountId].editedStatus = editedStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.stateNotification.next(this.cachedStatusStates[statusId][accountId]);
|
||||||
|
}
|
||||||
|
|
||||||
setStatusContent(data: string, replyingToStatus: StatusWrapper) {
|
setStatusContent(data: string, replyingToStatus: StatusWrapper) {
|
||||||
if (replyingToStatus) {
|
if (replyingToStatus) {
|
||||||
this.cachedStatusText[replyingToStatus.status.uri] = data;
|
this.cachedStatusText[replyingToStatus.status.uri] = data;
|
||||||
@ -101,6 +116,9 @@ export class StatusState {
|
|||||||
public accountId: string,
|
public accountId: string,
|
||||||
public isFavorited: boolean,
|
public isFavorited: boolean,
|
||||||
public isRebloged: boolean,
|
public isRebloged: boolean,
|
||||||
public isBookmarked: boolean) {
|
public isBookmarked: boolean,
|
||||||
|
public isEdited: boolean,
|
||||||
|
public editionTime: string,
|
||||||
|
public editedStatus: StatusWrapper) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user