ipfs-webui icon indicating copy to clipboard operation
ipfs-webui copied to clipboard

Improve Implicit `service:cid` Conversion

Open hacdias opened this issue 3 years ago • 1 comments

In multiple places of our code base, we convert pin information, stored as service:cid, using .split(':'). This can open the way for some bugs (unlikely unless some data is corrupted or manually changed in the user's local storage). We can replace this instances by some method that validates the string and returns the expected output.

https://github.com/ipfs/ipfs-webui/blob/183c476581fcbfa612aacf6b3622a9d6a8620afc/src/bundles/pinning.js#L13-L15

https://github.com/ipfs/ipfs-webui/blob/83ceac1066a00771fd618e3d58b0617268c7bacc/src/files/files-list/FilesList.js#L26

And some others introduced in https://github.com/ipfs/ipfs-webui/pull/1919.

hacdias avatar Oct 03 '22 08:10 hacdias

I think we can still store the data as strings service:cid but we should codify that instead of having it be implicit. We should have a solution that:

  1. Create ServicePin class
    1. ServicePin.loadAllPins static method on the class to read from localStorage
    2. ServicePin.save static method on the class to save an array of ServicePin instances
  2. instances 2. servicePin.service to get service name. 3. servicePin.cid to get the CID 4. servicePin.save to save to localStorage

SgtPooki avatar Oct 03 '22 17:10 SgtPooki