From 5cd56400946c6fc3881bce81eefd1549c0301cb0 Mon Sep 17 00:00:00 2001 From: Cole Terlesky Date: Tue, 14 Jun 2022 12:23:18 -0400 Subject: [PATCH 1/3] code cleanup some minor code cleanup that removes warnings from npm start. --- adze-web/src/ConfigureSection.js | 1 + adze-web/src/FeedSection.js | 2 +- adze-web/src/PeersSection.js | 3 ++- adze-web/src/state/feedSlice.js | 8 ++++---- adze-web/src/store.js | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/adze-web/src/ConfigureSection.js b/adze-web/src/ConfigureSection.js index 68f37f1..e01ee49 100644 --- a/adze-web/src/ConfigureSection.js +++ b/adze-web/src/ConfigureSection.js @@ -1,3 +1,4 @@ +import React from 'react'; import Constants from './Constants.js' import { selectManifest, uploadToHub } from './state/manifestSlice.js' import { selectCredentials, validateCredentials } from './state/credentialsSlice.js' diff --git a/adze-web/src/FeedSection.js b/adze-web/src/FeedSection.js index c27fee4..f31850e 100644 --- a/adze-web/src/FeedSection.js +++ b/adze-web/src/FeedSection.js @@ -139,7 +139,7 @@ class ProvenanceDescription extends React.Component { } - return sharerParts.join(", ");; + return sharerParts.join(", "); } getFullShareDescription() { diff --git a/adze-web/src/PeersSection.js b/adze-web/src/PeersSection.js index 31ce9c1..f79d964 100644 --- a/adze-web/src/PeersSection.js +++ b/adze-web/src/PeersSection.js @@ -1,4 +1,5 @@ -import Constants from './Constants.js' +import React from 'react'; +import Constants from './Constants.js'; import { selectManifest , addPeerByUrl, removePeer } from './state/manifestSlice.js' import { useSelector, useDispatch} from 'react-redux' diff --git a/adze-web/src/state/feedSlice.js b/adze-web/src/state/feedSlice.js index f813ca5..1caa9cb 100644 --- a/adze-web/src/state/feedSlice.js +++ b/adze-web/src/state/feedSlice.js @@ -36,15 +36,15 @@ async function updatePeerManifestCache(localManifest, numTimesToFollow) { var toVisitNext = []; var thisPeerOrder = 1; // make a plan to visit all the local peers - for (var peerNo in localManifest.content.peers) { - var peer = localManifest.content.peers[peerNo]; + for (let peerNo in localManifest.content.peers) { + let peer = localManifest.content.peers[peerNo]; peersSeenSoFar[peer.url] = true; toVisit.push(peer); } while (numTimesToFollow > 0) { - for (var peerNo in toVisit) { - var peer = toVisit[peerNo]; + for (let peerNo in toVisit) { + let peer = toVisit[peerNo]; var thisPeerManifest = await getPeerManifest(peer.url); peersSeenSoFar[peer.url] = true; thisPeerManifest.meta.order = thisPeerOrder; diff --git a/adze-web/src/store.js b/adze-web/src/store.js index bfe1be8..68e4ddf 100644 --- a/adze-web/src/store.js +++ b/adze-web/src/store.js @@ -15,7 +15,7 @@ const localStorageMiddleware = ({ getState }) => { const reHydrateStore = () => { if (localStorage.getItem('applicationState') !== null) { return JSON.parse(localStorage.getItem('applicationState')); // re-hydrate the store - }; + } } From b8fa694421cb67d7b74b2162846850dc4c89293d Mon Sep 17 00:00:00 2001 From: Cole Terlesky Date: Tue, 14 Jun 2022 12:23:52 -0400 Subject: [PATCH 2/3] add tagging adding tagging to my links page. only front end code. --- adze-web/src/LinksSection.js | 146 ++++++++++++++++++++++++----------- 1 file changed, 99 insertions(+), 47 deletions(-) diff --git a/adze-web/src/LinksSection.js b/adze-web/src/LinksSection.js index 5d65cf2..1a1d63c 100644 --- a/adze-web/src/LinksSection.js +++ b/adze-web/src/LinksSection.js @@ -1,37 +1,45 @@ -import React from 'react' - - +import React, { useState } from 'react' import Constants from './Constants.js' +import { selectManifest, addLinkByUrl, removeLink } from './state/manifestSlice.js' +import { selectCredentials } from './state/credentialsSlice.js' +import { useSelector, useDispatch } from 'react-redux' +import { ErrorMessageOrNull, ManifestStatusMessage } from './notifications.js' -import { selectManifest , addLinkByUrl, removeLink } from './state/manifestSlice.js' -import { selectCredentials } from './state/credentialsSlice.js' -import { useSelector, useDispatch} from 'react-redux' +const numberOfTags = 4; -import { ErrorMessageOrNull, ManifestStatusMessage} from './notifications.js' - -function SingleLinkElement({link}){ - // upvote adze it to your own list of links +function SingleLinkElement({ link }) { + // upvote adze it to your own list of links // gives you the option of following the peer if you aren't already - // downvote removes it from your feed, adze it to your list of 'no good' + // downvote removes it from your feed, adze it to your list of 'no good' // links, and gives the option of removing that peer - const dispatch = useDispatch(); - - const removeThisLink = () => { - dispatch(removeLink(link)); - } - - return ( -
  • - - {link.title} -
  • - ); + const dispatch = useDispatch(); + + const removeThisLink = () => { + dispatch(removeLink(link)); + } + + return ( +
  • + + {link.title} +
    {link.url}
    + Tags: + + Interesting + + + Website + +
  • + ); } -function LinksSection({isActive}) { - const className = isActive ? "" : "is-invisible"; +function LinksSection({ isActive }) { + const [inputLinkUrl, setInputLinkUrl] = useState("") + const [inputTags, setInputTags] = useState([...Array(numberOfTags)]) + const className = isActive ? "" : "is-invisible"; const styleType = isActive ? {} : Constants.invisibleStyle; const manifest = useSelector(selectManifest); const credentials = useSelector(selectCredentials); @@ -39,33 +47,77 @@ function LinksSection({isActive}) { const linkItems = manifest.content.sites.map(site => ); + const handleClear = () => { + setInputLinkUrl(""); + setInputTags([...Array(numberOfTags)]); + } - const handleAddLink = (event) => { - event.preventDefault(); - const formData = new FormData(event.currentTarget); - const { inputLinkUrl } = event.target.elements; + const updateInputTags = (value, i) => { + let updateInputTags = [...inputTags]; + updateInputTags[i] = value; + setInputTags(updateInputTags); + } - dispatch(addLinkByUrl({credentials: credentials, link: inputLinkUrl.value})); + const handleAddLink = (event) => { + event.preventDefault(); + console.log(inputLinkUrl); + let listOfTags = inputTags.filter(e => e && String(e).trim()); + console.log(listOfTags) + dispatch(addLinkByUrl({ + credentials: credentials, + link: inputLinkUrl, + tags: listOfTags + })); } + + return ( ) } From a141395de6081f5e5d3f3dc4621239d9ccb81190 Mon Sep 17 00:00:00 2001 From: Cole Terlesky Date: Tue, 14 Jun 2022 13:51:51 -0400 Subject: [PATCH 3/3] manifest tag updates manifest now saves tags, my links now displays tags --- adze-web/src/LinksSection.js | 11 +++++------ adze-web/src/state/manifestSlice.js | 1 + 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/adze-web/src/LinksSection.js b/adze-web/src/LinksSection.js index 1a1d63c..56da427 100644 --- a/adze-web/src/LinksSection.js +++ b/adze-web/src/LinksSection.js @@ -26,12 +26,11 @@ function SingleLinkElement({ link }) { {link.title}
    {link.url}
    Tags: - - Interesting - - - Website - + {link.tags && link.tags.length !== 0 && link.tags.map(tag => ( + + {tag} + + ))} ); } diff --git a/adze-web/src/state/manifestSlice.js b/adze-web/src/state/manifestSlice.js index 33c8f7d..149c8ad 100644 --- a/adze-web/src/state/manifestSlice.js +++ b/adze-web/src/state/manifestSlice.js @@ -55,6 +55,7 @@ export const addLinkByUrl = createAsyncThunk( title: linkDesc.title, url: linkDesc.url, timestamp_ms: new Date().getTime(), + tags: linkAndCreds.tags } } )