Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

refactor: naming cleanup in trash system

thecodrr2620609d82c3
diff --git a/apps/web/src/components/trash/index.js b/apps/web/src/components/trash/index.js
index b743cbefb..ac5e8d45e 100644
--- a/apps/web/src/components/trash/index.js
+++ b/apps/web/src/components/trash/index.js
@@ -10,28 +10,24 @@ const menuItems = [
{ title: "Restore" },
{
title: "Delete",
- color: "red",
+ color: "red"
}
];
-function sendOpenNoteEvent(note) {
- ev.emit("onOpenNote", note);
-}
-
const Trash = ({ item, index }) => {
- const note = item;
+ const trashItem = item;
return (
<ListItem
- title={note.title}
- body={note.headline}
+ title={trashItem.title}
+ body={trashItem.headline}
index={index}
- onClick={sendOpenNoteEvent.bind(this, note)}
- info={<TimeAgo datetime={note.dateCreated} />}
- menuData={note}
+ onClick={() => {}} //TODO
+ info={<TimeAgo datetime={trashItem.dateDeleted} />}
+ menuData={trashItem}
menuItems={menuItems}
dropdownRefs={dropdownRefs}
/>
);
};
-export default Trash;
\ No newline at end of file
+export default Trash;
diff --git a/apps/web/src/views/Trash.js b/apps/web/src/views/Trash.js
index fc6d953a5..91a2beefc 100644
--- a/apps/web/src/views/Trash.js
+++ b/apps/web/src/views/Trash.js
@@ -1,66 +1,61 @@
-import React, { useState, useEffect } from 'react';
-import {Box, Flex, Text} from 'rebass';
+import React, { useState, useEffect } from "react";
+import { Box, Flex, Text } from "rebass";
import Button from "../components/button";
-import { db } from "../common";
-import Trash1 from '../components/trash';
+import { db, ev } from "../common";
+import TrashItem from "../components/trash";
import Search from "../components/search";
import * as Icon from "react-feather";
import { Virtuoso as List } from "react-virtuoso";
+function Trash() {
+ const [trash, setTrash] = useState([]);
+ useEffect(() => {
+ function onRefreshTrash() {
+ setTrash(db.getTrash());
+ }
+ onRefreshTrash();
+ ev.addListener("refreshTrash", onRefreshTrash);
+ return () => {
+ ev.removeListener("refreshTrash", onRefreshTrash);
+ };
+ }, []);
-function Trash(){
-
- const [trash, setTrash] = useState([]);
-
- useEffect(() => {
- function onRefreshTrash() {
- setTrash(db.getTrash());
- }
- onRefreshTrash();
- //ev.addListener("refreshNotes", onRefreshNotes);
- // return () => {
- // //ev.removeListener("refreshNotes", onRefreshNotes);
- // };
- }, []);
-
- return(
+ return (
+ <Flex flexDirection="column" flex="1 1 auto">
+ {trash.length > 0 ? (
<Flex flexDirection="column" flex="1 1 auto">
- {trash.length > 0 ? (
- <Flex flexDirection="column" flex="1 1 auto">
- <Search placeholder="Search" />
- <List
- style={{
- width: "100%",
- flex: "1 1 auto",
- height: "auto",
- overflowX: "hidden"
- }}
- totalCount={
- trash.length
- }
- item={index => <Trash1 index={index} item={trash[index]} />}
- />
- <Button
- Icon={Icon.Trash2}
- content={"Clear Trash"}
- onClick={db.clearTrash()}
- />
- </Flex>
- ) : (
- <Flex
- flex="1 1 auto"
- alignItems="center"
- justifyContent="center"
- color="#9b9b9b"
- flexDirection="column"
- >
- <Icon.Trash size={72} strokeWidth={1.5} />
- <Text variant="title">You have no trash.</Text>
- </Flex>
- )}
- </Flex>
- );
+ <Search placeholder="Search" />
+ <List
+ style={{
+ width: "100%",
+ flex: "1 1 auto",
+ height: "auto",
+ overflowX: "hidden"
+ }}
+ totalCount={trash.length}
+ item={index => <TrashItem index={index} item={trash[index]} />}
+ />
+ <Button
+ Icon={Icon.Trash2}
+ content={"Clear Trash"}
+ onClick={db.clearTrash()}
+ />
+ </Flex>
+ ) : (
+ <Flex
+ flex="1 1 auto"
+ alignItems="center"
+ justifyContent="center"
+ color="#9b9b9b"
+ flexDirection="column"
+ >
+ <Icon.Trash size={72} strokeWidth={1.5} />
+ <Text variant="title">You have no trash.</Text>
+ </Flex>
+ )}
+ </Flex>
+ );
}
-export default Trash;
\ No newline at end of file
+export default Trash;