Skip to content

Commit

Permalink
ES6: migrated "properties"
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregor Herdmann committed Apr 18, 2017
1 parent 2c9b00f commit 105423b
Show file tree
Hide file tree
Showing 16 changed files with 351 additions and 280 deletions.
3 changes: 2 additions & 1 deletion app/page/template/_dist/app.htm
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@
<script src="/script/user/UserHandleGenerator.js"></script>
<!-- User Properties -->
<script src="/script/properties/Properties.js"></script>
<script src="/script/properties/PropertiesService.js"></script>
<script src="/script/properties/PropertiesRepository.js"></script>
<script src="/script/properties/PropertiesService.js"></script>
<script src="/script/properties/PropertiesType.js"></script>
<!-- Connection -->
<script src="/script/connect/ConnectError.js"></script>
<script src="/script/connect/ConnectGoogleService.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion app/page/template/content/preferences-options.htm
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<header class="preferences-header" data-bind="l10n_text: z.string.preferences_options_data"></header>
<div class="preferences-option">
<div class="preferences-option-icon checkbox text-theme">
<input type="checkbox" id="data-checkbox" data-bind="attr: {'data-uie-value': option_data}, checked: option_data">
<input type="checkbox" id="data-checkbox" data-bind="attr: {'data-uie-value': option_privacy}, checked: option_privacy">
<label class="preferences-options-checkbox-label" for="data-checkbox" data-bind="l10n_text: z.string.preferences_options_data_checkbox"></label>
</div>
</div>
Expand Down
2 changes: 0 additions & 2 deletions app/script/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ window.z.config = {
// measured in pixel
SCROLL_TO_LAST_MESSAGE_THRESHOLD: 100,

PROPERTIES_KEY: 'webapp',

// bigger requests will be split in chunks with a maximum size as defined
MAXIMUM_USERS_PER_REQUEST: 200,

Expand Down
6 changes: 3 additions & 3 deletions app/script/connect/ConnectRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ z.connect.ConnectRepository = class ConnectRepository {
})
.then((response) => {
this.logger.info(`Gmail contacts upload successful: ${response.results.length} matches, ${response['auto-connects'].length} auto connects`, response);
this.properties_repository.save_preference_contact_import_google(Date.now());
this.properties_repository.save_preference(z.properties.PROPERTIES_TYPE.CONTACT_IMPORT.GOOGLE);
return response;
})
.catch((error) => {
Expand Down Expand Up @@ -96,7 +96,7 @@ z.connect.ConnectRepository = class ConnectRepository {
})
.then((response) => {
this.logger.info(`macOS contacts upload successful: ${response.results.length} matches, ${response['auto-connects'].length} auto connects`, response);
this.properties_repository.save_preference_contact_import_macos(Date.now());
this.properties_repository.save_preference(z.properties.PROPERTIES_TYPE.CONTACT_IMPORT.MACOS);
return response;
})
.catch((error) => {
Expand Down Expand Up @@ -127,7 +127,7 @@ z.connect.ConnectRepository = class ConnectRepository {
})
.then((response) => {
this.logger.info(`macOS contacts upload successful: ${response.results.length} matches, ${response['auto-connects'].length} auto connects`, response);
this.properties_repository.save_preference_contact_import_macos(Date.now());
this.properties_repository.save_preference(z.properties.PROPERTIES_TYPE.CONTACT_IMPORT.MACOS);
return response;
})
.catch((error) => {
Expand Down
5 changes: 2 additions & 3 deletions app/script/event/WebApp.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,9 @@ z.event.WebApp =
SHOW: 'wire.webapp.profile.settings.show'
PROPERTIES:
UPDATE:
CONTACTS_GOOGLE: 'wire.webapp.properties.update.contacts-google'
CONTACTS_MACOS: 'wire.webapp.properties.update.contacts-macos'
CONTACTS: 'wire.webapp.properties.update.contacts'
NOTIFICATIONS: 'wire.webapp.properties.update.notifications'
SEND_DATA: 'wire.webapp.properties.update.send-data'
PRIVACY: 'wire.webapp.properties.update.privacy'
SOUND_ALERTS: 'wire.webapp.properties.update.sound-alerts'
HAS_CREATED_CONVERSATION: 'wire.webapp.properties.update.has-created-conversation'
UPDATED: 'wire.webapp.properties.updated'
Expand Down
4 changes: 2 additions & 2 deletions app/script/main/app.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -473,12 +473,12 @@ class z.main.App
# Disable debugging on any environment.
disable_debugging: ->
z.config.LOGGER.OPTIONS.domains['app.wire.com'] = -> 0
@repository.properties.save_preference_enable_debugging false
@repository.properties.save_preference z.properties.PROPERTIES_TYPE.ENABLE_DEBUGGING, false

# Enable debugging on any environment.
enable_debugging: ->
z.config.LOGGER.OPTIONS.domains['app.wire.com'] = -> 300
@repository.properties.save_preference_enable_debugging true
@repository.properties.save_preference z.properties.PROPERTIES_TYPE.ENABLE_DEBUGGING, true

# Report call telemetry to Raygun for analysis.
report_call: =>
Expand Down
36 changes: 0 additions & 36 deletions app/script/properties/Properties.coffee

This file was deleted.

45 changes: 45 additions & 0 deletions app/script/properties/Properties.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Wire
* Copyright (C) 2017 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*
*/

'use strict';

window.z = window.z || {};
window.z.properties = z.properties || {};

z.properties.Properties = class Properties {
constructor() {
this[z.properties.PROPERTIES_TYPE.VERSION] = 1;
this.settings = {
notifications: z.system_notification.SystemNotificationPreference.ON,
privacy: {
report_errors: true,
improve_wire: true,
},
sound: {
alerts: z.audio.AudioPreference.ALL,
},
};
this.contact_import = {
google: undefined,
macos: undefined,
};
this[z.properties.PROPERTIES_TYPE.HAS_CREATED_CONVERSATION] = false;
this[z.properties.PROPERTIES_TYPE.ENABLE_DEBUGGING] = false;
}
};
138 changes: 0 additions & 138 deletions app/script/properties/PropertiesRepository.coffee

This file was deleted.

Loading

0 comments on commit 105423b

Please sign in to comment.