mirror of
https://github.com/atom/atom.git
synced 2026-02-01 10:14:58 -05:00
Copy session url to clipboard instead of just id
This commit is contained in:
@@ -2,6 +2,7 @@ GuestView = require './guest-view'
|
||||
HostView = require './host-view'
|
||||
HostSession = require './host-session'
|
||||
JoinPromptView = require './join-prompt-view'
|
||||
{getSessionUrl} = require './session-utils'
|
||||
|
||||
module.exports =
|
||||
activate: ->
|
||||
@@ -12,14 +13,15 @@ module.exports =
|
||||
else
|
||||
hostSession = new HostSession()
|
||||
|
||||
rootView.command 'collaboration:copy-session-id', ->
|
||||
copySession = ->
|
||||
sessionId = hostSession.getId()
|
||||
pasteboard.write(sessionId) if sessionId
|
||||
pasteboard.write(getSessionUrl(sessionId)) if sessionId
|
||||
|
||||
rootView.command 'collaboration:copy-session-id', copySession
|
||||
|
||||
rootView.command 'collaboration:start-session', ->
|
||||
hostView ?= new HostView(hostSession)
|
||||
if sessionId = hostSession.start()
|
||||
pasteboard.write(sessionId)
|
||||
copySession() if hostSession.start()
|
||||
|
||||
rootView.command 'collaboration:join-session', ->
|
||||
new JoinPromptView (id) ->
|
||||
|
||||
@@ -3,7 +3,8 @@ Editor = require 'editor'
|
||||
$ = require 'jquery'
|
||||
Point = require 'point'
|
||||
_ = require 'underscore'
|
||||
Guid = require 'guid'
|
||||
|
||||
{getSessionId} = require './session-utils'
|
||||
|
||||
module.exports =
|
||||
class JoinPromptView extends View
|
||||
@@ -20,8 +21,8 @@ class JoinPromptView extends View
|
||||
@on 'core:cancel', => @remove()
|
||||
|
||||
clipboard = pasteboard.read()[0]
|
||||
if Guid.isGuid(clipboard)
|
||||
@miniEditor.setText(clipboard)
|
||||
if sessionId = getSessionId(clipboard)
|
||||
@miniEditor.setText(sessionId)
|
||||
|
||||
@attach()
|
||||
|
||||
|
||||
@@ -1,7 +1,26 @@
|
||||
Peer = require '../vendor/peer.js'
|
||||
Guid = require 'guid'
|
||||
|
||||
url = require 'url'
|
||||
|
||||
module.exports =
|
||||
getSessionId: (text) ->
|
||||
return null unless text
|
||||
|
||||
text = text.trim()
|
||||
sessionUrl = url.parse(text)
|
||||
if sessionUrl.host is 'session'
|
||||
sessionId = sessionUrl.path.split('/')[1]
|
||||
else
|
||||
sessionId = text
|
||||
|
||||
if Guid.isGuid(sessionId)
|
||||
sessionId
|
||||
else
|
||||
null
|
||||
|
||||
getSessionUrl: (sessionId) -> "atom://session/#{sessionId}"
|
||||
|
||||
createPeer: ->
|
||||
id = Guid.create().toString()
|
||||
new Peer(id, key: '0njqmaln320dlsor')
|
||||
|
||||
Reference in New Issue
Block a user