From 09f47c0e59797a1059a8abdd0bf0ac43beaadfd8 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 4 Oct 2017 17:01:22 -0400 Subject: [PATCH] double click to launch website from vault --- src/popup/app/vault/vaultController.js | 42 +++++++++++++---- .../app/vault/vaultViewFolderController.js | 46 ++++++++++++++----- 2 files changed, 66 insertions(+), 22 deletions(-) diff --git a/src/popup/app/vault/vaultController.js b/src/popup/app/vault/vaultController.js index 6be9be4d68..26eeda9c0e 100644 --- a/src/popup/app/vault/vaultController.js +++ b/src/popup/app/vault/vaultController.js @@ -127,12 +127,32 @@ }; $scope.viewLogin = function (login) { - storeState(); - $state.go('viewLogin', { - loginId: login.id, - animation: 'in-slide-up', - from: 'vault' - }); + if (login.clicked) { + login.cancelClick = true; + $scope.launchWebsite(login); + return; + } + + login.clicked = true; + + $timeout(function () { + if (login.cancelClick) { + login.cancelClick = false; + login.clicked = false; + return; + } + + storeState(); + $state.go('viewLogin', { + loginId: login.id, + animation: 'in-slide-up', + from: 'vault' + }); + + // clean up + login.cancelClick = false; + login.clicked = false; + }, 200); }; $scope.viewFolder = function (folder) { @@ -154,10 +174,12 @@ }; $scope.launchWebsite = function (login) { - if (login.uri.startsWith('http://') || login.uri.startsWith('https://')) { - $analytics.eventTrack('Launched Website From Listing'); - chrome.tabs.create({ url: login.uri }); - } + $timeout(function () { + if (login.uri.startsWith('http://') || login.uri.startsWith('https://')) { + $analytics.eventTrack('Launched Website From Listing'); + chrome.tabs.create({ url: login.uri }); + } + }); }; $scope.$on('syncCompleted', function (event, successfully) { diff --git a/src/popup/app/vault/vaultViewFolderController.js b/src/popup/app/vault/vaultViewFolderController.js index d207faad3e..e8f9f16f8f 100644 --- a/src/popup/app/vault/vaultViewFolderController.js +++ b/src/popup/app/vault/vaultViewFolderController.js @@ -2,7 +2,7 @@ .module('bit.vault') .controller('vaultViewFolderController', function ($scope, loginService, folderService, $q, $state, $stateParams, toastr, - syncService, $analytics, i18nService, stateService, utilsService) { + syncService, $analytics, i18nService, stateService, utilsService, $timeout) { var stateKey = 'viewFolder', state = stateService.getState(stateKey) || {}; @@ -64,7 +64,7 @@ $scope.searchLogins(); } - setTimeout(setScrollY, 200); + $timeout(setScrollY, 200); }); } @@ -132,10 +132,12 @@ }; $scope.launchWebsite = function (login) { - if (login.uri.startsWith('http://') || login.uri.startsWith('https://')) { - $analytics.eventTrack('Launched Website From Listing'); - chrome.tabs.create({ url: login.uri }); - } + $timeout(function () { + if (login.uri.startsWith('http://') || login.uri.startsWith('https://')) { + $analytics.eventTrack('Launched Website From Listing'); + chrome.tabs.create({ url: login.uri }); + } + }); }; function resetList(logins) { @@ -169,12 +171,32 @@ }; $scope.viewLogin = function (login) { - storeState(); - $state.go('viewLogin', { - loginId: login.id, - animation: 'in-slide-up', - from: 'folder' - }); + if (login.clicked) { + login.cancelClick = true; + $scope.launchWebsite(login); + return; + } + + login.clicked = true; + + $timeout(function () { + if (login.cancelClick) { + login.cancelClick = false; + login.clicked = false; + return; + } + + storeState(); + $state.go('viewLogin', { + loginId: login.id, + animation: 'in-slide-up', + from: 'folder' + }); + + // clean up + login.cancelClick = false; + login.clicked = false; + }, 200); }; $scope.clipboardError = function (e) {