gab-social/app/javascript/gabsocial/reducers/albums.js
mgabdev 34f6a1ab5b Progress
new MediaAttachment video style :playable for mp4 to make videojs work with multiple files, hiding albums, hiding bookmark collections. may need tweaks on mediaattachment for mov and other formats : todo :
2020-12-22 12:11:22 -05:00

29 lines
830 B
JavaScript

import {
ALBUMS_FETCH_REQUEST,
ALBUMS_FETCH_SUCCESS,
ALBUMS_FETCH_FAIL,
ALBUM_CREATE_SUCCESS,
ALBUM_REMOVE_REQUEST,
} from '../actions/albums'
import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable'
const importAlbum = (state, album) => state.set(album.id, fromJS(album))
const importAlbums = (state, albums) =>
state.withMutations((mutable) => albums.forEach((album) => importAlbum(mutable, album)))
const initialState = ImmutableMap()
export default function albums(state = initialState, action) {
switch(action.type) {
case ALBUMS_FETCH_SUCCESS:
return importAlbums(state, action.albums)
case ALBUM_CREATE_SUCCESS:
return importAlbum(state, action.album)
case ALBUM_REMOVE_REQUEST:
return state.delete(action.albumId)
default:
return state
}
}