-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from NicolasConstant/develop
Merge for 0.5
- Loading branch information
Showing
52 changed files
with
1,826 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "chrome", | ||
"request": "launch", | ||
"name": "Launch Chrome against localhost", | ||
"url": "http://localhost:4200", | ||
"webRoot": "${workspaceFolder}" | ||
} | ||
] | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
.../components/floating-column/manage-account/direct-messages/direct-messages.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<p> | ||
direct-messages works! | ||
</p> |
Empty file.
25 changes: 25 additions & 0 deletions
25
...mponents/floating-column/manage-account/direct-messages/direct-messages.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { DirectMessagesComponent } from './direct-messages.component'; | ||
|
||
xdescribe('DirectMessagesComponent', () => { | ||
let component: DirectMessagesComponent; | ||
let fixture: ComponentFixture<DirectMessagesComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ DirectMessagesComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(DirectMessagesComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
119 changes: 119 additions & 0 deletions
119
...pp/components/floating-column/manage-account/direct-messages/direct-messages.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import { Component, OnInit, Input, Output, EventEmitter, ViewChild, ElementRef } from '@angular/core'; | ||
|
||
import { AccountWrapper } from '../../../../models/account.models'; | ||
import { OpenThreadEvent } from '../../../../services/tools.service'; | ||
import { StatusWrapper } from '../../../../models/common.model'; | ||
import { NotificationService } from '../../../../services/notification.service'; | ||
import { MastodonService } from '../../../../services/mastodon.service'; | ||
import { StreamTypeEnum } from '../../../../states/streams.state'; | ||
import { Status } from '../../../../services/models/mastodon.interfaces'; | ||
|
||
@Component({ | ||
selector: 'app-direct-messages', | ||
templateUrl: '../../../stream/stream-statuses/stream-statuses.component.html', | ||
styleUrls: ['../../../stream/stream-statuses/stream-statuses.component.scss', './direct-messages.component.scss'] | ||
}) | ||
export class DirectMessagesComponent implements OnInit { | ||
statuses: StatusWrapper[] = []; | ||
displayError: string; | ||
isLoading = true; | ||
isThread = false; | ||
hasContentWarnings = false; | ||
|
||
@Output() browseAccountEvent = new EventEmitter<string>(); | ||
@Output() browseHashtagEvent = new EventEmitter<string>(); | ||
@Output() browseThreadEvent = new EventEmitter<OpenThreadEvent>(); | ||
|
||
private maxReached = false; | ||
private _account: AccountWrapper; | ||
|
||
@Input('account') | ||
set account(acc: AccountWrapper) { | ||
console.warn('account'); | ||
this._account = acc; | ||
this.getDirectMessages(); | ||
} | ||
get account(): AccountWrapper { | ||
return this._account; | ||
} | ||
|
||
@ViewChild('statusstream') public statustream: ElementRef; | ||
|
||
constructor( | ||
private readonly notificationService: NotificationService, | ||
private readonly mastodonService: MastodonService) { } | ||
|
||
ngOnInit() { | ||
} | ||
|
||
private reset() { | ||
this.isLoading = true; | ||
this.statuses.length = 0; | ||
this.maxReached = false; | ||
} | ||
|
||
private getDirectMessages() { | ||
this.reset(); | ||
|
||
this.mastodonService.getTimeline(this.account.info, StreamTypeEnum.directmessages) | ||
.then((statuses: Status[]) => { | ||
//this.maxId = statuses[statuses.length - 1].id; | ||
for (const s of statuses) { | ||
const wrapper = new StatusWrapper(s, this.account.info); | ||
this.statuses.push(wrapper); | ||
} | ||
}) | ||
.catch(err => { | ||
this.notificationService.notifyHttpError(err); | ||
}) | ||
.then(() => { | ||
this.isLoading = false; | ||
}); | ||
} | ||
|
||
onScroll() { | ||
var element = this.statustream.nativeElement as HTMLElement; | ||
const atBottom = element.scrollHeight <= element.clientHeight + element.scrollTop + 1000; | ||
|
||
if (atBottom) { | ||
this.scrolledToBottom(); | ||
} | ||
} | ||
|
||
private scrolledToBottom() { | ||
if (this.isLoading || this.maxReached) return; | ||
|
||
const maxId = this.statuses[this.statuses.length - 1].status.id; | ||
this.isLoading = true; | ||
this.mastodonService.getTimeline(this.account.info, StreamTypeEnum.directmessages, maxId) | ||
.then((statuses: Status[]) => { | ||
if (statuses.length === 0) { | ||
this.maxReached = true; | ||
return; | ||
} | ||
|
||
for (const s of statuses) { | ||
const wrapper = new StatusWrapper(s, this.account.info); | ||
this.statuses.push(wrapper); | ||
} | ||
}) | ||
.catch(err => { | ||
this.notificationService.notifyHttpError(err); | ||
}) | ||
.then(() => { | ||
this.isLoading = false; | ||
}); | ||
} | ||
|
||
browseAccount(accountName: string): void { | ||
this.browseAccountEvent.next(accountName); | ||
} | ||
|
||
browseHashtag(hashtag: string): void { | ||
this.browseHashtagEvent.next(hashtag); | ||
} | ||
|
||
browseThread(openThreadEvent: OpenThreadEvent): void { | ||
this.browseThreadEvent.next(openThreadEvent); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
src/app/components/floating-column/manage-account/favorites/favorites.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<p> | ||
favorites works! | ||
</p> |
Empty file.
25 changes: 25 additions & 0 deletions
25
src/app/components/floating-column/manage-account/favorites/favorites.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { FavoritesComponent } from './favorites.component'; | ||
|
||
xdescribe('FavoritesComponent', () => { | ||
let component: FavoritesComponent; | ||
let fixture: ComponentFixture<FavoritesComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ FavoritesComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(FavoritesComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
123 changes: 123 additions & 0 deletions
123
src/app/components/floating-column/manage-account/favorites/favorites.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import { Component, OnInit, Output, EventEmitter, Input, ViewChild, ElementRef } from '@angular/core'; | ||
|
||
import { StatusWrapper } from '../../../../models/common.model'; | ||
import { OpenThreadEvent } from '../../../../services/tools.service'; | ||
import { AccountWrapper } from '../../../../models/account.models'; | ||
import { MastodonService, FavoriteResult } from '../../../../services/mastodon.service'; | ||
import { Status } from '../../../../services/models/mastodon.interfaces'; | ||
import { NotificationService } from '../../../../services/notification.service'; | ||
import { resetCompiledComponents } from '@angular/core/src/render3/jit/module'; | ||
|
||
@Component({ | ||
selector: 'app-favorites', | ||
templateUrl: '../../../stream/stream-statuses/stream-statuses.component.html', | ||
styleUrls: ['../../../stream/stream-statuses/stream-statuses.component.scss', './favorites.component.scss'] | ||
}) | ||
export class FavoritesComponent implements OnInit { | ||
statuses: StatusWrapper[] = []; | ||
displayError: string; | ||
isLoading = true; | ||
isThread = false; | ||
hasContentWarnings = false; | ||
|
||
@Output() browseAccountEvent = new EventEmitter<string>(); | ||
@Output() browseHashtagEvent = new EventEmitter<string>(); | ||
@Output() browseThreadEvent = new EventEmitter<OpenThreadEvent>(); | ||
|
||
private maxReached = false; | ||
private maxId: string; | ||
private _account: AccountWrapper; | ||
|
||
@Input('account') | ||
set account(acc: AccountWrapper) { | ||
this._account = acc; | ||
this.getFavorites(); | ||
} | ||
get account(): AccountWrapper { | ||
return this._account; | ||
} | ||
|
||
@ViewChild('statusstream') public statustream: ElementRef; | ||
|
||
constructor( | ||
private readonly notificationService: NotificationService, | ||
private readonly mastodonService: MastodonService) { } | ||
|
||
ngOnInit() { | ||
} | ||
|
||
private reset(){ | ||
this.isLoading = true; | ||
this.statuses.length = 0; | ||
this.maxReached = false; | ||
this.maxId = null; | ||
} | ||
|
||
private getFavorites() { | ||
this.reset(); | ||
|
||
this.mastodonService.getFavorites(this.account.info) | ||
.then((result: FavoriteResult) => { | ||
this.maxId = result.max_id; | ||
for (const s of result.favorites) { | ||
const wrapper = new StatusWrapper(s, this.account.info); | ||
this.statuses.push(wrapper); | ||
} | ||
}) | ||
.catch(err => { | ||
this.notificationService.notifyHttpError(err); | ||
}) | ||
.then(() => { | ||
this.isLoading = false; | ||
}); | ||
|
||
} | ||
|
||
onScroll() { | ||
var element = this.statustream.nativeElement as HTMLElement; | ||
const atBottom = element.scrollHeight <= element.clientHeight + element.scrollTop + 1000; | ||
|
||
if (atBottom) { | ||
this.scrolledToBottom(); | ||
} | ||
} | ||
|
||
|
||
private scrolledToBottom() { | ||
if (this.isLoading || this.maxReached) return; | ||
|
||
this.isLoading = true; | ||
this.mastodonService.getFavorites(this.account.info, this.maxId) | ||
.then((result: FavoriteResult) => { | ||
const statuses = result.favorites; | ||
if (statuses.length === 0 || !this.maxId) { | ||
this.maxReached = true; | ||
return; | ||
} | ||
|
||
this.maxId = result.max_id; | ||
for (const s of statuses) { | ||
const wrapper = new StatusWrapper(s, this.account.info); | ||
this.statuses.push(wrapper); | ||
} | ||
}) | ||
.catch(err => { | ||
this.notificationService.notifyHttpError(err); | ||
}) | ||
.then(() => { | ||
this.isLoading = false; | ||
}); | ||
} | ||
|
||
browseAccount(accountName: string): void { | ||
this.browseAccountEvent.next(accountName); | ||
} | ||
|
||
browseHashtag(hashtag: string): void { | ||
this.browseHashtagEvent.next(hashtag); | ||
} | ||
|
||
browseThread(openThreadEvent: OpenThreadEvent): void { | ||
this.browseThreadEvent.next(openThreadEvent); | ||
} | ||
} |
Oops, something went wrong.