From 801445cd8c4e542e0fa0589bb9cdd980148c353b Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Sun, 23 Jun 2019 21:01:36 -0400 Subject: [PATCH] added update stream action --- src/app/states/streams.state.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/app/states/streams.state.ts b/src/app/states/streams.state.ts index ee72081a..accdbd62 100644 --- a/src/app/states/streams.state.ts +++ b/src/app/states/streams.state.ts @@ -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, 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, 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,