[FIX] Remove unused code for Cordova (#13188)
parent
e5c7472f8c
commit
c736766e80
@ -0,0 +1,6 @@ |
||||
{ |
||||
"globals": { |
||||
"Npm" : false, |
||||
"Package": false |
||||
} |
||||
} |
@ -1,15 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
import { EmojiPicker } from './lib/EmojiPicker'; |
||||
|
||||
if (Meteor.isCordova) { |
||||
window.addEventListener('native.keyboardshow', function() { |
||||
if ((typeof device !== 'undefined' && device !== null ? device.platform.toLowerCase() : false) !== 'android') { |
||||
EmojiPicker.setPosition(); |
||||
} |
||||
}); |
||||
window.addEventListener('native.keyboardhide', function() { |
||||
if ((typeof device !== 'undefined' && device !== null ? device.platform.toLowerCase() : false) !== 'android') { |
||||
EmojiPicker.setPosition(); |
||||
} |
||||
}); |
||||
} |
@ -1,34 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
import { Accounts } from 'meteor/accounts-base'; |
||||
import { Facebook } from 'meteor/facebook-oauth'; |
||||
|
||||
Meteor.loginWithFacebookCordova = function(options, callback) { |
||||
if (!callback && typeof options === 'function') { |
||||
callback = options; |
||||
options = null; |
||||
} |
||||
const credentialRequestCompleteCallback = Accounts.oauth.credentialRequestCompleteHandler(callback); |
||||
const fbLoginSuccess = function(data) { |
||||
data.cordova = true; |
||||
return Accounts.callLoginMethod({ |
||||
methodArguments: [data], |
||||
userCallback: callback, |
||||
}); |
||||
}; |
||||
if (typeof facebookConnectPlugin !== 'undefined') { |
||||
return facebookConnectPlugin.getLoginStatus(function(response) { |
||||
if (response.status !== 'connected') { |
||||
return facebookConnectPlugin.login(['public_profile', 'email'], fbLoginSuccess, function(error) { |
||||
console.log('login', JSON.stringify(error), error); |
||||
return callback(error); |
||||
}); |
||||
} else { |
||||
return fbLoginSuccess(response); |
||||
} |
||||
}, function(error) { |
||||
console.log('getLoginStatus', JSON.stringify(error), error); |
||||
return callback(error); |
||||
}); |
||||
} |
||||
return Facebook.requestCredential(options, credentialRequestCompleteCallback); |
||||
}; |
@ -1,33 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
if (Meteor.isCordova) { |
||||
const body = $(document.body); |
||||
document.addEventListener('deviceready', function() { |
||||
if (typeof device !== 'undefined' && device !== null && device.platform.toLowerCase() !== 'android') { |
||||
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); |
||||
return cordova.plugins.Keyboard.disableScroll(true); |
||||
} |
||||
}); |
||||
window.addEventListener('native.keyboardshow', function() { |
||||
if (typeof device !== 'undefined' && device !== null && device.platform.toLowerCase() !== 'android') { |
||||
if (Meteor.userId() != null) { |
||||
$('.main-content').css('height', window.innerHeight); |
||||
$('.sweet-alert').css('transform', `translateY(-${ (document.height - window.innerHeight) / 2 }px)`).css('-webkit-transform', `translateY(-${ (document.height - window.innerHeight) / 2 }px)`); |
||||
} else { |
||||
body.css('height', window.innerHeight); |
||||
body.css('overflow', 'scroll'); |
||||
} |
||||
} |
||||
}); |
||||
window.addEventListener('native.keyboardhide', function() { |
||||
if (typeof device !== 'undefined' && device !== null && device.platform.toLowerCase() !== 'android') { |
||||
if (Meteor.userId() != null) { |
||||
$('.main-content').css('height', window.innerHeight); |
||||
$('.sweet-alert').css('transform', '').css('-webkit-transform', ''); |
||||
} else { |
||||
body.css('height', window.innerHeight); |
||||
body.css('overflow', 'visible'); |
||||
} |
||||
} |
||||
}); |
||||
} |
@ -1,94 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
import { Tracker } from 'meteor/tracker'; |
||||
import { FlowRouter } from 'meteor/kadira:flow-router'; |
||||
import { Push } from 'meteor/rocketchat:push'; |
||||
import { settings } from 'meteor/rocketchat:settings'; |
||||
|
||||
if (Meteor.isCordova) { |
||||
// Push.addListener 'token', (token) ->
|
||||
// Meteor.call 'log', 'CLIENT', 'token', arguments
|
||||
|
||||
// Push.addListener 'error', (err) ->
|
||||
// Meteor.call 'log', 'CLIENT', 'error', arguments
|
||||
// if err.type == 'apn.cordova'
|
||||
// Meteor.call 'log', 'CLIENT', err.error
|
||||
|
||||
// Push.addListener 'register', (evt) ->
|
||||
// Meteor.call 'log', 'CLIENT', 'register', arguments
|
||||
|
||||
// Push.addListener 'alert', (notification) ->
|
||||
// Meteor.call 'log', 'CLIENT', 'alert', arguments
|
||||
|
||||
// Push.addListener 'sound', (notification) ->
|
||||
// Meteor.call 'log', 'CLIENT', 'sound', arguments
|
||||
|
||||
// Push.addListener 'badge', (notification) ->
|
||||
// Meteor.call 'log', 'CLIENT', 'badge', arguments
|
||||
|
||||
// Push.addListener 'message', (notification) ->
|
||||
// Meteor.call 'log', 'CLIENT', 'message', arguments
|
||||
|
||||
Push.addListener('startup', function(notification) { |
||||
// Meteor.call 'log', 'CLIENT', 'startup', arguments
|
||||
|
||||
if (notification.payload && notification.payload.rid) { |
||||
if (notification.payload.host === Meteor.absoluteUrl()) { |
||||
switch (notification.payload.type) { |
||||
case 'c': |
||||
return FlowRouter.go('channel', { name: notification.payload.name }, FlowRouter.current().queryParams); |
||||
case 'p': |
||||
return FlowRouter.go('group', { name: notification.payload.name }, FlowRouter.current().queryParams); |
||||
case 'd': |
||||
return FlowRouter.go('direct', { username: notification.payload.sender.username }, FlowRouter.current().queryParams); |
||||
} |
||||
} else { |
||||
let path = ''; |
||||
switch (notification.payload.type) { |
||||
case 'c': |
||||
path = `channel/${ notification.payload.name }`; |
||||
break; |
||||
case 'p': |
||||
path = `group/${ notification.payload.name }`; |
||||
break; |
||||
case 'd': |
||||
path = `direct/${ notification.payload.sender.username }`; |
||||
break; |
||||
} |
||||
|
||||
const host = notification.payload.host.replace(/\/$/, ''); |
||||
if (Servers.serverExists(host) !== true) { |
||||
return; |
||||
} |
||||
|
||||
return Servers.startServer(host, path, function(err) { |
||||
if (err) { |
||||
// TODO err
|
||||
return console.log(err); |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
}); |
||||
|
||||
|
||||
Meteor.startup(() => |
||||
Tracker.autorun(() => { |
||||
if (settings.get('Push_enable') === true) { |
||||
|
||||
Push.Configure({ |
||||
android: { |
||||
senderID: window.ANDROID_SENDER_ID, |
||||
sound: true, |
||||
vibrate: true, |
||||
}, |
||||
ios: { |
||||
badge: true, |
||||
clearBadge: true, |
||||
sound: true, |
||||
alert: true, |
||||
}, |
||||
}); |
||||
} |
||||
}) |
||||
); |
||||
} |
@ -1,19 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
Meteor.startup(() => { |
||||
if (!Meteor.isCordova) { return; } |
||||
// Handle click events for all external URLs
|
||||
document.addEventListener('deviceready', () => { |
||||
// const platform = device.platform.toLowerCase();
|
||||
$(document).on('click', function(e) { |
||||
const $link = $(e.target).closest('a[href]'); |
||||
if (!($link.length > 0)) { return; } |
||||
const url = $link.attr('href'); |
||||
|
||||
if (/^https?:\/\/.+/i.test(url) === true) { |
||||
window.open(url, '_system'); |
||||
return e.preventDefault(); |
||||
} |
||||
}); |
||||
}); |
||||
}); |
@ -1,28 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
import { UserPresence } from 'meteor/konecty:user-presence'; |
||||
import { readMessage } from 'meteor/rocketchat:ui-utils'; |
||||
import _ from 'underscore'; |
||||
|
||||
let timer = undefined; |
||||
if (Meteor.isCordova) { |
||||
document.addEventListener('pause', () => { |
||||
UserPresence.setAway(); |
||||
readMessage.disable(); |
||||
|
||||
// Only disconnect after one minute of being in the background
|
||||
timer = setTimeout(() => { |
||||
Meteor.disconnect(); |
||||
timer = undefined; |
||||
}, 60000); |
||||
}, true); |
||||
|
||||
document.addEventListener('resume', () => { |
||||
if (!_.isUndefined(timer)) { |
||||
clearTimeout(timer); |
||||
} |
||||
|
||||
Meteor.reconnect(); |
||||
UserPresence.setOnline(); |
||||
readMessage.enable(); |
||||
}, true); |
||||
} |
@ -0,0 +1,7 @@ |
||||
{ |
||||
"globals": { |
||||
"globals" : true, |
||||
"language_names": true, |
||||
"TAPi18next" : false |
||||
} |
||||
} |
@ -1,42 +0,0 @@ |
||||
import _ from 'underscore'; |
||||
import { Accounts } from 'meteor/accounts-base'; |
||||
import { HTTP } from 'meteor/http'; |
||||
|
||||
function getIdentity(accessToken) { |
||||
try { |
||||
return HTTP.get('https://graph.facebook.com/me', { |
||||
params: { |
||||
access_token: accessToken, |
||||
}, |
||||
}).data; |
||||
} catch (error) { |
||||
throw _.extend(new Error(`Failed to fetch identity from Facebook. ${ error.message }`), { |
||||
response: error.response, |
||||
}); |
||||
} |
||||
} |
||||
|
||||
Accounts.registerLoginHandler(function(loginRequest) { |
||||
if (!loginRequest.cordova) { |
||||
return; |
||||
} |
||||
|
||||
loginRequest = loginRequest.authResponse; |
||||
|
||||
const identity = getIdentity(loginRequest.accessToken); |
||||
const serviceData = { |
||||
accessToken: loginRequest.accessToken, |
||||
expiresAt: Date.now() + 1000 * loginRequest.expiresIn, |
||||
}; |
||||
|
||||
const whitelisted = ['id', 'email', 'name', 'first_name', 'last_name', 'link', 'username', 'gender', 'locale', 'age_range']; |
||||
const fields = _.pick(identity, whitelisted); |
||||
const options = { |
||||
profile: {}, |
||||
}; |
||||
|
||||
_.extend(serviceData, fields); |
||||
_.extend(options.profile, fields); |
||||
|
||||
return Accounts.updateOrCreateUserFromExternalService('facebook', serviceData, options); |
||||
}); |
Loading…
Reference in new issue