Encapsulate all link validation requests inside LinkSource (Client)
evancofer opened this issue · comments
We should encapsulate all link functions requiring communication with the server or reddit. We should put them inside a LinkSource
object on the client side, with an interface of getLink()
and removeLink(link)
. The first, getLink()
should return a fresh link every time. The other, removeLink(link)
tells LinkSource
that link
has been seen, and to tell the server to add it to the database.
Furthermore, we need to determine the logic with which to act upon replies from client-side link validation requests to server. By response, I mean things like determining whether or not to fetch more links from reddit or returning a link(s). This response should be indifferent for single link validation and multiple link validation.
We do not need a getLinks(n)
method for getting n
links at a time from reddit. This is because LinkSource
should at most store a certain number of links in the cache at a time (lets call this number maxLinks
). The actual number of links stored locally will only be equal to maxLinks
on page load on login. It will decline as the user removes these links one at a time. Other than this login, there will never be a time where the user is requesting more than 1 link at a time. Furthermore, at login the LinkSource
will automatically get and fetch maxLinks
links, and then the TableRow
will build the table one row at a time using getLink()
.