This repository has been archived by the owner on Jun 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
renderer.js
64 lines (50 loc) · 2.09 KB
/
renderer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// All of the Node.js APIs are available in this process.
var angApp = require('./app/init')
require('./app/services/credentials-service')
require('./app/services/settings-service')
require('./app/services/system-service')
require('./app/services/app-state-service')
require('./app/services/xmpp-helper-service')
require('./app/services/chimeverse-service')
require('./app/controllers/settings-controller')
require('./app/controllers/login-controller')
require('./app/controllers/default-controller')
require('./app/controllers/about-controller')
require('./app/controllers/footer-controller')
angApp.controller('AppController', function ($scope, $timeout, ChimeVerseService, SettingsService, AppStateService) {
const { ipcRenderer } = require('electron')
// Menu force logout event
ipcRenderer.on('force-logout-event', () => {
ChimeVerseService.logout()
let event = new CustomEvent("converse-force-logout") // Dispatch to the plugin
document.dispatchEvent(event)
})
// Menu settings event
ipcRenderer.on('preferences-event', () => {
AppStateService.set(AppStateService.APP_STATE_SETTINGS)
})
// Menu about event
ipcRenderer.on('about-page-event', () => {
AppStateService.set(AppStateService.APP_STATE_ABOUT)
})
// Menu about event
ipcRenderer.on('open-unread-chat', () => {
let event = new CustomEvent('conversejs-open-chat', {detail: ChimeVerseService.chatToOpen})
document.dispatchEvent(event)
})
AppStateService.set(AppStateService.APP_STATE_DEFAULT)
$scope.$on('app:state:changed', (event, data) => {
// @see https://docs.angularjs.org/error/$rootScope/inprog
$timeout(() => {
$scope.state = data
console.log('Switch to the "' + $scope.state +'" state')
}, 0)
})
$scope.$on('app:restart', (event, data) => {
ipcRenderer.send('app-restart')
})
SettingsService.initDefaults()
ChimeVerseService.getCredentialsAndLogin()
})