added update stream action

This commit is contained in:
Nicolas Constant 2019-06-23 21:01:36 -04:00
parent 0fa56da2e4
commit 801445cd8c
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
1 changed files with 24 additions and 0 deletions

View File

@ -5,6 +5,11 @@ export class AddStream {
constructor(public stream: StreamElement) {}
}
export class UpdateStream {
static readonly type = '[Streams] Update stream';
constructor(public stream: StreamElement) {}
}
export class RemoveAllStreams {
static readonly type = '[Streams] Remove all streams';
constructor(public accountId :string) {}
@ -43,6 +48,21 @@ export class StreamsState {
streams: [...state.streams, action.stream]
});
}
@Action(UpdateStream)
UpdateStream(ctx: StateContext<StreamsStateModel>, action: UpdateStream){
const state = ctx.getState();
const otherStreams = state.streams.filter(x => x.id !== action.stream.id);
const updatedStream = state.streams.find(x => x.id === action.stream.id);
updatedStream.hideBoosts = action.stream.hideBoosts;
updatedStream.hideReplies = action.stream.hideReplies;
updatedStream.hideBots = action.stream.hideBots;
ctx.patchState({
streams: [...otherStreams, updatedStream]
});
}
@Action(RemoveAllStreams)
RemoveAllStreams(ctx: StateContext<StreamsStateModel>, action: RemoveAllStreams){
const state = ctx.getState();
@ -92,6 +112,10 @@ export class StreamsState {
export class StreamElement {
public id: string;
public hideBoosts: boolean;
public hideReplies: boolean;
public hideBots: boolean;
constructor(
public type: StreamTypeEnum,
public name: string,