mirror of
https://github.com/NicolasConstant/sengi
synced 2025-02-03 20:07:47 +01:00
refactoring
This commit is contained in:
parent
cfb6539493
commit
8b116216b8
@ -20,7 +20,7 @@ import { AuthService } from "./services/auth.service";
|
||||
import { AccountsService } from "./services/accounts.service";
|
||||
import { StreamsService } from "./services/streams.service";
|
||||
import { StreamingService } from "./services/streaming.service";
|
||||
import { RegisteredAppsState } from "./stores/registered-apps.state";
|
||||
import { RegisteredAppsState } from "./states/registered-apps.state";
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: "", redirectTo: "home", pathMatch: "full" },
|
||||
|
@ -4,7 +4,7 @@ import { Store, Select } from '@ngxs/store';
|
||||
import { AuthService } from "../../services/auth.service";
|
||||
import { TokenData } from "../../services/models/mastodon.interfaces";
|
||||
import { AccountsService } from "../../services/accounts.service";
|
||||
import { AddRegisteredApp, RegisteredAppsState, RegisteredAppsStateModel } from "../../stores/registered-apps.state";
|
||||
import { AddRegisteredApp, RegisteredAppsState, RegisteredAppsStateModel } from "../../states/registered-apps.state";
|
||||
import { Observable } from "rxjs";
|
||||
|
||||
@Component({
|
||||
|
37
src/app/services/app.service.ts
Normal file
37
src/app/services/app.service.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Http, Response, RequestOptions } from '@angular/http';
|
||||
import { ApiRoutes } from './models/api.settings';
|
||||
|
||||
@Injectable()
|
||||
export class AppService {
|
||||
private apiRoutes = new ApiRoutes();
|
||||
|
||||
constructor(private readonly httpService: Http) {
|
||||
}
|
||||
|
||||
createNewApplication(mastodonUrl: string): Promise<> {
|
||||
const url = mastodonUrl + this.apiRoutes.createApp;
|
||||
|
||||
const options = new RequestOptions();
|
||||
const formData = new FormData();
|
||||
|
||||
formData.append('client_name', 'Sengi');
|
||||
formData.append('redirect_uris', '');
|
||||
formData.append('scopes', 'read write follow');
|
||||
formData.append('website', 'https://github.com/NicolasConstant/sengi');
|
||||
|
||||
return this.httpService.post(url, formData, options)
|
||||
.pipe(
|
||||
map((res: Response) => {
|
||||
const result = res.json();
|
||||
return result as TokenData;
|
||||
}))
|
||||
.toPromise()
|
||||
|
||||
|
||||
.then((res: Response) => {
|
||||
const result = res.json();
|
||||
return result as TokenData;
|
||||
});
|
||||
}
|
||||
}
|
@ -19,9 +19,13 @@ export class RegisteredAppsState {
|
||||
@Action(AddRegisteredApp)
|
||||
AddRegisteredApp(ctx: StateContext<RegisteredAppsStateModel>, action: AddRegisteredApp) {
|
||||
const state = ctx.getState();
|
||||
ctx.setState({
|
||||
ctx.patchState({
|
||||
registeredApps: [...state.registeredApps, action.app]
|
||||
});
|
||||
|
||||
// ctx.setState({
|
||||
// registeredApps: [...state.registeredApps, action.app]
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user