Skip to content

Commit

Permalink
Merge pull request RocketChat#117 from RocketChat/develop
Browse files Browse the repository at this point in the history
Update to version 1.1.0
  • Loading branch information
rodrigok committed Mar 1, 2016
2 parents ebabbaf + 241671a commit fe90b38
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 29 deletions.
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"productName": "Rocket.Chat",
"identifier": "chat.rocket",
"description": "Rocket.Chat Native Cross-Platform Desktop Application via Electron.",
"version": "1.1.0-partial.1",
"version": "1.1.0",
"build": "10",
"author": "Rocket.Chat Support <[email protected]>",
"copyright": "© 2016, Rocket.Chat",
Expand Down
2 changes: 2 additions & 0 deletions app/scripts/menus.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ if (process.platform === 'darwin') {
label: 'Quit',
accelerator: 'Command+Q',
click: function() {
remote.app.forceQuit = true;
app.quit();
}
}
Expand Down Expand Up @@ -169,6 +170,7 @@ if (process.platform === 'darwin') {
label: 'Quit',
accelerator: 'Ctrl+Q',
click: function() {
remote.app.forceQuit = true;
app.quit();
}
}
Expand Down
21 changes: 14 additions & 7 deletions app/scripts/tray.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,21 @@ function createAppTray(mainWindow) {
}, {
label: 'Quit',
click: function() {
remote.app.forceQuit = true;
doQuit();
}
}]);
_tray.setToolTip('Rocket.Chat');
_tray.setContextMenu(contextMenu);

