added update stream action
This commit is contained in:
parent
0fa56da2e4
commit
801445cd8c
|
@ -5,6 +5,11 @@ export class AddStream {
|
||||||
constructor(public stream: StreamElement) {}
|
constructor(public stream: StreamElement) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class UpdateStream {
|
||||||
|
static readonly type = '[Streams] Update stream';
|
||||||
|
constructor(public stream: StreamElement) {}
|
||||||
|
}
|
||||||
|
|
||||||
export class RemoveAllStreams {
|
export class RemoveAllStreams {
|
||||||
static readonly type = '[Streams] Remove all streams';
|
static readonly type = '[Streams] Remove all streams';
|
||||||
constructor(public accountId :string) {}
|
constructor(public accountId :string) {}
|
||||||
|
@ -43,6 +48,21 @@ export class StreamsState {
|
||||||
streams: [...state.streams, action.stream]
|
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)
|
@Action(RemoveAllStreams)
|
||||||
RemoveAllStreams(ctx: StateContext<StreamsStateModel>, action: RemoveAllStreams){
|
RemoveAllStreams(ctx: StateContext<StreamsStateModel>, action: RemoveAllStreams){
|
||||||
const state = ctx.getState();
|
const state = ctx.getState();
|
||||||
|
@ -92,6 +112,10 @@ export class StreamsState {
|
||||||
export class StreamElement {
|
export class StreamElement {
|
||||||
public id: string;
|
public id: string;
|
||||||
|
|
||||||
|
public hideBoosts: boolean;
|
||||||
|
public hideReplies: boolean;
|
||||||
|
public hideBots: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public type: StreamTypeEnum,
|
public type: StreamTypeEnum,
|
||||||
public name: string,
|
public name: string,
|
||||||
|
|
Loading…
Reference in New Issue