BusterLabs / Partyshare

A free, open source file sharing application, built on the peer-to-peer hypermedia protocol IPFS.
https://busterlabs.github.io/Partyshare
MIT License
158 stars 26 forks source link

Copy link does not work on linux #39

Closed hexagon6 closed 6 years ago

hexagon6 commented 6 years ago

Scenario:

  1. Existing file in ~/Partyshare
  2. Click on Copy Link
  3. Message Link copied to your clipboard appears
  4. Trying to paste content does not contain new content (while expecting an IPFS link)
hexagon6 commented 6 years ago

More info from the log output:

[18:31:47:0295] [info] [IPFSSync] setState { files: 
   [ { path: '/home/me/Partyshare/fix.jpg',
       hash: 'QmaL7yjgTuRqp59ELEfZDdFHwFEpkMBeHf4b56mGeNCzCd',
       size: NaN,
       urlPath: 'QmeDGcJ7tJK5Pps3MRWUDgUKJpvxRJQHuqgM3nC6occYwd/fix.jpg',
       name: 'fix.jpg' } ],
  synced: true }
hexagon6 commented 6 years ago

Notice: I've patched package.json with the following, since #38 prevented me from installing:

-    "ipfs-api": "git://github.com/bhstahl/js-ipfs-api.git#add-with-querystrings",
-    "ipfsd-ctl": "git://github.com/bhstahl/js-ipfsd-ctl.git#add-with-querystrings",
+    "ipfs-api": "git://github.com/bhstahl/js-ipfs-api.git#master",
+    "ipfsd-ctl": "git://github.com/bhstahl/js-ipfsd-ctl.git#master",
hexagon6 commented 6 years ago

Since the resource is available on ipfs https://gateway.ipfs.io/ipfs/QmeDGcJ7tJK5Pps3MRWUDgUKJpvxRJQHuqgM3nC6occYwd/fix.jpg I assume clipboard.writeText(url, 'selection'); does not work on my machine. Investigating further

hexagon6 commented 6 years ago

Found the bug (or feature :laughing: ):

diff --git a/src/ui/components/FileListItem/index.jsx b/src/ui/components/FileListItem/index.jsx
index d2fc176..a4643e5 100644
--- a/src/ui/components/FileListItem/index.jsx
+++ b/src/ui/components/FileListItem/index.jsx
@@ -30,8 +30,8 @@ const FileListItem = ({
               title="Copy link to your clipboard"
               role="button"
               onClick={() => {
-                  clipboard.writeText(url, 'selection');
-                  ipcRenderer.send(IPC_EVENT_NOTIFICATION, 'Link copied to your clipboard');
+                  clipboard.writeText(url);
+                  ipcRenderer.send(IPC_EVENT_NOTIFICATION, 'Link copied to your clipboard: ' + url);
               }}
             >
                 <span className={styles.copy_button}>

Explanation:

Instead of copying to the clipboard, it copied to the selection clipboard. I expected to press ^V and get contents, instead it is a middle click on the mouse.

Proposing to change either: A) message to reflect copy to selection clipboard B) actually copying to clipboard

hexagon6 commented 6 years ago

@bhstahl what is your opinion to my proposals? I'd prefer B) because on a laptop with touchpad a mouse middle click is usually not available.

bhstahl commented 6 years ago

@hexagon6 I think I prefer B as well, nice choice.