Progress, Deck done

This commit is contained in:
mgabdev
2020-12-16 17:29:06 -05:00
parent 8f94ffad9c
commit 04053c0e31
20 changed files with 473 additions and 93 deletions

View File

@@ -1,16 +1,23 @@
import throttle from 'lodash.throttle'
import debounce from 'lodash.debounce'
import api, { getLinks } from '../api'
import { importFetchedAccounts } from './importer'
import { me } from '../initial_state'
export const CHAT_CONVERSATION_CREATE_SEARCH_ACCOUNTS_SUCCESS = 'CHAT_CONVERSATION_CREATE_SEARCH_ACCOUNTS_SUCCESS'
export const CLEAR_CHAT_CONVERSATION_CREATE_SEARCH_ACCOUNTS = 'CLEAR_CHAT_CONVERSATION_CREATE_SEARCH_ACCOUNTS'
export const SET_CHAT_CONVERSATION_SELECTED = 'SET_CHAT_CONVERSATION_SELECTED'
/**
*
*/
export const fetchChatConversationAccountSuggestions = (query) => throttle((dispatch, getState) => {
export const fetchChatConversationAccountSuggestions = (query) => (dispatch, getState) => {
if (!query) return
debouncedFetchChatConversationAccountSuggestions(query, dispatch, getState)
}
export const debouncedFetchChatConversationAccountSuggestions = debounce((query, dispatch, getState) => {
if (!query) return
api(getState).get('/api/v1/accounts/search', {
@@ -25,13 +32,20 @@ export const fetchChatConversationAccountSuggestions = (query) => throttle((disp
}).catch((error) => {
//
})
}, 200, { leading: true, trailing: true })
}, 650, { leading: true })
const fetchChatConversationAccountSuggestionsSuccess = (accounts) => ({
type: CHAT_CONVERSATION_CREATE_SEARCH_ACCOUNTS_SUCCESS,
accounts,
})
/**
*
*/
export const clearChatConversationAccountSuggestions = () => (dispatch) => {
dispatch({ type: CLEAR_CHAT_CONVERSATION_CREATE_SEARCH_ACCOUNTS })
}
/**
*
*/

View File

@@ -41,6 +41,7 @@ export const COMPOSE_QUOTE = 'COMPOSE_QUOTE'
export const COMPOSE_REPLY_CANCEL = 'COMPOSE_REPLY_CANCEL'
export const COMPOSE_MENTION = 'COMPOSE_MENTION'
export const COMPOSE_RESET = 'COMPOSE_RESET'
export const COMPOSE_GROUP_SET = 'COMPOSE_GROUP_SET'
export const COMPOSE_UPLOAD_REQUEST = 'COMPOSE_UPLOAD_REQUEST'
export const COMPOSE_UPLOAD_SUCCESS = 'COMPOSE_UPLOAD_SUCCESS'
@@ -762,6 +763,14 @@ export const changeExpiresAt = (value) => ({
value,
})
/**
*
*/
export const changeComposeGroupId = (groupId) => ({
type: COMPOSE_GROUP_SET,
groupId,
})
/**
*
*/

View File

@@ -1,5 +1,8 @@
import debounce from 'lodash.debounce'
import api from '../api'
import { me } from '../initial_state'
import { saveSettings } from './settings'
import { importFetchedAccounts } from './importer'
export const DECK_CONNECT = 'DECK_CONNECT'
export const DECK_DISCONNECT = 'DECK_DISCONNECT'
@@ -8,6 +11,9 @@ export const DECK_SET_COLUMN_AT_INDEX = 'DECK_SET_COLUMN_AT_INDEX'
export const DECK_DELETE_COLUMN_AT_INDEX = 'DECK_DELETE_COLUMN_AT_INDEX'
export const DECK_CHANGE_COLUMN_AT_INDEX = 'DECK_CHANGE_COLUMN_AT_INDEX'
export const DECK_SEARCH_USERS_SUCCESS = 'DECK_SEARCH_USERS_SUCCESS'
export const DECK_SEARCH_USERS_CLEAR = 'DECK_SEARCH_USERS_CLEAR'
export const deckConnect = () => ({
type: DECK_CONNECT,
})
@@ -41,3 +47,40 @@ export const updateDeckColumnAtIndex = (oldIndex, newIndex) => (dispatch) => {
})
dispatch(saveSettings())
}
/**
*
*/
export const fetchDeckAccountSuggestions = (query) => (dispatch, getState) => {
if (!query) return
debouncedFetchDeckAccountSuggestions(query, dispatch, getState)
}
const debouncedFetchDeckAccountSuggestions = debounce((query, dispatch, getState) => {
if (!query) return
api(getState).get('/api/v1/accounts/search', {
params: {
q: query,
resolve: false,
limit: 4,
},
}).then((response) => {
dispatch(importFetchedAccounts(response.data))
dispatch(fetchDeckAccountSuggestionsSuccess(response.data))
}).catch((error) => {
//
})
}, 650, { leading: true })
const fetchDeckAccountSuggestionsSuccess = (accounts) => ({
type: DECK_SEARCH_USERS_SUCCESS,
accounts,
})
/**
*
*/
export const clearDeckAccountSuggestions = () => (dispatch) => {
dispatch({ type: DECK_SEARCH_USERS_CLEAR })
}