clean up, renaming to be more name generic
This commit is contained in:
parent
1137e7f69e
commit
97015ba0fe
|
@ -27,7 +27,7 @@ import { FloatingColumnComponent } from './components/floating-column/floating-c
|
||||||
import { ColumnsEditorComponent } from './components/floating-column/columns-editor/columns-editor.component';
|
import { ColumnsEditorComponent } from './components/floating-column/columns-editor/columns-editor.component';
|
||||||
import { MessageEditorComponent } from './components/floating-column/message-editor/message-editor.component';
|
import { MessageEditorComponent } from './components/floating-column/message-editor/message-editor.component';
|
||||||
import { StreamsState } from "./states/streams.state";
|
import { StreamsState } from "./states/streams.state";
|
||||||
import { TootComponent } from "./components/stream/toot/toot.component";
|
import { StatusComponent } from "./components/stream/status/status.component";
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: "", redirectTo: "home", pathMatch: "full" },
|
{ path: "", redirectTo: "home", pathMatch: "full" },
|
||||||
|
@ -43,7 +43,7 @@ const routes: Routes = [
|
||||||
StreamsMainDisplayComponent,
|
StreamsMainDisplayComponent,
|
||||||
StreamComponent,
|
StreamComponent,
|
||||||
StreamsSelectionFooterComponent,
|
StreamsSelectionFooterComponent,
|
||||||
TootComponent,
|
StatusComponent,
|
||||||
RegisterNewAccountComponent,
|
RegisterNewAccountComponent,
|
||||||
AccountIconComponent,
|
AccountIconComponent,
|
||||||
FloatingColumnComponent,
|
FloatingColumnComponent,
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<div class="toot">
|
||||||
|
<img class="toot__avatar" src="{{ status.account.avatar }}" />
|
||||||
|
<a href class="toot__profile-link"><span class="toot__fullname" innerHTML="{{status.account.display_name}}"></span> @<span id="toot-username" innerHTML="{{status.account.username}}"></span></a>
|
||||||
|
<div class="toot__content" innerHTML="{{status.content}}"></div>
|
||||||
|
</div>
|
|
@ -1,20 +1,20 @@
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { TootComponent } from './toot.component';
|
import { StatusComponent } from './status.component';
|
||||||
|
|
||||||
describe('TootComponent', () => {
|
describe('StatusComponent', () => {
|
||||||
let component: TootComponent;
|
let component: StatusComponent;
|
||||||
let fixture: ComponentFixture<TootComponent>;
|
let fixture: ComponentFixture<StatusComponent>;
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
declarations: [ TootComponent ]
|
declarations: [ StatusComponent ]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(TootComponent);
|
fixture = TestBed.createComponent(StatusComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
|
@ -0,0 +1,18 @@
|
||||||
|
import { Component, OnInit, Input } from "@angular/core";
|
||||||
|
import { Status } from "../../../services/models/mastodon.interfaces";
|
||||||
|
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: "app-status",
|
||||||
|
templateUrl: "./status.component.html",
|
||||||
|
styleUrls: ["./status.component.scss"]
|
||||||
|
})
|
||||||
|
export class StatusComponent implements OnInit {
|
||||||
|
@Input() status: Status;
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,8 +3,8 @@
|
||||||
<a href title="return to top" (click)="goToTop()"><h1>{{ streamElement.name.toUpperCase() }}</h1></a>
|
<a href title="return to top" (click)="goToTop()"><h1>{{ streamElement.name.toUpperCase() }}</h1></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="stream-toots" data-simplebar>
|
<div class="stream-toots" data-simplebar>
|
||||||
<div *ngFor="let toot of statuses">
|
<div *ngFor="let status of statuses">
|
||||||
<app-toot [toot]="toot"></app-toot>
|
<app-status [status]="status"></app-status>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -14,12 +14,12 @@ import { Status } from "../../services/models/mastodon.interfaces";
|
||||||
styleUrls: ["./stream.component.scss"]
|
styleUrls: ["./stream.component.scss"]
|
||||||
})
|
})
|
||||||
export class StreamComponent implements OnInit {
|
export class StreamComponent implements OnInit {
|
||||||
|
private _streamElement: StreamElement;
|
||||||
private apiRoutes = new ApiRoutes();
|
private apiRoutes = new ApiRoutes();
|
||||||
private account: AccountInfo;
|
private account: AccountInfo;
|
||||||
private websocketStreaming: StreamingWrapper;
|
private websocketStreaming: StreamingWrapper;
|
||||||
private type: StreamTypeEnum;
|
|
||||||
statuses: TootWrapper[] = [];
|
statuses: Status[] = [];
|
||||||
private _streamElement: StreamElement;
|
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
set streamElement(streamElement: StreamElement) {
|
set streamElement(streamElement: StreamElement) {
|
||||||
|
@ -29,7 +29,7 @@ export class StreamComponent implements OnInit {
|
||||||
const user = splitedUserName[0];
|
const user = splitedUserName[0];
|
||||||
const instance = splitedUserName[1];
|
const instance = splitedUserName[1];
|
||||||
this.account = this.getRegisteredAccounts().find(x => x.username == user && x.instance == instance);
|
this.account = this.getRegisteredAccounts().find(x => x.username == user && x.instance == instance);
|
||||||
this.type = streamElement.type;
|
// this.type = streamElement.type;
|
||||||
|
|
||||||
this.retrieveToots(); //TODO change this for WebSockets
|
this.retrieveToots(); //TODO change this for WebSockets
|
||||||
this.launchWebsocket();
|
this.launchWebsocket();
|
||||||
|
@ -39,15 +39,12 @@ export class StreamComponent implements OnInit {
|
||||||
return this._streamElement;
|
return this._streamElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
toots: TootWrapper[] = [];
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly store: Store,
|
private readonly store: Store,
|
||||||
private readonly streamingService: StreamingService,
|
private readonly streamingService: StreamingService,
|
||||||
private readonly httpClient: HttpClient) {
|
private readonly httpClient: HttpClient) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +53,7 @@ export class StreamComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
private getTimelineRoute(): string {
|
private getTimelineRoute(): string {
|
||||||
switch (this.type) {
|
switch (this._streamElement.type) {
|
||||||
case StreamTypeEnum.personnal:
|
case StreamTypeEnum.personnal:
|
||||||
return this.apiRoutes.getHomeTimeline;
|
return this.apiRoutes.getHomeTimeline;
|
||||||
case StreamTypeEnum.local:
|
case StreamTypeEnum.local:
|
||||||
|
@ -78,11 +75,7 @@ export class StreamComponent implements OnInit {
|
||||||
const headers = new HttpHeaders({ 'Authorization': `Bearer ${this.account.token.access_token}` });
|
const headers = new HttpHeaders({ 'Authorization': `Bearer ${this.account.token.access_token}` });
|
||||||
this.httpClient.get<Status[]>(route, { headers: headers }).toPromise()
|
this.httpClient.get<Status[]>(route, { headers: headers }).toPromise()
|
||||||
.then((results: Status[]) => {
|
.then((results: Status[]) => {
|
||||||
var statuses = results.map((status: Status) => {
|
for (const s of results) {
|
||||||
return new TootWrapper(status);
|
|
||||||
});
|
|
||||||
|
|
||||||
for (const s of statuses) {
|
|
||||||
this.statuses.push(s);
|
this.statuses.push(s);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -91,7 +84,7 @@ export class StreamComponent implements OnInit {
|
||||||
private launchWebsocket(): void {
|
private launchWebsocket(): void {
|
||||||
//Web socket
|
//Web socket
|
||||||
let streamRequest: string;
|
let streamRequest: string;
|
||||||
switch (this.type) {
|
switch (this._streamElement.type) {
|
||||||
case StreamTypeEnum.global:
|
case StreamTypeEnum.global:
|
||||||
streamRequest = 'public';
|
streamRequest = 'public';
|
||||||
break;
|
break;
|
||||||
|
@ -107,25 +100,9 @@ export class StreamComponent implements OnInit {
|
||||||
this.websocketStreaming.statusUpdateSubjet.subscribe((update: StatusUpdate) => {
|
this.websocketStreaming.statusUpdateSubjet.subscribe((update: StatusUpdate) => {
|
||||||
if (update) {
|
if (update) {
|
||||||
if (update.type === EventEnum.update) {
|
if (update.type === EventEnum.update) {
|
||||||
this.statuses.unshift(new TootWrapper(update.status));
|
this.statuses.unshift(update.status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
export class TootWrapper {
|
|
||||||
constructor(status: Status) {
|
|
||||||
this.account = new AccountWrapper();
|
|
||||||
this.account.username = status.account.username;
|
|
||||||
this.account.display_name = status.account.display_name;
|
|
||||||
this.account.avatar = status.account.avatar;
|
|
||||||
|
|
||||||
this.content = status.content;
|
|
||||||
}
|
|
||||||
|
|
||||||
account: AccountWrapper; //TODO change to Account
|
|
||||||
content: string;
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
<div class="toot">
|
|
||||||
<img class="toot__avatar" src="{{ toot.account.avatar }}" />
|
|
||||||
<a href class="toot__profile-link"><span class="toot__fullname" innerHTML="{{toot.account.display_name}}"></span> @<span id="toot-username" innerHTML="{{toot.account.username}}"></span></a>
|
|
||||||
<div class="toot__content" innerHTML="{{toot.content}}"></div>
|
|
||||||
</div>
|
|
|
@ -1,17 +0,0 @@
|
||||||
import { Component, OnInit, Input } from "@angular/core";
|
|
||||||
import { TootWrapper } from "../stream.component";
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: "app-toot",
|
|
||||||
templateUrl: "./toot.component.html",
|
|
||||||
styleUrls: ["./toot.component.scss"]
|
|
||||||
})
|
|
||||||
export class TootComponent implements OnInit {
|
|
||||||
@Input() toot: TootWrapper;
|
|
||||||
|
|
||||||
constructor() { }
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue