ipfs-webui
ipfs-webui copied to clipboard
Improve Implicit `service:cid` Conversion
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.
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:
- Create
ServicePinclassServicePin.loadAllPinsstatic method on the class to read from localStorageServicePin.savestatic method on the class to save an array of ServicePin instances
- instances
2.
servicePin.serviceto get service name. 3.servicePin.cidto get the CID 4.servicePin.saveto save to localStorage