mirror of
https://github.com/NicolasConstant/sengi
synced 2025-02-02 11:36:54 +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 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);
|
||||
}
|
||||
@ -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));
|
||||
}
|
||||
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
@ -85,6 +85,9 @@
|
||||
<div class="status__labels--label status__labels--remote" title="this status isn't federated with this instance" *ngIf="isRemote">
|
||||
remote
|
||||
</div>
|
||||
<div class="status__labels--label status__labels--edited" title="this status was edited" *ngIf="statusWrapper.status.edited_at">
|
||||
edited
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -105,6 +105,17 @@
|
||||
background-color: rgb(33, 69, 136);
|
||||
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 {
|
||||
display: inline-block;
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Component, OnInit, Input, Output, EventEmitter, ViewChild, ElementRef } from "@angular/core";
|
||||
import { faStar, faRetweet, faList, faThumbtack } from "@fortawesome/free-solid-svg-icons";
|
||||
import { Subscription } from "rxjs";
|
||||
|
||||
import { Status, Account } from "../../../services/models/mastodon.interfaces";
|
||||
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 { EmojiConverter, EmojiTypeEnum } from '../../../tools/emoji.tools';
|
||||
import { ContentWarningPolicyEnum } from '../../../states/settings.state';
|
||||
import { stat } from 'fs';
|
||||
import { StatusesStateService, StatusState } from "../../../services/statuses-state.service";
|
||||
|
||||
|
||||
@Component({
|
||||
selector: "app-status",
|
||||
@ -56,6 +58,8 @@ export class StatusComponent implements OnInit {
|
||||
private _statusWrapper: StatusWrapper;
|
||||
status: Status;
|
||||
|
||||
private statusesStateServiceSub: Subscription;
|
||||
|
||||
@Input('statusWrapper')
|
||||
set statusWrapper(value: StatusWrapper) {
|
||||
this._statusWrapper = value;
|
||||
@ -97,9 +101,19 @@ export class StatusComponent implements OnInit {
|
||||
|
||||
constructor(
|
||||
public elem: ElementRef,
|
||||
private readonly toolsService: ToolsService) { }
|
||||
private readonly toolsService: ToolsService,
|
||||
private readonly statusesStateService: StatusesStateService) { }
|
||||
|
||||
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 {
|
||||
|
@ -172,6 +172,7 @@ export interface Status {
|
||||
reblog: Status;
|
||||
content: string;
|
||||
created_at: string;
|
||||
edited_at: string;
|
||||
reblogs_count: number;
|
||||
replies_count: number;
|
||||
favourites_count: string;
|
||||
|
@ -31,7 +31,7 @@ export class StatusesStateService {
|
||||
this.cachedStatusStates[statusId] = {};
|
||||
|
||||
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 {
|
||||
this.cachedStatusStates[statusId][accountId].isFavorited = isFavorited;
|
||||
}
|
||||
@ -44,7 +44,7 @@ export class StatusesStateService {
|
||||
this.cachedStatusStates[statusId] = {};
|
||||
|
||||
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 {
|
||||
this.cachedStatusStates[statusId][accountId].isRebloged = isRebloged;
|
||||
}
|
||||
@ -57,7 +57,7 @@ export class StatusesStateService {
|
||||
this.cachedStatusStates[statusId] = {};
|
||||
|
||||
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 {
|
||||
this.cachedStatusStates[statusId][accountId].isBookmarked = isBookmarked;
|
||||
}
|
||||
@ -65,6 +65,21 @@ export class StatusesStateService {
|
||||
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) {
|
||||
if (replyingToStatus) {
|
||||
this.cachedStatusText[replyingToStatus.status.uri] = data;
|
||||
@ -101,6 +116,9 @@ export class StatusState {
|
||||
public accountId: string,
|
||||
public isFavorited: 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