accounts approved, video player testing, bookmark collections
This commit is contained in:
mgabdev
2020-12-17 01:34:00 -05:00
parent 04053c0e31
commit 5a37a7090e
88 changed files with 688 additions and 395 deletions

View File

@@ -1,7 +1,9 @@
import {
BOOKMARK_COLLECTIONS_FETCH_REQUEST,
BOOKMARK_COLLECTIONS_FETCH_SUCCESS,
BOOKMARK_COLLECTIONS_FETCH_FAIL,
ALBUMS_FETCH_REQUEST,
ALBUMS_FETCH_SUCCESS,
ALBUMS_FETCH_FAIL,
ALBUMS_CREATE_SUCCESS,
ALBUMS_REMOVE_REQUEST,
} from '../actions/bookmarks'
import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable'
@@ -12,49 +14,32 @@ const initialState = ImmutableMap({
isError: false,
})
const normalizeBookmarkCollection = (bookmarkCollection) => {
return {
id: shortcut.id,
shortcut_type: 'account',
shortcut_id: shortcut.shortcut_id,
title: shortcut.shortcut.acct,
image: shortcut.shortcut.avatar_static,
to: `/${shortcut.shortcut.acct}`,
}
}
const normalizeBookmarkCollections = (shortcuts) => {
return fromJS(shortcuts.map((shortcut) => {
return normalizeShortcut(shortcut)
}))
}
export default function albums(state = initialState, action) {
switch(action.type) {
case SHORTCUTS_FETCH_REQUEST:
case ALBUMS_FETCH_REQUEST:
return state.withMutations((map) => {
map.set('isLoading', true)
map.set('isFetched', false)
map.set('isError', false)
})
case SHORTCUTS_FETCH_SUCCESS:
case ALBUMS_FETCH_SUCCESS:
return state.withMutations((map) => {
map.set('items', normalizeShortcuts(action.shortcuts))
map.set('items', fromJS(action.bookmarkCollections))
map.set('isLoading', false)
map.set('isFetched', true)
map.set('isError', false)
})
case SHORTCUTS_FETCH_FAIL:
case ALBUMS_FETCH_FAIL:
return state.withMutations((map) => {
map.set('isLoading', false)
map.set('isFetched', true)
map.set('isError', true)
})
case BOOKMARK_COLLECTIONS_CREATE_REQUEST:
return state.update('items', list => list.push(fromJS(normalizeShortcut(action.shortcut))))
case BOOKMARK_COLLECTIONS_REMOVE_REQUEST:
case ALBUMS_CREATE_SUCCESS:
return state.update('items', list => list.push(fromJS(action.bookmarkCollection)))
case ALBUMS_REMOVE_REQUEST:
return state.update('items', list => list.filterNot((item) => {
return `${item.get('id')}` === `${action.shortcutId}`
return item.get('id') === action.bookmarkCollectionId
}))
default:
return state