Commit d98b6944 authored by Milan DiGiuseppe's avatar Milan DiGiuseppe

'found' date stored as timestamp

parent 44dff6e4
......@@ -5,7 +5,7 @@ export const sampleCaches: Cache[] = [
id: '0',
name: 'milan.digiuseppe',
message: 'Ok gamer time',
found: new Date(2020, 0, 2, 0, 0, 0, 0).toISOString(),
found: new Date(2020, 0, 2, 0, 0, 0, 0).valueOf(),
lat: 40.7464687,
lng: -73.9844323,
isUserCreated: true,
......@@ -14,7 +14,7 @@ export const sampleCaches: Cache[] = [
id: '1',
name: 'will.brown',
message: 'Check out my cute ass dogs. Follow my on ig. I post epic dogs',
found: new Date(2019, 9, 20, 0, 0, 0, 0).toISOString(),
found: new Date(2019, 9, 20, 0, 0, 0, 0).valueOf(),
lat: 43.40,
lng: -80.56,
isUserCreated: false,
......@@ -23,7 +23,7 @@ export const sampleCaches: Cache[] = [
id: '2',
name: 'jayson',
message: 'My first cache, and also a cry for help. Please help me I\'m stuck in a cache writing factory',
found: new Date(2020, 1, 14, 0, 0, 0, 0).toISOString(),
found: new Date(2020, 1, 14, 0, 0, 0, 0).valueOf(),
lat: 43.40,
lng: -80.56,
isUserCreated: false,
......@@ -32,7 +32,7 @@ export const sampleCaches: Cache[] = [
id: '3',
name: 'krisztian',
message: 'Someone please give us $1 million for this app. We are starving students',
found: new Date(2020, 1, 8, 0, 0, 0, 0).toISOString(),
found: new Date(2020, 1, 8, 0, 0, 0, 0).valueOf(),
lat: 43.40,
lng: -80.56,
isUserCreated: false,
......
......@@ -11,7 +11,7 @@ import GeoText from './GeoText';
const { colors, spacing } = theme;
interface Props {
found: string;
found: number;
name: string;
message: string;
}
......
......@@ -32,7 +32,7 @@ const DiscoverScreen: React.FC = () => {
setOpenCache(null);
}, [setCacheModalOpen, setOpenCache]);
const onSave = useCallback((cache: Cache) => {
dispatch(saveCache({ ...cache, found: new Date().toISOString() }));
dispatch(saveCache({ ...cache, found: new Date().valueOf() }));
onClose();
}, [dispatch, onClose]);
const onReport = useCallback((id) => {
......
......@@ -50,7 +50,6 @@ const MessageCreateScreen: React.FC = () => {
uuid: '1',
expire: duration,
name: anonymous ? 'anonymous' : 'milan.digiuseppe',
found: new Date().toISOString(),
isUserCreated: true,
}));
});
......
......@@ -43,7 +43,6 @@ const SectionHeader: React.FC<SectionHeaderProps> = ({ title }) => (
</View>
);
// TODO: sort by timestamp
const cacheSort = (a: Cache, b: Cache) => b.found - a.found;
const SavedMessagesScreen: React.FC = () => {
......
import { createSelector } from '@reduxjs/toolkit'
import { createSelector } from '@reduxjs/toolkit';
import { RootState } from '../RootReducer';
const getSavedCaches = (state: RootState) => Object.values(state.caches.saved);
export const getUserCreatedCaches = createSelector([getSavedCaches],
(saved) => saved.filter(c => c.isUserCreated));
(saved) => saved.filter((c) => c.isUserCreated));
export const getFoundCaches = createSelector([getSavedCaches],
(saved) => saved.filter(c => !c.isUserCreated));
(saved) => saved.filter((c) => !c.isUserCreated));
export const getDiscoveredCaches = (state: RootState) => Object.values(state.caches.discovered);
......@@ -2,7 +2,7 @@ export interface Cache {
// uuid?: string;
id: string;
expire?: number;
found: string;
found: number; // timestamp
lat: number;
lng: number;
name: string;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment