[ACA-1607][ACA-1985] Leave library action (#824)

* [ACA-1607] leave library action

* [ACA-1607] confirm leave action

* [ACA-1607] confirm leave action

* [ACA-1607] remove comment
This commit is contained in:
Suzana Dirla
2018-11-23 16:23:26 +02:00
committed by Denys Vuika
parent 62e33efbd0
commit 13db4fb339
9 changed files with 114 additions and 4 deletions

View File

@@ -34,7 +34,9 @@ import {
NavigateLibraryAction,
NAVIGATE_LIBRARY,
UpdateLibraryAction,
UPDATE_LIBRARY
UPDATE_LIBRARY,
LeaveLibraryAction,
LEAVE_LIBRARY
} from '../actions';
import { ContentManagementService } from '../../services/content-management.service';
import { Store } from '@ngrx/store';
@@ -73,6 +75,25 @@ export class LibraryEffects {
})
);
@Effect({ dispatch: false })
leaveLibrary$ = this.actions$.pipe(
ofType<LeaveLibraryAction>(LEAVE_LIBRARY),
map(action => {
if (action.payload) {
this.content.leaveLibrary(action.payload);
} else {
this.store
.select(appSelection)
.pipe(take(1))
.subscribe(selection => {
if (selection && selection.library) {
this.content.leaveLibrary(selection.library.entry.id);
}
});
}
})
);
@Effect()
createLibrary$ = this.actions$.pipe(
ofType<CreateLibraryAction>(CREATE_LIBRARY),