more documentation

This commit is contained in:
shams mosowi
2019-10-14 09:17:29 +11:00
parent 16f8a0fede
commit 88f2881981
6 changed files with 21 additions and 5 deletions

View File

@@ -8,6 +8,7 @@ export enum DocActions {
const documentReducer = (prevState: any, newProps: any) => {
switch (newProps.action) {
case DocActions.update:
// takes data object form the dispatcher and updates doc
prevState.ref.update({ ...newProps.data });
return { ...prevState, doc: { ...prevState.doc, ...newProps.data } };
case DocActions.delete:

View File

@@ -38,7 +38,7 @@ const useFiretable = (collectionName: string) => {
const [tableState, tableActions] = useTable({
path: collectionName,
});
/** set collection path of table */
const setTable = (collectionName: string, filters: FireTableFilter[]) => {
configActions.setTable(collectionName);
tableActions.setTable(collectionName, filters);

View File

@@ -5,7 +5,6 @@ import equals from "ramda/es/equals";
import firebase from "firebase/app";
import { algoliaUpdateDoc } from "../../firebase/callables";
import { FireTableFilter } from ".";
import filter from "ramda/es/filter";
const CAP = 1000; // safety paramter sets the upper limit of number of docs fetched by this hook
@@ -30,6 +29,11 @@ const useTable = (initialOverrides: any) => {
...tableInitialState,
...initialOverrides,
});
/** set collection listener
* @param filters
* @param limit max number of docs
* @param sort
*/
const getRows = (
filters: {
key: string;

View File

@@ -2,13 +2,13 @@ import { useReducer } from "react";
import { bucket } from "../../firebase/index";
import firebase from "firebase/app";
const intialState = { progress: 0 };
const initialState = { progress: 0 };
const uploadReducer = (prevState: any, newProps: any) => {
return { ...prevState, ...newProps };
};
const useUploader = () => {
const [uploaderState, uploaderDispatch] = useReducer(uploadReducer, {
...intialState,
...initialState,
});
const upload = (

View File

@@ -2,7 +2,12 @@ import hotkeys, { HotkeysEvent } from "hotkeys-js";
import { useCallback, useEffect } from "react";
type CallbackFn = (event: KeyboardEvent, handler: HotkeysEvent) => void;
/**
* used for listening for keyboard shortcuts
* @param keys
* @param callback
* @param deps
*/
export default function useHotkeys(
keys: string,
callback: CallbackFn,

View File

@@ -1,3 +1,9 @@
/**
* reposition an element in an array
* @param arr array
* @param old_index index of element to be moved
* @param new_index new position of the moved element
*/
export const arrayMover = (
arr: any[],
old_index: number,