mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-10 17:48:50 +08:00
Revert "feat(mailto): Allow N1 to be default client on windows"
This reverts commit a08eb3e175
.
This commit is contained in:
parent
d940f8df08
commit
7a15e369a7
4 changed files with 34 additions and 24 deletions
|
@ -9,6 +9,8 @@ module.exports =
|
|||
activate: (@state) ->
|
||||
@services = new LaunchServices()
|
||||
|
||||
return unless @services.available()
|
||||
|
||||
# We shouldn't ask if they've already said No
|
||||
return if NylasEnv.config.get(NOTIF_SETTINGS_KEY) is true
|
||||
|
||||
|
|
|
@ -8,9 +8,11 @@ class DefaultMailClientItem extends React.Component {
|
|||
super();
|
||||
this.state = {defaultClient: false};
|
||||
this._services = new LaunchServices();
|
||||
this._services.isRegisteredForURLScheme('mailto', (registered) => {
|
||||
if (this._mounted) this.setState({defaultClient: registered});
|
||||
});
|
||||
if (this._services.available()) {
|
||||
this._services.isRegisteredForURLScheme('mailto', (registered) => {
|
||||
if (this._mounted) this.setState({defaultClient: registered});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
|
@ -33,7 +35,7 @@ class DefaultMailClientItem extends React.Component {
|
|||
}
|
||||
|
||||
render() {
|
||||
if (process.platform !== "darwin") return false;
|
||||
if (process.platform === "win32") return false;
|
||||
return (
|
||||
<div className="item">
|
||||
<input type="checkbox" id="default-client" checked={this.state.defaultClient} onChange={this.toggleDefaultMailClient}/>
|
||||
|
|
|
@ -125,6 +125,10 @@ describe "LaunchServices", ->
|
|||
execHitory = []
|
||||
@services = new LaunchServices.LaunchServicesMac()
|
||||
|
||||
describe "available", ->
|
||||
it "should return true", ->
|
||||
expect(@services.available()).toEqual(true)
|
||||
|
||||
describe "readDefaults", ->
|
||||
|
||||
describe "writeDefaults", ->
|
||||
|
|
|
@ -1,9 +1,25 @@
|
|||
exec = require('child_process').exec
|
||||
app = require('electron').remote.app
|
||||
fs = require('fs')
|
||||
|
||||
bundleIdentifier = 'com.nylas.nylas-mail'
|
||||
|
||||
class LaunchServicesUnavailable
|
||||
available: ->
|
||||
false
|
||||
|
||||
isRegisteredForURLScheme: (scheme, callback) ->
|
||||
throw new Error "isRegisteredForURLScheme is not available"
|
||||
|
||||
resetURLScheme: (scheme, callback) ->
|
||||
throw new Error "resetURLScheme is not available"
|
||||
|
||||
registerForURLScheme: (scheme, callback) ->
|
||||
throw new Error "registerForURLScheme is not available"
|
||||
|
||||
class LaunchServicesLinux
|
||||
available: ->
|
||||
true
|
||||
|
||||
isRegisteredForURLScheme: (scheme, callback) ->
|
||||
throw new Error "isRegisteredForURLScheme is async, provide a callback" unless callback
|
||||
exec "xdg-mime query default x-scheme-handler/#{scheme}", (err, stdout, stderr) ->
|
||||
|
@ -24,6 +40,9 @@ class LaunchServicesMac
|
|||
constructor: ->
|
||||
@secure = false
|
||||
|
||||
available: ->
|
||||
true
|
||||
|
||||
getLaunchServicesPlistPath: (callback) ->
|
||||
secure = "#{process.env.HOME}/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist"
|
||||
insecure = "#{process.env.HOME}/Library/Preferences/com.apple.LaunchServices.plist"
|
||||
|
@ -98,24 +117,7 @@ class LaunchServicesMac
|
|||
@writeDefaults(defaults, callback)
|
||||
|
||||
|
||||
class LaunchServicesElectron
|
||||
constructor: ->
|
||||
|
||||
isRegisteredForURLScheme: (scheme, callback) ->
|
||||
process.nextTick =>
|
||||
callback(app.isDefaultProtocolClient(scheme))
|
||||
|
||||
resetURLScheme: (scheme, callback) ->
|
||||
process.nextTick =>
|
||||
app.removeAsDefaultProtocolClient(scheme)
|
||||
callback(null, null) if callback
|
||||
|
||||
registerForURLScheme: (scheme, callback) ->
|
||||
process.nextTick =>
|
||||
app.setAsDefaultProtocolClient(scheme)
|
||||
callback(null, null) if callback
|
||||
|
||||
module.exports = LaunchServicesElectron
|
||||
module.exports = LaunchServicesUnavailable
|
||||
if process.platform is 'darwin'
|
||||
module.exports = LaunchServicesMac
|
||||
else if process.platform is 'linux'
|
||||
|
@ -123,4 +125,4 @@ else if process.platform is 'linux'
|
|||
|
||||
module.exports.LaunchServicesMac = LaunchServicesMac
|
||||
module.exports.LaunchServicesLinux = LaunchServicesLinux
|
||||
module.exports.LaunchServicesElectron = LaunchServicesElectron
|
||||
module.exports.LaunchServicesUnavailable = LaunchServicesUnavailable
|
||||
|
|
Loading…
Reference in a new issue