if (process.platform === 'darwin') {
_tray.on('double-clicked', function() {
if (process.platform === 'darwin' || process.platform == 'win32') {
_tray.on('double-click', function() {
toggleShowMainWindow();
});
} else {
let dblClickDelay = 500,
dblClickTimeoutFct = null;
_tray.on('clicked', function() {
_tray.on('click', function() {
if (!dblClickTimeoutFct) {
dblClickTimeoutFct = setTimeout(function() {
// Single click, do nothing for now
Expand Down Expand Up @@ -97,7 +98,6 @@ function showTrayAlert(showAlert, title) {
_tray.setImage(_iconTrayAlert);
if (process.platform === 'darwin') {
_tray.setTitle(title);
// _tray.setTitle(title);
}
} else {
_tray.setImage(_iconTray);
Expand Down Expand Up @@ -145,9 +145,16 @@ bindOnQuit(function() {
remote.app.quit();
});

window.addEventListener('beforeunload', function() {
destroy();
});
// Closes or hides the client
window.onbeforeunload = function(e) {
if(!remote.app.forceQuit) {
showMainWindow(false);
return false;
}
else {
destroy();
}
}

export default {
createAppTray: createAppTray,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"devDependencies": {
"asar": "^0.7.2",
"electron-prebuilt": "git@github.com:RocketChat/electron-prebuilt.git",
"electron-prebuilt": "https://github.com/RocketChat/electron-prebuilt.git",
"fs-jetpack": "^0.7.0",
"gulp": "^3.9.0",
"gulp-less": "^3.0.3",
Expand Down
4 changes: 0 additions & 4 deletions parent.plist
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,5 @@
<true/>
<key>com.apple.security.network.server</key>
<true/>
<key>com.apple.security.personal-information.location</key>
<true/>
<key>com.apple.security.print</key>
<true/>
</dict>
</plist>
158 changes: 142 additions & 16 deletions resources/windows/installer.nsi
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
; NSIS packaging/install script
; Docs: http://nsis.sourceforge.net/Docs/Contents.html

; --------------------------------
; Includes
; --------------------------------

!include LogicLib.nsh
!include nsDialogs.nsh

; --------------------------------
; Variables
; Variables
; --------------------------------

!define dest "{{dest}}"
Expand All @@ -26,7 +30,7 @@
!define uninstaller "uninstall.exe"

; --------------------------------
; Installation
; Installation
; --------------------------------

Unicode true
Expand All @@ -52,27 +56,56 @@ Caption "${productName} Setup"
SubCaption 3 " "
SubCaption 4 " "

; --------------------------------
; Page layout
; --------------------------------

Page custom welcome
Page components
Page directory
Page instfiles
Page custom finish finishEnd

; --------------------------------
; Control variables
; --------------------------------

Var Image
Var ImageHandle

Var LaunchAppCheckbox
Var LaunchAppCheckbox_State

; --------------------------------
; Installer init
; --------------------------------

Function .onInit

; Extract banner image for welcome page
InitPluginsDir
ReserveFile "${banner}"
File /oname=$PLUGINSDIR\banner.bmp "${banner}"

; Check if the application is currently running, show message if it is
retryInstallation:
FindWindow $0 "Chrome_WidgetWin_1" "${productName}"
StrCmp $0 0 notRunning
MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "${productName} is currently running. Please close the application to continue." /SD IDCANCEL IDRETRY retryInstallation
Abort
notRunning:

FunctionEnd

; Custom welcome page
; --------------------------------
; Welcome page [custom]
; --------------------------------

Function welcome

nsDialogs::Create 1018

${NSD_CreateLabel} 185 1u 210 100% "Welcome to ${productName} version ${version} installer.$\r$\n$\r$\nClick install to begin."
${NSD_CreateLabel} 185 1u 210 100% "Welcome to ${productName} version ${version} installer.$\r$\n$\r$\nClick next to continue."

${NSD_CreateBitmap} 0 0 170 210 ""
Pop $Image
Expand All @@ -84,9 +117,15 @@ Function welcome

FunctionEnd

; Installation declarations
Section "Install"
; --------------------------------
; Installation sections
; --------------------------------

Section "${productName} Client"

; Make this section a requirement
SectionIn RO

WriteRegStr HKLM "${regkey}" "Install_Dir" "$INSTDIR"
WriteRegStr HKLM "${uninstkey}" "DisplayName" "${productName}"
WriteRegStr HKLM "${uninstkey}" "DisplayIcon" '"$INSTDIR\icon.ico"'
Expand All @@ -102,18 +141,68 @@ Section "Install"
; Include all files from /build directory
File /r "${src}\*"

; Create start menu shortcut
SetShellVarContext all
CreateShortCut "$SMPROGRAMS\${productName}.lnk" "$INSTDIR\${exec}" "" "$INSTDIR\icon.ico"
WriteUninstaller "${uninstaller}"

SectionEnd

Section "Desktop shortcut"

; Create desktop shortcut
CreateShortCut "$DESKTOP\${productName}.lnk" "$INSTDIR\${exec}" "" "$INSTDIR\icon.ico"

SectionEnd

WriteUninstaller "${uninstaller}"
Section "Autostart Entry"

; Create autostart entry
CreateShortCut "$SMSTARTUP\${productName}.lnk" "$INSTDIR\${exec}" "" "$INSTDIR\icon.ico"

SectionEnd

Section "Start Menu Entry"

; Create start menu entry
SetShellVarContext all
CreateShortCut "$SMPROGRAMS\${productName}.lnk" "$INSTDIR\${exec}" "" "$INSTDIR\icon.ico"

SectionEnd

; --------------------------------
; Finish page [custom]
; --------------------------------

Function finish

nsDialogs::Create 1018

${NSD_CreateLabel} 185 1u 210 30u "${productName} installation successfully finished."

${NSD_CreateCheckbox} 185 35u 100% 10u "Launch ${productName}"
Pop $LaunchAppCheckbox
${NSD_SetState} $LaunchAppCheckbox ${BST_CHECKED}

${NSD_CreateBitmap} 0 0 170 210 ""
Pop $Image
${NSD_SetImage} $Image $PLUGINSDIR\banner.bmp $ImageHandle

nsDialogs::Show

${NSD_FreeImage} $ImageHandle

FunctionEnd

Function finishEnd
; Save checkbox state on installer leave
${NSD_GetState} $LaunchAppCheckbox $LaunchAppCheckbox_State

; Launch the app, if the box is checked
${If} $LaunchAppCheckbox_State == ${BST_CHECKED}
Exec "$INSTDIR\${exec}"
${EndIf}
FunctionEnd

; --------------------------------
; Uninstaller
; Uninstaller
; --------------------------------

ShowUninstDetails nevershow
Expand All @@ -122,13 +211,40 @@ UninstallCaption "Uninstall ${productName}"
UninstallText "Don't like ${productName} anymore? Hit uninstall button."
UninstallIcon "${icon}"

; --------------------------------
; Page layout
; --------------------------------

UninstPage custom un.confirm un.confirmOnLeave
UninstPage instfiles

; --------------------------------
; Control variables
; --------------------------------

Var RemoveAppDataCheckbox
Var RemoveAppDataCheckbox_State

; Custom uninstall confirm page
; --------------------------------
; Uninstaller init
; --------------------------------

Function un.onInit

; Check if the application is currently running, show message if it is
retryUninstall:
FindWindow $0 "Chrome_WidgetWin_1" "${productName}"
StrCmp $0 0 notRunning
MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "${productName} is currently running. Please close the application to continue." /SD IDCANCEL IDRETRY retryUninstall
Abort
notRunning:

FunctionEnd

; --------------------------------
; Confirm page [custom]
; --------------------------------

Function un.confirm

nsDialogs::Create 1018
Expand All @@ -149,17 +265,27 @@ Function un.confirmOnLeave

FunctionEnd

; Uninstall declarations
; --------------------------------
; Uninstallation sections
; --------------------------------

Section "Uninstall"

; Remove registry entries
DeleteRegKey HKLM "${uninstkey}"
DeleteRegKey HKLM "${regkey}"

SetShellVarContext all
Delete "$SMPROGRAMS\${productName}.lnk"
; Remove desktop shortcut
Delete "$DESKTOP\${productName}.lnk"
; Remove whole directory from Program Files

; Remove autostart entry
Delete "$SMSTARTUP\${productName}.lnk"

; Remove start menu entry
SetShellVarContext all
Delete "$SMPROGRAMS\${productName}.lnk"

; Remove whole directory from installation directory
RMDir /r "$INSTDIR"

; Remove also appData directory generated by your app if user checked this option
Expand Down

0 comments on commit fe90b38

Please sign in to comment.