mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-29 00:16:39 +01:00
more documentation
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 = (
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user