fix(@desktop/notifications): move notifications settings to `status-go`
Fixes #5649
This commit is contained in:
parent
72c389ba09
commit
aeba272ae4
|
@ -47,6 +47,7 @@ type
|
|||
notificationsManager*: NotificationsManager
|
||||
|
||||
# Global
|
||||
appSettingsVariant: QVariant
|
||||
localAppSettingsVariant: QVariant
|
||||
localAccountSettingsVariant: QVariant
|
||||
localAccountSensitiveSettingsVariant: QVariant
|
||||
|
@ -111,7 +112,11 @@ proc connect(self: AppController) =
|
|||
proc newAppController*(statusFoundation: StatusFoundation): AppController =
|
||||
result = AppController()
|
||||
result.statusFoundation = statusFoundation
|
||||
result.notificationsManager = newNotificationsManager(statusFoundation.events)
|
||||
|
||||
# Preparing settings service to be exposed later as global QObject
|
||||
result.settingsService = settings_service.newService()
|
||||
result.appSettingsVariant = newQVariant(result.settingsService)
|
||||
result.notificationsManager = newNotificationsManager(statusFoundation.events, result.settingsService)
|
||||
|
||||
# Global
|
||||
result.localAppSettingsVariant = newQVariant(singletonInstance.localAppSettings)
|
||||
|
@ -122,7 +127,6 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController =
|
|||
|
||||
# Services
|
||||
result.generalService = general_service.newService()
|
||||
result.settingsService = settings_service.newService()
|
||||
result.nodeConfigurationService = node_configuration_service.newService(statusFoundation.fleetConfiguration,
|
||||
result.settingsService)
|
||||
result.keychainService = keychain_service.newService(statusFoundation.events)
|
||||
|
@ -237,6 +241,7 @@ proc delete*(self: AppController) =
|
|||
self.mainModule.delete
|
||||
self.languageService.delete
|
||||
|
||||
self.appSettingsVariant.delete
|
||||
self.localAppSettingsVariant.delete
|
||||
self.localAccountSettingsVariant.delete
|
||||
self.localAccountSensitiveSettingsVariant.delete
|
||||
|
@ -314,12 +319,10 @@ proc load(self: AppController) =
|
|||
self.ensService.init()
|
||||
self.gifService.init()
|
||||
|
||||
# Accessible after user login
|
||||
singletonInstance.engine.setRootContextProperty("appSettings", self.appSettingsVariant)
|
||||
singletonInstance.engine.setRootContextProperty("globalUtils", self.globalUtilsVariant)
|
||||
|
||||
let pubKey = self.settingsService.getPublicKey()
|
||||
singletonInstance.localAccountSensitiveSettings.setFileName(pubKey)
|
||||
singletonInstance.engine.setRootContextProperty("localAccountSensitiveSettings", self.localAccountSensitiveSettingsVariant)
|
||||
|
||||
self.buildAndRegisterLocalAccountSensitiveSettings()
|
||||
self.buildAndRegisterUserProfile()
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ import NimQml, json, chronicles
|
|||
import ../../global/app_signals
|
||||
import ../../global/global_singleton
|
||||
import ../eventemitter
|
||||
import ../../../app_service/service/settings/service as settings_service
|
||||
import details
|
||||
|
||||
export details
|
||||
|
@ -39,15 +40,17 @@ type
|
|||
QtObject:
|
||||
type NotificationsManager* = ref object of QObject
|
||||
events: EventEmitter
|
||||
settingsService: settings_service.Service
|
||||
osNotification: StatusOSNotification
|
||||
soundManager: StatusSoundManager
|
||||
notificationSetUp: bool
|
||||
|
||||
proc processNotification(self: NotificationsManager, title: string, message: string, details: NotificationDetails)
|
||||
|
||||
proc setup(self: NotificationsManager, events: EventEmitter) =
|
||||
proc setup(self: NotificationsManager, events: EventEmitter, settingsService: settings_service.Service) =
|
||||
self.QObject.setup
|
||||
self.events = events
|
||||
self.settingsService = settingsService
|
||||
|
||||
proc delete*(self: NotificationsManager) =
|
||||
if self.notificationSetUp:
|
||||
|
@ -55,9 +58,9 @@ QtObject:
|
|||
self.soundManager.delete
|
||||
self.QObject.delete
|
||||
|
||||
proc newNotificationsManager*(events: EventEmitter): NotificationsManager =
|
||||
proc newNotificationsManager*(events: EventEmitter, settingsService: settings_service.Service): NotificationsManager =
|
||||
new(result, delete)
|
||||
result.setup(events)
|
||||
result.setup(events, settingsService)
|
||||
|
||||
proc init*(self: NotificationsManager) =
|
||||
self.osNotification = newStatusOSNotification()
|
||||
|
@ -145,27 +148,6 @@ QtObject:
|
|||
sectionId: sectionId)
|
||||
self.processNotification(title, message, details)
|
||||
|
||||
proc getExemptions(self: NotificationsManager, id: string): JsonNode =
|
||||
# This proc returns exemptions as json object for the passed `id` if there are no set exemptions,
|
||||
# json object with the default values will be returned.
|
||||
let allExemptions = singletonInstance.localAccountSensitiveSettings.getNotifSettingExemptionsAsJson()
|
||||
result = %* {
|
||||
EXEMPTION_KEY_MUTE_ALL_MESSAGES: false,
|
||||
EXEMPTION_KEY_PERSONAL_MENTIONS: LSS_VALUE_NOTIF_SEND_ALERTS,
|
||||
EXEMPTION_KEY_GLOBAL_MENTIONS: LSS_VALUE_NOTIF_SEND_ALERTS,
|
||||
EXEMPTION_KEY_OTHER_MESSAGES: LSS_VALUE_NOTIF_SEND_TURN_OFF
|
||||
}
|
||||
if(allExemptions.contains(id)):
|
||||
let obj = allExemptions[id]
|
||||
if(obj.contains(EXEMPTION_KEY_MUTE_ALL_MESSAGES)):
|
||||
result[EXEMPTION_KEY_MUTE_ALL_MESSAGES] = obj[EXEMPTION_KEY_MUTE_ALL_MESSAGES]
|
||||
if(obj.contains(EXEMPTION_KEY_PERSONAL_MENTIONS)):
|
||||
result[EXEMPTION_KEY_PERSONAL_MENTIONS] = obj[EXEMPTION_KEY_PERSONAL_MENTIONS]
|
||||
if(obj.contains(EXEMPTION_KEY_GLOBAL_MENTIONS)):
|
||||
result[EXEMPTION_KEY_GLOBAL_MENTIONS] = obj[EXEMPTION_KEY_GLOBAL_MENTIONS]
|
||||
if(obj.contains(EXEMPTION_KEY_OTHER_MESSAGES)):
|
||||
result[EXEMPTION_KEY_OTHER_MESSAGES] = obj[EXEMPTION_KEY_OTHER_MESSAGES]
|
||||
|
||||
proc notificationCheck(self: NotificationsManager, title: string, message: string, details: NotificationDetails,
|
||||
notificationWay: string) =
|
||||
var data = NotificationArgs(title: title, message: message, details: details)
|
||||
|
@ -183,7 +165,7 @@ QtObject:
|
|||
details.notificationType == NotificationType.NewContactRequest or
|
||||
details.notificationType == NotificationType.IdentityVerificationRequest):
|
||||
|
||||
if(notificationWay == LSS_VALUE_NOTIF_SEND_DELIVER_QUIETLY):
|
||||
if(notificationWay == VALUE_NOTIF_DELIVER_QUIETLY):
|
||||
return
|
||||
|
||||
if((details.notificationType == NotificationType.NewMessage or
|
||||
|
@ -200,17 +182,17 @@ QtObject:
|
|||
|
||||
if(not appIsActive or details.notificationType == NotificationType.TestNotification):
|
||||
# Check anonymity level
|
||||
if(singletonInstance.localAccountSensitiveSettings.getNotificationMessagePreviewSetting() == PREVIEW_ANONYMOUS):
|
||||
if(self.settingsService.getNotificationMessagePreview() == PREVIEW_ANONYMOUS):
|
||||
data.title = "Status"
|
||||
data.message = "You have a new message"
|
||||
elif(singletonInstance.localAccountSensitiveSettings.getNotificationMessagePreviewSetting() == PREVIEW_NAME_ONLY):
|
||||
elif(self.settingsService.getNotificationMessagePreview() == PREVIEW_NAME_ONLY):
|
||||
data.message = "You have a new message"
|
||||
let identifier = $(details.toJsonNode())
|
||||
debug "Add OS notification", title=data.title, message=data.message, identifier=identifier
|
||||
self.showOSNotification(data.title, data.message, identifier)
|
||||
|
||||
if(singletonInstance.localAccountSensitiveSettings.getNotificationSoundsEnabled()):
|
||||
self.soundManager.setPlayerVolume(singletonInstance.localAccountSensitiveSettings.getVolume())
|
||||
if(self.settingsService.getNotificationSoundsEnabled()):
|
||||
self.soundManager.setPlayerVolume(self.settingsService.getNotificationVolume())
|
||||
self.soundManager.playSound(NOTIFICATION_SOUND)
|
||||
|
||||
proc processNotification(self: NotificationsManager, title: string, message: string, details: NotificationDetails) =
|
||||
|
@ -225,76 +207,76 @@ QtObject:
|
|||
# - https://drive.google.com/file/d/1L_9c2CMObcDcSuhVUu97s9-_26gtutES/view
|
||||
# - https://drive.google.com/file/d/1KmG7lJDJIx6R_HJWeFvMYT2wk32RoTJQ/view
|
||||
|
||||
if(not singletonInstance.localAccountSensitiveSettings.getNotifSettingAllowNotifications()):
|
||||
if(not self.settingsService.getNotifSettingAllowNotifications()):
|
||||
return
|
||||
|
||||
# In case of contact request
|
||||
if(details.notificationType == NotificationType.NewContactRequest):
|
||||
if(singletonInstance.localAccountSensitiveSettings.getNotifSettingContactRequests() != LSS_VALUE_NOTIF_SEND_TURN_OFF):
|
||||
self.notificationCheck(title, message, details, singletonInstance.localAccountSensitiveSettings.getNotifSettingContactRequests())
|
||||
if(self.settingsService.getNotifSettingContactRequests() != VALUE_NOTIF_TURN_OFF):
|
||||
self.notificationCheck(title, message, details, self.settingsService.getNotifSettingContactRequests())
|
||||
return
|
||||
|
||||
# In case of identity verification request
|
||||
elif(details.notificationType == NotificationType.IdentityVerificationRequest):
|
||||
if(singletonInstance.localAccountSensitiveSettings.getNotifSettingIdentityVerificationRequests() != LSS_VALUE_NOTIF_SEND_TURN_OFF):
|
||||
self.notificationCheck(title, message, details, singletonInstance.localAccountSensitiveSettings.getNotifSettingIdentityVerificationRequests())
|
||||
if(self.settingsService.getNotifSettingIdentityVerificationRequests() != VALUE_NOTIF_TURN_OFF):
|
||||
self.notificationCheck(title, message, details, self.settingsService.getNotifSettingIdentityVerificationRequests())
|
||||
return
|
||||
|
||||
# In case of new message (regardless it's message with mention or not)
|
||||
elif(details.notificationType == NotificationType.NewMessage or
|
||||
details.notificationType == NotificationType.NewMessageWithPersonalMention or
|
||||
details.notificationType == NotificationType.NewMessageWithGlobalMention):
|
||||
if(singletonInstance.localAccountSensitiveSettings.getNotifSettingAllMessages() != LSS_VALUE_NOTIF_SEND_TURN_OFF):
|
||||
self.notificationCheck(title, message, details, singletonInstance.localAccountSensitiveSettings.getNotifSettingAllMessages())
|
||||
if(self.settingsService.getNotifSettingAllMessages() != VALUE_NOTIF_TURN_OFF):
|
||||
self.notificationCheck(title, message, details, self.settingsService.getNotifSettingAllMessages())
|
||||
return
|
||||
|
||||
let messageBelongsToCommunity = details.isCommunitySection
|
||||
if(messageBelongsToCommunity):
|
||||
let exemptionObj = self.getExemptions(details.sectionId)
|
||||
if(exemptionObj[EXEMPTION_KEY_MUTE_ALL_MESSAGES].getBool):
|
||||
let exemptions = self.settingsService.getNotifSettingExemptions(details.sectionId)
|
||||
if(exemptions.muteAllMessages):
|
||||
return
|
||||
|
||||
if(details.notificationType == NotificationType.NewMessageWithPersonalMention and
|
||||
exemptionObj[EXEMPTION_KEY_PERSONAL_MENTIONS].getStr != LSS_VALUE_NOTIF_SEND_TURN_OFF):
|
||||
self.notificationCheck(title, message, details, exemptionObj[EXEMPTION_KEY_PERSONAL_MENTIONS].getStr)
|
||||
exemptions.personalMentions != VALUE_NOTIF_TURN_OFF):
|
||||
self.notificationCheck(title, message, details, exemptions.personalMentions)
|
||||
return
|
||||
|
||||
if(details.notificationType == NotificationType.NewMessageWithGlobalMention and
|
||||
exemptionObj[EXEMPTION_KEY_GLOBAL_MENTIONS].getStr != LSS_VALUE_NOTIF_SEND_TURN_OFF):
|
||||
self.notificationCheck(title, message, details, exemptionObj[EXEMPTION_KEY_GLOBAL_MENTIONS].getStr)
|
||||
exemptions.globalMentions != VALUE_NOTIF_TURN_OFF):
|
||||
self.notificationCheck(title, message, details, exemptions.globalMentions)
|
||||
return
|
||||
|
||||
if(details.notificationType == NotificationType.NewMessage and
|
||||
exemptionObj[EXEMPTION_KEY_OTHER_MESSAGES].getStr != LSS_VALUE_NOTIF_SEND_TURN_OFF):
|
||||
self.notificationCheck(title, message, details, exemptionObj[EXEMPTION_KEY_OTHER_MESSAGES].getStr)
|
||||
exemptions.otherMessages != VALUE_NOTIF_TURN_OFF):
|
||||
self.notificationCheck(title, message, details, exemptions.otherMessages)
|
||||
return
|
||||
|
||||
return
|
||||
else:
|
||||
if(details.isOneToOne or details.isGroupChat):
|
||||
let exemptionObj = self.getExemptions(details.chatId)
|
||||
if(exemptionObj[EXEMPTION_KEY_MUTE_ALL_MESSAGES].getBool):
|
||||
let exemptions = self.settingsService.getNotifSettingExemptions(details.chatId)
|
||||
if(exemptions.muteAllMessages):
|
||||
return
|
||||
|
||||
if(details.notificationType == NotificationType.NewMessageWithPersonalMention and
|
||||
singletonInstance.localAccountSensitiveSettings.getNotifSettingPersonalMentions() != LSS_VALUE_NOTIF_SEND_TURN_OFF):
|
||||
self.notificationCheck(title, message, details, singletonInstance.localAccountSensitiveSettings.getNotifSettingPersonalMentions())
|
||||
self.settingsService.getNotifSettingPersonalMentions() != VALUE_NOTIF_TURN_OFF):
|
||||
self.notificationCheck(title, message, details, self.settingsService.getNotifSettingPersonalMentions())
|
||||
return
|
||||
|
||||
if(details.notificationType == NotificationType.NewMessageWithGlobalMention and
|
||||
singletonInstance.localAccountSensitiveSettings.getNotifSettingGlobalMentions() != LSS_VALUE_NOTIF_SEND_TURN_OFF):
|
||||
self.notificationCheck(title, message, details, singletonInstance.localAccountSensitiveSettings.getNotifSettingGlobalMentions())
|
||||
self.settingsService.getNotifSettingGlobalMentions() != VALUE_NOTIF_TURN_OFF):
|
||||
self.notificationCheck(title, message, details, self.settingsService.getNotifSettingGlobalMentions())
|
||||
return
|
||||
|
||||
if(details.notificationType == NotificationType.NewMessage):
|
||||
if(details.isOneToOne and
|
||||
singletonInstance.localAccountSensitiveSettings.getNotifSettingOneToOneChats() != LSS_VALUE_NOTIF_SEND_TURN_OFF):
|
||||
self.notificationCheck(title, message, details, singletonInstance.localAccountSensitiveSettings.getNotifSettingOneToOneChats())
|
||||
self.settingsService.getNotifSettingOneToOneChats() != VALUE_NOTIF_TURN_OFF):
|
||||
self.notificationCheck(title, message, details, self.settingsService.getNotifSettingOneToOneChats())
|
||||
return
|
||||
|
||||
if(details.isGroupChat and
|
||||
singletonInstance.localAccountSensitiveSettings.getNotifSettingGroupChats() != LSS_VALUE_NOTIF_SEND_TURN_OFF):
|
||||
self.notificationCheck(title, message, details, singletonInstance.localAccountSensitiveSettings.getNotifSettingGroupChats())
|
||||
self.settingsService.getNotifSettingGroupChats() != VALUE_NOTIF_TURN_OFF):
|
||||
self.notificationCheck(title, message, details, self.settingsService.getNotifSettingGroupChats())
|
||||
return
|
||||
|
||||
# In all other cases (TestNotification, AcceptedContactRequest, JoinCommunityRequest, MyRequestToJoinCommunityAccepted,
|
||||
|
|
|
@ -36,12 +36,6 @@ const LSS_KEY_HIDDEN_COMMUNITY_CHANNELS_AND_CATEGORIES_BANNERS* = "hiddenCommuni
|
|||
const DEFAULT_HIDDEN_COMMUNITY_CHANNELS_AND_CATEGORIES_BANNERS = ""
|
||||
const LSS_KEY_HIDDEN_COMMUNITY_BACKUP_BANNERS* = "hiddenCommunityBackUpBanners"
|
||||
const DEFAULT_HIDDEN_COMMUNITY_BACKUP_BANNERS = ""
|
||||
const LSS_KEY_VOLUME* = "volume"
|
||||
const DEFAULT_VOLUME = 50
|
||||
const LSS_KEY_NOTIFICATION_SOUNDS_ENABLED* = "notificationSoundsEnabled"
|
||||
const DEFAULT_NOTIFICATION_SOUNDS_ENABLED = true
|
||||
const LSS_KEY_NOTIFICATION_MESSAGE_PREVIEW_SETTING* = "notificationMessagePreviewSetting"
|
||||
const DEFAULT_NOTIFICATION_MESSAGE_PREVIEW_SETTING = 2 #notificationPreviewNameAndMessage from qml
|
||||
const LSS_KEY_WITHLISTED_UNFURLING_SITES* = "whitelistedUnfurlingSites"
|
||||
const DEFAULT_WITHLISTED_UNFURLING_SITES = ""
|
||||
const LSS_KEY_NEVER_ASK_ABOUT_UNFURLING_AGAIN* = "neverAskAboutUnfurlingAgain"
|
||||
|
@ -101,36 +95,6 @@ const DEFAULT_IS_DDMMYY_DATE_FORMAT = false
|
|||
const LSS_KEY_IS_24H_TIME_FORMAT* = "is_24h_time_format"
|
||||
const DEFAULT_IS_24H_TIME_FORMAT = false
|
||||
|
||||
# Exemption Keys
|
||||
const EXEMPTION_KEY_MUTE_ALL_MESSAGES* = "muteAllMessages"
|
||||
const EXEMPTION_KEY_PERSONAL_MENTIONS* = "personalMentions"
|
||||
const EXEMPTION_KEY_GLOBAL_MENTIONS* = "globalMentions"
|
||||
const EXEMPTION_KEY_OTHER_MESSAGES* = "otherMessages"
|
||||
|
||||
# Exemption Values
|
||||
const LSS_VALUE_NOTIF_SEND_ALERTS* = "sendAlerts"
|
||||
const LSS_VALUE_NOTIF_SEND_DELIVER_QUIETLY* = "deliverQuietly"
|
||||
const LSS_VALUE_NOTIF_SEND_TURN_OFF* = "turnOff"
|
||||
|
||||
# Notifications
|
||||
const LSS_KEY_NOTIF_SETTING_ALLOW_NOTIFICATIONS* = "allowNotifications"
|
||||
const DEFAULT_NOTIF_SETTING_ALLOW_NOTIFICATIONS = true
|
||||
const LSS_KEY_NOTIF_SETTING_ONE_TO_ONE_CHATS* = "notifSettingOneToOneChats"
|
||||
const DEFAULT_NOTIF_SETTING_ONE_TO_ONE_CHATS = LSS_VALUE_NOTIF_SEND_ALERTS
|
||||
const LSS_KEY_NOTIF_SETTING_GROUP_CHATS* = "notifSettingGroupChats"
|
||||
const DEFAULT_NOTIF_SETTING_GROUP_CHATS = LSS_VALUE_NOTIF_SEND_ALERTS
|
||||
const LSS_KEY_NOTIF_SETTING_PERSONAL_MENTIONS* = "notifSettingPersonalMentions"
|
||||
const DEFAULT_NOTIF_SETTING_PERSONAL_MENTIONS = LSS_VALUE_NOTIF_SEND_ALERTS
|
||||
const LSS_KEY_NOTIF_SETTING_GLOBAL_MENTIONS* = "notifSettingGlobalMentions"
|
||||
const DEFAULT_NOTIF_SETTING_GLOBAL_MENTIONS = LSS_VALUE_NOTIF_SEND_ALERTS
|
||||
const LSS_KEY_NOTIF_SETTING_ALL_MESSAGES* = "notifSettingAllMessages"
|
||||
const DEFAULT_NOTIF_SETTING_ALL_MESSAGES = LSS_VALUE_NOTIF_SEND_TURN_OFF
|
||||
const LSS_KEY_NOTIF_SETTING_CONTACT_REQUESTS* = "notifSettingContactRequests"
|
||||
const DEFAULT_NOTIF_SETTING_CONTACT_REQUESTS = LSS_VALUE_NOTIF_SEND_ALERTS
|
||||
const LSS_KEY_NOTIF_SETTING_IDENTITY_VERIF_REQUESTS* = "notifSettingIdentityVerificationRequests"
|
||||
const DEFAULT_NOTIF_SETTING_IDENTITY_VERIF_REQUESTS = LSS_VALUE_NOTIF_SEND_ALERTS
|
||||
const LSS_KEY_NOTIF_SETTING_EXEMPTIONS* = "notificationsExemptions"
|
||||
const DEFAULT_NOTIF_SETTING_EXEMPTIONS = ""
|
||||
|
||||
logScope:
|
||||
topics = "la-sensitive-settings"
|
||||
|
@ -422,44 +386,6 @@ QtObject:
|
|||
notify = hiddenCommunityBackUpBannersChanged
|
||||
|
||||
|
||||
proc volumeChanged*(self: LocalAccountSensitiveSettings) {.signal.}
|
||||
proc getVolume*(self: LocalAccountSensitiveSettings): int {.slot.} =
|
||||
getSettingsProp[int](self, LSS_KEY_VOLUME, newQVariant(DEFAULT_VOLUME))
|
||||
proc setVolume*(self: LocalAccountSensitiveSettings, value: int) {.slot.} =
|
||||
setSettingsProp(self, LSS_KEY_VOLUME, newQVariant(value)):
|
||||
self.volumeChanged()
|
||||
QtProperty[int] volume:
|
||||
read = getVolume
|
||||
write = setVolume
|
||||
notify = volumeChanged
|
||||
|
||||
|
||||
proc notificationSoundsEnabledChanged*(self: LocalAccountSensitiveSettings) {.signal.}
|
||||
proc getNotificationSoundsEnabled*(self: LocalAccountSensitiveSettings): bool {.slot.} =
|
||||
getSettingsProp[bool](self, LSS_KEY_NOTIFICATION_SOUNDS_ENABLED, newQVariant(DEFAULT_NOTIFICATION_SOUNDS_ENABLED))
|
||||
proc setNotificationSoundsEnabled*(self: LocalAccountSensitiveSettings, value: bool) {.slot.} =
|
||||
setSettingsProp(self, LSS_KEY_NOTIFICATION_SOUNDS_ENABLED, newQVariant(value)):
|
||||
self.notificationSoundsEnabledChanged()
|
||||
|
||||
QtProperty[bool] notificationSoundsEnabled:
|
||||
read = getNotificationSoundsEnabled
|
||||
write = setNotificationSoundsEnabled
|
||||
notify = notificationSoundsEnabledChanged
|
||||
|
||||
|
||||
proc notificationMessagePreviewSettingChanged*(self: LocalAccountSensitiveSettings) {.signal.}
|
||||
proc getNotificationMessagePreviewSetting*(self: LocalAccountSensitiveSettings): int {.slot.} =
|
||||
getSettingsProp[int](self, LSS_KEY_NOTIFICATION_MESSAGE_PREVIEW_SETTING, newQVariant(DEFAULT_NOTIFICATION_MESSAGE_PREVIEW_SETTING))
|
||||
proc setNotificationMessagePreviewSetting*(self: LocalAccountSensitiveSettings, value: int) {.slot.} =
|
||||
setSettingsProp(self, LSS_KEY_NOTIFICATION_MESSAGE_PREVIEW_SETTING, newQVariant(value)):
|
||||
self.notificationMessagePreviewSettingChanged()
|
||||
|
||||
QtProperty[int] notificationMessagePreviewSetting:
|
||||
read = getNotificationMessagePreviewSetting
|
||||
write = setNotificationMessagePreviewSetting
|
||||
notify = notificationMessagePreviewSettingChanged
|
||||
|
||||
|
||||
proc whitelistedUnfurlingSitesChanged*(self: LocalAccountSensitiveSettings) {.signal.}
|
||||
proc getWhitelistedUnfurlingSites*(self: LocalAccountSensitiveSettings): QVariant {.slot.} =
|
||||
getSettingsPropQVariant(self, LSS_KEY_WITHLISTED_UNFURLING_SITES, newQVariant(DEFAULT_WITHLISTED_UNFURLING_SITES))
|
||||
|
@ -835,117 +761,6 @@ QtObject:
|
|||
write = setIs24hTimeFormat
|
||||
notify = is24hTimeFormatChanged
|
||||
|
||||
proc notifSettingAllowNotificationsChanged*(self: LocalAccountSensitiveSettings) {.signal.}
|
||||
proc getNotifSettingAllowNotifications*(self: LocalAccountSensitiveSettings): bool {.slot.} =
|
||||
getSettingsProp[bool](self, LSS_KEY_NOTIF_SETTING_ALLOW_NOTIFICATIONS, newQVariant(DEFAULT_NOTIF_SETTING_ALLOW_NOTIFICATIONS))
|
||||
proc setNotifSettingAllowNotifications*(self: LocalAccountSensitiveSettings, value: bool) {.slot.} =
|
||||
setSettingsProp(self, LSS_KEY_NOTIF_SETTING_ALLOW_NOTIFICATIONS, newQVariant(value)):
|
||||
self.notifSettingAllowNotificationsChanged()
|
||||
QtProperty[bool] notifSettingAllowNotifications:
|
||||
read = getNotifSettingAllowNotifications
|
||||
write = setNotifSettingAllowNotifications
|
||||
notify = notifSettingAllowNotificationsChanged
|
||||
|
||||
proc notifSettingOneToOneChatsChanged*(self: LocalAccountSensitiveSettings) {.signal.}
|
||||
proc getNotifSettingOneToOneChats*(self: LocalAccountSensitiveSettings): string {.slot.} =
|
||||
getSettingsProp[string](self, LSS_KEY_NOTIF_SETTING_ONE_TO_ONE_CHATS, newQVariant(DEFAULT_NOTIF_SETTING_ONE_TO_ONE_CHATS))
|
||||
proc setNotifSettingOneToOneChats*(self: LocalAccountSensitiveSettings, value: string) {.slot.} =
|
||||
setSettingsProp(self, LSS_KEY_NOTIF_SETTING_ONE_TO_ONE_CHATS, newQVariant(value)):
|
||||
self.notifSettingOneToOneChatsChanged()
|
||||
QtProperty[string] notifSettingOneToOneChats:
|
||||
read = getNotifSettingOneToOneChats
|
||||
write = setNotifSettingOneToOneChats
|
||||
notify = notifSettingOneToOneChatsChanged
|
||||
|
||||
proc notifSettingGroupChatsChanged*(self: LocalAccountSensitiveSettings) {.signal.}
|
||||
proc getNotifSettingGroupChats*(self: LocalAccountSensitiveSettings): string {.slot.} =
|
||||
getSettingsProp[string](self, LSS_KEY_NOTIF_SETTING_GROUP_CHATS, newQVariant(DEFAULT_NOTIF_SETTING_GROUP_CHATS))
|
||||
proc setNotifSettingGroupChats*(self: LocalAccountSensitiveSettings, value: string) {.slot.} =
|
||||
setSettingsProp(self, LSS_KEY_NOTIF_SETTING_GROUP_CHATS, newQVariant(value)):
|
||||
self.notifSettingGroupChatsChanged()
|
||||
QtProperty[string] notifSettingGroupChats:
|
||||
read = getNotifSettingGroupChats
|
||||
write = setNotifSettingGroupChats
|
||||
notify = notifSettingGroupChatsChanged
|
||||
|
||||
proc notifSettingPersonalMentionsChanged*(self: LocalAccountSensitiveSettings) {.signal.}
|
||||
proc getNotifSettingPersonalMentions*(self: LocalAccountSensitiveSettings): string {.slot.} =
|
||||
getSettingsProp[string](self, LSS_KEY_NOTIF_SETTING_PERSONAL_MENTIONS, newQVariant(DEFAULT_NOTIF_SETTING_PERSONAL_MENTIONS))
|
||||
proc setNotifSettingPersonalMentions*(self: LocalAccountSensitiveSettings, value: string) {.slot.} =
|
||||
setSettingsProp(self, LSS_KEY_NOTIF_SETTING_PERSONAL_MENTIONS, newQVariant(value)):
|
||||
self.notifSettingPersonalMentionsChanged()
|
||||
QtProperty[string] notifSettingPersonalMentions:
|
||||
read = getNotifSettingPersonalMentions
|
||||
write = setNotifSettingPersonalMentions
|
||||
notify = notifSettingPersonalMentionsChanged
|
||||
|
||||
proc notifSettingGlobalMentionsChanged*(self: LocalAccountSensitiveSettings) {.signal.}
|
||||
proc getNotifSettingGlobalMentions*(self: LocalAccountSensitiveSettings): string {.slot.} =
|
||||
getSettingsProp[string](self, LSS_KEY_NOTIF_SETTING_GLOBAL_MENTIONS, newQVariant(DEFAULT_NOTIF_SETTING_GLOBAL_MENTIONS))
|
||||
proc setNotifSettingGlobalMentions*(self: LocalAccountSensitiveSettings, value: string) {.slot.} =
|
||||
setSettingsProp(self, LSS_KEY_NOTIF_SETTING_GLOBAL_MENTIONS, newQVariant(value)):
|
||||
self.notifSettingGlobalMentionsChanged()
|
||||
QtProperty[string] notifSettingGlobalMentions:
|
||||
read = getNotifSettingGlobalMentions
|
||||
write = setNotifSettingGlobalMentions
|
||||
notify = notifSettingGlobalMentionsChanged
|
||||
|
||||
proc notifSettingAllMessagesChanged*(self: LocalAccountSensitiveSettings) {.signal.}
|
||||
proc getNotifSettingAllMessages*(self: LocalAccountSensitiveSettings): string {.slot.} =
|
||||
getSettingsProp[string](self, LSS_KEY_NOTIF_SETTING_ALL_MESSAGES, newQVariant(DEFAULT_NOTIF_SETTING_ALL_MESSAGES))
|
||||
proc setNotifSettingAllMessages*(self: LocalAccountSensitiveSettings, value: string) {.slot.} =
|
||||
setSettingsProp(self, LSS_KEY_NOTIF_SETTING_ALL_MESSAGES, newQVariant(value)):
|
||||
self.notifSettingAllMessagesChanged()
|
||||
QtProperty[string] notifSettingAllMessages:
|
||||
read = getNotifSettingAllMessages
|
||||
write = setNotifSettingAllMessages
|
||||
notify = notifSettingAllMessagesChanged
|
||||
|
||||
proc notifSettingContactRequestsChanged*(self: LocalAccountSensitiveSettings) {.signal.}
|
||||
proc getNotifSettingContactRequests*(self: LocalAccountSensitiveSettings): string {.slot.} =
|
||||
getSettingsProp[string](self, LSS_KEY_NOTIF_SETTING_CONTACT_REQUESTS, newQVariant(DEFAULT_NOTIF_SETTING_CONTACT_REQUESTS))
|
||||
proc setNotifSettingContactRequests*(self: LocalAccountSensitiveSettings, value: string) {.slot.} =
|
||||
setSettingsProp(self, LSS_KEY_NOTIF_SETTING_CONTACT_REQUESTS, newQVariant(value)):
|
||||
self.notifSettingContactRequestsChanged()
|
||||
QtProperty[string] notifSettingContactRequests:
|
||||
read = getNotifSettingContactRequests
|
||||
write = setNotifSettingContactRequests
|
||||
notify = notifSettingContactRequestsChanged
|
||||
|
||||
proc notifSettingIdentityVerificationRequestsChanged*(self: LocalAccountSensitiveSettings) {.signal.}
|
||||
proc getNotifSettingIdentityVerificationRequests*(self: LocalAccountSensitiveSettings): string {.slot.} =
|
||||
getSettingsProp[string](self, LSS_KEY_NOTIF_SETTING_IDENTITY_VERIF_REQUESTS, newQVariant(DEFAULT_NOTIF_SETTING_IDENTITY_VERIF_REQUESTS))
|
||||
proc setNotifSettingIdentityVerificationRequests*(self: LocalAccountSensitiveSettings, value: string) {.slot.} =
|
||||
setSettingsProp(self, LSS_KEY_NOTIF_SETTING_IDENTITY_VERIF_REQUESTS, newQVariant(value)):
|
||||
self.notifSettingIdentityVerificationRequestsChanged()
|
||||
QtProperty[string] notifSettingIdentityVerificationRequests:
|
||||
read = getNotifSettingIdentityVerificationRequests
|
||||
write = setNotifSettingIdentityVerificationRequests
|
||||
notify = notifSettingIdentityVerificationRequestsChanged
|
||||
|
||||
proc notifSettingExemptionsChanged*(self: LocalAccountSensitiveSettings) {.signal.}
|
||||
proc getNotifSettingExemptions*(self: LocalAccountSensitiveSettings): string {.slot.} =
|
||||
getSettingsProp[string](self, LSS_KEY_NOTIF_SETTING_EXEMPTIONS, newQVariant(DEFAULT_NOTIF_SETTING_EXEMPTIONS))
|
||||
proc setNotifSettingExemptions*(self: LocalAccountSensitiveSettings, value: string) {.slot.} =
|
||||
setSettingsProp(self, LSS_KEY_NOTIF_SETTING_EXEMPTIONS, newQVariant(value)):
|
||||
self.notifSettingExemptionsChanged()
|
||||
QtProperty[string] notifSettingExemptions:
|
||||
read = getNotifSettingExemptions
|
||||
write = setNotifSettingExemptions
|
||||
notify = notifSettingExemptionsChanged
|
||||
|
||||
proc getNotifSettingExemptionsAsJson*(self: LocalAccountSensitiveSettings): JsonNode =
|
||||
var allExemptions = newJObject()
|
||||
let exemptions = self.getNotifSettingExemptions()
|
||||
if(exemptions.len == 0):
|
||||
return allExemptions
|
||||
try:
|
||||
let exemptionsObj = exemptions.parseJson
|
||||
allExemptions = exemptionsObj
|
||||
except Exception as e:
|
||||
error "stored exemptions are corrupted, will be overwritten", msg=e.msg
|
||||
return allExemptions
|
||||
|
||||
proc removeKey*(self: LocalAccountSensitiveSettings, key: string) =
|
||||
if(self.settings.isNil):
|
||||
return
|
||||
|
@ -971,9 +786,6 @@ QtObject:
|
|||
of LSS_KEY_HIDDEN_COMMUNITY_WELCOME_BANNERS: self.hiddenCommunityWelcomeBannersChanged()
|
||||
of LSS_KEY_HIDDEN_COMMUNITY_CHANNELS_AND_CATEGORIES_BANNERS: self.hiddenCommunityChannelAndCategoriesBannersChanged()
|
||||
of LSS_KEY_HIDDEN_COMMUNITY_BACKUP_BANNERS: self.hiddenCommunityBackUpBannersChanged()
|
||||
of LSS_KEY_VOLUME: self.volumeChanged()
|
||||
of LSS_KEY_NOTIFICATION_SOUNDS_ENABLED: self.notificationSoundsEnabledChanged()
|
||||
of LSS_KEY_NOTIFICATION_MESSAGE_PREVIEW_SETTING: self.notificationMessagePreviewSettingChanged()
|
||||
of LSS_KEY_WITHLISTED_UNFURLING_SITES: self.whitelistedUnfurlingSitesChanged()
|
||||
of LSS_KEY_NEVER_ASK_ABOUT_UNFURLING_AGAIN: self.neverAskAboutUnfurlingAgainChanged()
|
||||
of LSS_KEY_HIDE_CHANNEL_SUGGESTIONS: self.hideChannelSuggestionsChanged()
|
||||
|
@ -1003,12 +815,3 @@ QtObject:
|
|||
of LSS_KEY_STICKERS_ENS_ROPSTEN: self.stickersEnsRopstenChanged()
|
||||
of LSS_KEY_IS_DDMMYY_DATE_FORMAT: self.isDDMMYYDateFormatChanged()
|
||||
of LSS_KEY_IS_24H_TIME_FORMAT: self.is24hTimeFormatChanged()
|
||||
of LSS_KEY_NOTIF_SETTING_ALLOW_NOTIFICATIONS: self.notifSettingAllowNotificationsChanged()
|
||||
of LSS_KEY_NOTIF_SETTING_ONE_TO_ONE_CHATS: self.notifSettingOneToOneChatsChanged()
|
||||
of LSS_KEY_NOTIF_SETTING_GROUP_CHATS: self.notifSettingGroupChatsChanged()
|
||||
of LSS_KEY_NOTIF_SETTING_PERSONAL_MENTIONS: self.notifSettingPersonalMentionsChanged()
|
||||
of LSS_KEY_NOTIF_SETTING_GLOBAL_MENTIONS: self.notifSettingGlobalMentionsChanged()
|
||||
of LSS_KEY_NOTIF_SETTING_ALL_MESSAGES: self.notifSettingAllMessagesChanged()
|
||||
of LSS_KEY_NOTIF_SETTING_CONTACT_REQUESTS: self.notifSettingContactRequestsChanged()
|
||||
of LSS_KEY_NOTIF_SETTING_IDENTITY_VERIF_REQUESTS: self.notifSettingIdentityVerificationRequestsChanged()
|
||||
of LSS_KEY_NOTIF_SETTING_EXEMPTIONS: self.notifSettingExemptionsChanged()
|
|
@ -84,7 +84,7 @@ proc newModule*(delegate: delegate_interface.AccessInterface,
|
|||
result.advancedModule = advanced_module.newModule(result, events, settingsService, stickersService, nodeConfigurationService)
|
||||
result.devicesModule = devices_module.newModule(result, events, settingsService, devicesService)
|
||||
result.syncModule = sync_module.newModule(result, events, settingsService, mailserversService)
|
||||
result.notificationsModule = notifications_module.newModule(result, events, chatService, contactsService)
|
||||
result.notificationsModule = notifications_module.newModule(result, events, settingsService, chatService, contactsService)
|
||||
result.ensUsernamesModule = ens_usernames_module.newModule(
|
||||
result, events, settingsService, ensService, walletAccountService
|
||||
)
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import Tables, chronicles
|
||||
import Tables, chronicles, json
|
||||
import io_interface
|
||||
|
||||
import ../../../../global/app_signals
|
||||
import ../../../../core/eventemitter
|
||||
import ../../../../../app_service/service/settings/service as settings_service
|
||||
import ../../../../../app_service/service/chat/service as chat_service
|
||||
import ../../../../../app_service/service/contacts/service as contact_service
|
||||
import ../../../../../app_service/service/community/service as community_service
|
||||
|
@ -14,16 +15,19 @@ type
|
|||
Controller* = ref object of RootObj
|
||||
delegate: io_interface.AccessInterface
|
||||
events: EventEmitter
|
||||
settingsService: settings_service.Service
|
||||
chatService: chat_service.Service
|
||||
contactService: contact_service.Service
|
||||
|
||||
proc newController*(delegate: io_interface.AccessInterface,
|
||||
events: EventEmitter,
|
||||
settingsService: settings_service.Service,
|
||||
chatService: chat_service.Service,
|
||||
contactService: contact_service.Service): Controller =
|
||||
result = Controller()
|
||||
result.delegate = delegate
|
||||
result.events = events
|
||||
result.settingsService = settingsService
|
||||
result.chatService = chatService
|
||||
result.contactService = contactService
|
||||
|
||||
|
@ -88,6 +92,15 @@ proc init*(self: Controller) =
|
|||
let args = ChatExtArgs(e)
|
||||
self.delegate.addChat(args.chatId)
|
||||
|
||||
proc getNotifSettingExemptions*(self: Controller, id: string): NotificationsExemptions =
|
||||
return self.settingsService.getNotifSettingExemptions(id)
|
||||
|
||||
proc setNotifSettingExemptions*(self: Controller, id: string, exemptions: NotificationsExemptions): bool =
|
||||
return self.settingsService.setNotifSettingExemptions(id, exemptions)
|
||||
|
||||
proc removeNotifSettingExemptions*(self: Controller, id: string): bool =
|
||||
return self.settingsService.removeNotifSettingExemptions(id)
|
||||
|
||||
proc getChannelGroups*(self: Controller): seq[ChannelGroupDto] =
|
||||
return self.chatService.getChannelGroups()
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import ../../../../global/local_account_sensitive_settings
|
||||
import ../../../../../app_service/service/settings/dto/settings
|
||||
|
||||
type
|
||||
Type* {.pure.} = enum
|
||||
|
@ -20,8 +20,8 @@ type
|
|||
otherMessages: string
|
||||
|
||||
proc initItem*(id, name, image, color: string, joinedTimestamp: int64, itemType: Type, muteAllMessages = false,
|
||||
personalMentions = LSS_VALUE_NOTIF_SEND_ALERTS, globalMentions = LSS_VALUE_NOTIF_SEND_ALERTS,
|
||||
otherMessages = LSS_VALUE_NOTIF_SEND_TURN_OFF): Item =
|
||||
personalMentions = VALUE_NOTIF_SEND_ALERTS, globalMentions = VALUE_NOTIF_SEND_ALERTS,
|
||||
otherMessages = VALUE_NOTIF_TURN_OFF): Item =
|
||||
result = Item()
|
||||
result.id = id
|
||||
result.name = name
|
||||
|
@ -57,9 +57,9 @@ proc itemType*(self: Item): Type =
|
|||
|
||||
proc customized*(self: Item): bool =
|
||||
return self.muteAllMessages or
|
||||
self.personalMentions != LSS_VALUE_NOTIF_SEND_ALERTS or
|
||||
self.globalMentions != LSS_VALUE_NOTIF_SEND_ALERTS or
|
||||
self.otherMessages != LSS_VALUE_NOTIF_SEND_TURN_OFF
|
||||
self.personalMentions != VALUE_NOTIF_SEND_ALERTS or
|
||||
self.globalMentions != VALUE_NOTIF_SEND_ALERTS or
|
||||
self.otherMessages != VALUE_NOTIF_TURN_OFF
|
||||
|
||||
proc muteAllMessages*(self: Item): bool =
|
||||
return self.muteAllMessages
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import NimQml, Tables
|
||||
import item
|
||||
|
||||
import ../../../../global/local_account_sensitive_settings
|
||||
import ../../../../../app_service/service/settings/dto/settings
|
||||
|
||||
type
|
||||
ModelRole {.pure.} = enum
|
||||
|
@ -145,8 +145,8 @@ QtObject:
|
|||
for i in 0 ..< self.items.len:
|
||||
yield self.items[i]
|
||||
|
||||
proc updateExemptions*(self: Model, id: string, muteAllMessages = false, personalMentions = LSS_VALUE_NOTIF_SEND_ALERTS,
|
||||
globalMentions = LSS_VALUE_NOTIF_SEND_ALERTS, otherMessages = LSS_VALUE_NOTIF_SEND_TURN_OFF) =
|
||||
proc updateExemptions*(self: Model, id: string, muteAllMessages = false, personalMentions = VALUE_NOTIF_SEND_ALERTS,
|
||||
globalMentions = VALUE_NOTIF_SEND_ALERTS, otherMessages = VALUE_NOTIF_TURN_OFF) =
|
||||
let ind = self.findIndexForItemId(id)
|
||||
if(ind == -1):
|
||||
return
|
||||
|
|
|
@ -6,6 +6,7 @@ import view, controller, model, item
|
|||
import ../../../../global/app_signals
|
||||
import ../../../../global/global_singleton
|
||||
import ../../../../core/eventemitter
|
||||
import ../../../../../app_service/service/settings/service as settings_service
|
||||
import ../../../../../app_service/service/chat/service as chat_service
|
||||
import ../../../../../app_service/service/contacts/service as contact_service
|
||||
from ../../../../../app_service/service/community/dto/community import CommunityDto
|
||||
|
@ -25,13 +26,14 @@ type
|
|||
|
||||
proc newModule*(delegate: delegate_interface.AccessInterface,
|
||||
events: EventEmitter,
|
||||
settingsService: settings_service.Service,
|
||||
chatService: chat_service.Service,
|
||||
contactService: contact_service.Service): Module =
|
||||
result = Module()
|
||||
result.delegate = delegate
|
||||
result.view = view.newView(result)
|
||||
result.viewVariant = newQVariant(result.view)
|
||||
result.controller = controller.newController(result, events, chatService, contactService)
|
||||
result.controller = controller.newController(result, events, settingsService, chatService, contactService)
|
||||
result.moduleLoaded = false
|
||||
|
||||
method delete*(self: Module) =
|
||||
|
@ -52,18 +54,9 @@ method isLoaded*(self: Module): bool =
|
|||
return self.moduleLoaded
|
||||
|
||||
proc createItem(self: Module, id, name, image, color: string, joinedTimestamp: int64, itemType: Type): Item =
|
||||
let allExemptions = singletonInstance.localAccountSensitiveSettings.getNotifSettingExemptionsAsJson()
|
||||
var item = initItem(id, name, image, color, joinedTimestamp, itemType)
|
||||
if(allExemptions.contains(id)):
|
||||
let obj = allExemptions[id]
|
||||
if(obj.contains(EXEMPTION_KEY_MUTE_ALL_MESSAGES)):
|
||||
item.muteAllMessages = obj[EXEMPTION_KEY_MUTE_ALL_MESSAGES].getBool
|
||||
if(obj.contains(EXEMPTION_KEY_PERSONAL_MENTIONS)):
|
||||
item.personalMentions = obj[EXEMPTION_KEY_PERSONAL_MENTIONS].getStr
|
||||
if(obj.contains(EXEMPTION_KEY_GLOBAL_MENTIONS)):
|
||||
item.globalMentions = obj[EXEMPTION_KEY_GLOBAL_MENTIONS].getStr
|
||||
if(obj.contains(EXEMPTION_KEY_OTHER_MESSAGES)):
|
||||
item.otherMessages = obj[EXEMPTION_KEY_OTHER_MESSAGES].getStr
|
||||
let exemptions = self.controller.getNotifSettingExemptions(id)
|
||||
var item = initItem(id, name, image, color, joinedTimestamp, itemType, exemptions.muteAllMessages,
|
||||
exemptions.personalMentions, exemptions.globalMentions, exemptions.otherMessages)
|
||||
return item
|
||||
|
||||
proc createChatItem(self: Module, chatDto: ChatDto): Item =
|
||||
|
@ -111,18 +104,13 @@ method sendTestNotification*(self: Module, title: string, message: string) =
|
|||
|
||||
method saveExemptions*(self: Module, itemId: string, muteAllMessages: bool, personalMentions: string,
|
||||
globalMentions: string, otherMessages: string) =
|
||||
var allExemptions = singletonInstance.localAccountSensitiveSettings.getNotifSettingExemptionsAsJson()
|
||||
allExemptions[itemId] = %* {
|
||||
EXEMPTION_KEY_MUTE_ALL_MESSAGES: muteAllMessages,
|
||||
EXEMPTION_KEY_PERSONAL_MENTIONS: personalMentions,
|
||||
EXEMPTION_KEY_GLOBAL_MENTIONS: globalMentions,
|
||||
EXEMPTION_KEY_OTHER_MESSAGES: otherMessages
|
||||
}
|
||||
|
||||
let exemptions = NotificationsExemptions(muteAllMessages: muteAllMessages,
|
||||
personalMentions: personalMentions,
|
||||
globalMentions: globalMentions,
|
||||
otherMessages: otherMessages)
|
||||
if(self.controller.setNotifSettingExemptions(itemId, exemptions)):
|
||||
self.view.exemptionsModel().updateExemptions(itemId, muteAllMessages, personalMentions, globalMentions, otherMessages)
|
||||
|
||||
singletonInstance.localAccountSensitiveSettings.setNotifSettingExemptions($allExemptions)
|
||||
|
||||
method onToggleSection*(self: Module, sectionType: SectionType) =
|
||||
if(sectionType != SectionType.Community):
|
||||
return
|
||||
|
@ -137,14 +125,9 @@ method onToggleSection*(self: Module, sectionType: SectionType) =
|
|||
let item = self.createItem(cg.id, cg.name, cg.images.thumbnail, cg.color, joinedTimestamp = 0, item.Type.Community)
|
||||
self.view.exemptionsModel().addItem(item)
|
||||
else:
|
||||
var allExemptions = singletonInstance.localAccountSensitiveSettings.getNotifSettingExemptionsAsJson()
|
||||
for item in self.view.exemptionsModel().modelIterator():
|
||||
if(item.itemType != Type.Community):
|
||||
continue
|
||||
if(allExemptions.contains(item.id)):
|
||||
allExemptions.delete(item.id)
|
||||
if(item.itemType == Type.Community and self.controller.removeNotifSettingExemptions(item.id)):
|
||||
self.view.exemptionsModel().removeItemById(item.id)
|
||||
singletonInstance.localAccountSensitiveSettings.setNotifSettingExemptions($allExemptions)
|
||||
|
||||
method addCommunity*(self: Module, communityDto: CommunityDto) =
|
||||
let ind = self.view.exemptionsModel().findIndexForItemId(communityDto.id)
|
||||
|
@ -161,10 +144,7 @@ method editCommunity*(self: Module, communityDto: CommunityDto) =
|
|||
self.view.exemptionsModel().addItem(item)
|
||||
|
||||
method removeItemWithId*(self: Module, itemId: string) =
|
||||
var allExemptions = singletonInstance.localAccountSensitiveSettings.getNotifSettingExemptionsAsJson()
|
||||
if(allExemptions.contains(itemId)):
|
||||
allExemptions.delete(itemId)
|
||||
singletonInstance.localAccountSensitiveSettings.setNotifSettingExemptions($allExemptions)
|
||||
if(self.controller.removeNotifSettingExemptions(itemId)):
|
||||
self.view.exemptionsModel().removeItemById(itemId)
|
||||
|
||||
method addChat*(self: Module, chatDto: ChatDto) =
|
||||
|
|
|
@ -47,10 +47,21 @@ const KEY_GIF_API_KEY* = "gifs/api-key"
|
|||
const KEY_DISPLAY_NAME* = "display-name"
|
||||
const KEY_TEST_NETWORKS_ENABLED* = "test-networks-enabled?"
|
||||
|
||||
# Notifications Settings Values
|
||||
const VALUE_NOTIF_SEND_ALERTS* = "SendAlerts"
|
||||
const VALUE_NOTIF_DELIVER_QUIETLY* = "DeliverQuietly"
|
||||
const VALUE_NOTIF_TURN_OFF* = "TurnOff"
|
||||
|
||||
const PROFILE_PICTURES_VISIBILITY_CONTACTS_ONLY* = 1
|
||||
const PROFILE_PICTURES_VISIBILITY_EVERYONE* = 2
|
||||
const PROFILE_PICTURES_VISIBILITY_NO_ONE* = 3
|
||||
|
||||
type NotificationsExemptions* = object
|
||||
muteAllMessages*: bool
|
||||
personalMentions*: string
|
||||
globalMentions*: string
|
||||
otherMessages*: string
|
||||
|
||||
type UpstreamConfig* = object
|
||||
Enabled*: bool
|
||||
URL*: string
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import chronicles, json, strutils, sequtils, tables, sugar
|
||||
import NimQml, chronicles, json, strutils, sequtils, tables, sugar
|
||||
|
||||
import ../../common/[network_constants]
|
||||
import ../../../app/core/fleets/fleet_configuration
|
||||
|
@ -22,114 +22,118 @@ const DEFAULT_FLEET* = $Fleet.Prod
|
|||
logScope:
|
||||
topics = "settings-service"
|
||||
|
||||
type
|
||||
Service* = ref object of RootObj
|
||||
QtObject:
|
||||
type Service* = ref object of QObject
|
||||
settings: SettingsDto
|
||||
eip1559Enabled*: bool
|
||||
|
||||
proc delete*(self: Service) =
|
||||
discard
|
||||
proc delete*(self: Service) =
|
||||
self.QObject.delete
|
||||
|
||||
proc newService*(): Service =
|
||||
result = Service()
|
||||
proc newService*(): Service =
|
||||
new(result, delete)
|
||||
result.QObject.setup
|
||||
result.eip1559Enabled = false
|
||||
|
||||
proc init*(self: Service) =
|
||||
proc init*(self: Service) =
|
||||
try:
|
||||
let response = status_settings.getSettings()
|
||||
self.settings = response.result.toSettingsDto()
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "error: ", errDesription
|
||||
return
|
||||
|
||||
proc saveSetting(self: Service, attribute: string, value: string | JsonNode | bool | int): bool =
|
||||
proc saveSetting(self: Service, attribute: string, value: string | JsonNode | bool | int): bool =
|
||||
try:
|
||||
let response = status_settings.saveSettings(attribute, value)
|
||||
if(not response.error.isNil):
|
||||
error "error saving settings: ", errDescription = response.error.message
|
||||
return false
|
||||
|
||||
return true
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "saving settings error: ", errDesription
|
||||
return false
|
||||
|
||||
proc saveAddress*(self: Service, value: string): bool =
|
||||
proc saveAddress*(self: Service, value: string): bool =
|
||||
if(self.saveSetting(KEY_ADDRESS, value)):
|
||||
self.settings.address = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc getAddress*(self: Service): string =
|
||||
proc getAddress*(self: Service): string =
|
||||
return self.settings.address
|
||||
|
||||
proc saveCurrency*(self: Service, value: string): bool =
|
||||
proc saveCurrency*(self: Service, value: string): bool =
|
||||
if(self.saveSetting(KEY_CURRENCY, value)):
|
||||
self.settings.currency = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc getCurrency*(self: Service): string =
|
||||
proc getCurrency*(self: Service): string =
|
||||
if(self.settings.currency.len == 0):
|
||||
self.settings.currency = DEFAULT_CURRENCY
|
||||
|
||||
return self.settings.currency
|
||||
|
||||
proc saveCurrentNetwork*(self: Service, value: string): bool =
|
||||
proc saveCurrentNetwork*(self: Service, value: string): bool =
|
||||
if(self.saveSetting(KEY_NETWORKS_CURRENT_NETWORK, value)):
|
||||
self.settings.currentNetwork = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc getCurrentNetwork*(self: Service): string =
|
||||
proc getCurrentNetwork*(self: Service): string =
|
||||
if(self.settings.currentNetwork.len == 0):
|
||||
self.settings.currentNetwork = DEFAULT_CURRENT_NETWORK
|
||||
|
||||
return self.settings.currentNetwork
|
||||
|
||||
proc saveDappsAddress*(self: Service, value: string): bool =
|
||||
proc saveDappsAddress*(self: Service, value: string): bool =
|
||||
if(self.saveSetting(KEY_DAPPS_ADDRESS, value)):
|
||||
self.settings.dappsAddress = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc getDappsAddress*(self: Service): string =
|
||||
proc getDappsAddress*(self: Service): string =
|
||||
return self.settings.dappsAddress
|
||||
|
||||
proc saveEip1581Address*(self: Service, value: string): bool =
|
||||
proc saveEip1581Address*(self: Service, value: string): bool =
|
||||
if(self.saveSetting(KEY_EIP1581_ADDRESS, value)):
|
||||
self.settings.eip1581Address = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc getEip1581Address*(self: Service): string =
|
||||
proc getEip1581Address*(self: Service): string =
|
||||
return self.settings.eip1581Address
|
||||
|
||||
proc saveInstallationId*(self: Service, value: string): bool =
|
||||
proc saveInstallationId*(self: Service, value: string): bool =
|
||||
if(self.saveSetting(KEY_INSTALLATION_ID, value)):
|
||||
self.settings.installationId = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc getInstallationId*(self: Service): string =
|
||||
proc getInstallationId*(self: Service): string =
|
||||
return self.settings.installationId
|
||||
|
||||
proc savePreferredName*(self: Service, value: string): bool =
|
||||
proc savePreferredName*(self: Service, value: string): bool =
|
||||
if(self.saveSetting(KEY_PREFERRED_NAME, value)):
|
||||
self.settings.preferredName = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc getPreferredName*(self: Service): string =
|
||||
proc getPreferredName*(self: Service): string =
|
||||
return self.settings.preferredName
|
||||
|
||||
proc getDisplayName*(self: Service): string =
|
||||
proc getDisplayName*(self: Service): string =
|
||||
return self.settings.displayName
|
||||
|
||||
proc saveDisplayName*(self: Service, value: string): bool =
|
||||
proc saveDisplayName*(self: Service, value: string): bool =
|
||||
if(self.saveSetting(KEY_DISPLAY_NAME, value)):
|
||||
self.settings.displayName = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc saveNewEnsUsername*(self: Service, username: string): bool =
|
||||
proc saveNewEnsUsername*(self: Service, username: string): bool =
|
||||
var newEnsUsernames = self.settings.ensUsernames
|
||||
newEnsUsernames.add(username)
|
||||
let newEnsUsernamesAsJson = %* newEnsUsernames
|
||||
|
@ -139,163 +143,175 @@ proc saveNewEnsUsername*(self: Service, username: string): bool =
|
|||
return true
|
||||
return false
|
||||
|
||||
proc getEnsUsernames*(self: Service): seq[string] =
|
||||
proc getEnsUsernames*(self: Service): seq[string] =
|
||||
return self.settings.ensUsernames
|
||||
|
||||
proc saveKeyUid*(self: Service, value: string): bool =
|
||||
proc saveKeyUid*(self: Service, value: string): bool =
|
||||
if(self.saveSetting(KEY_KEY_UID, value)):
|
||||
self.settings.keyUid = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc getKeyUid*(self: Service): string =
|
||||
proc getKeyUid*(self: Service): string =
|
||||
return self.settings.keyUid
|
||||
|
||||
proc saveLatestDerivedPath*(self: Service, value: int): bool =
|
||||
proc saveLatestDerivedPath*(self: Service, value: int): bool =
|
||||
if(self.saveSetting(KEY_LATEST_DERIVED_PATH, value)):
|
||||
self.settings.latestDerivedPath = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc getLatestDerivedPath*(self: Service): int =
|
||||
proc getLatestDerivedPath*(self: Service): int =
|
||||
self.settings.latestDerivedPath
|
||||
|
||||
proc saveLinkPreviewRequestEnabled*(self: Service, value: bool): bool =
|
||||
proc saveLinkPreviewRequestEnabled*(self: Service, value: bool): bool =
|
||||
if(self.saveSetting(KEY_LINK_PREVIEW_REQUEST_ENABLED, value)):
|
||||
self.settings.linkPreviewRequestEnabled = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc getLinkPreviewRequestEnabled*(self: Service): bool =
|
||||
proc getLinkPreviewRequestEnabled*(self: Service): bool =
|
||||
self.settings.linkPreviewRequestEnabled
|
||||
|
||||
proc saveMessagesFromContactsOnly*(self: Service, value: bool): bool =
|
||||
proc saveMessagesFromContactsOnly*(self: Service, value: bool): bool =
|
||||
if(self.saveSetting(KEY_MESSAGES_FROM_CONTACTS_ONLY, value)):
|
||||
self.settings.messagesFromContactsOnly = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc getMessagesFromContactsOnly*(self: Service): bool =
|
||||
proc getMessagesFromContactsOnly*(self: Service): bool =
|
||||
self.settings.messagesFromContactsOnly
|
||||
|
||||
proc saveMnemonic*(self: Service, value: string): bool =
|
||||
proc saveMnemonic*(self: Service, value: string): bool =
|
||||
if(self.saveSetting(KEY_MNEMONIC, value)):
|
||||
self.settings.mnemonic = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc getMnemonic*(self: Service): string =
|
||||
proc getMnemonic*(self: Service): string =
|
||||
return self.settings.mnemonic
|
||||
|
||||
proc saveName*(self: Service, value: string): bool =
|
||||
proc saveName*(self: Service, value: string): bool =
|
||||
if(self.saveSetting(KEY_NAME, value)):
|
||||
self.settings.name = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc getName*(self: Service): string =
|
||||
proc getName*(self: Service): string =
|
||||
return self.settings.name
|
||||
|
||||
proc savePhotoPath*(self: Service, value: string): bool =
|
||||
proc savePhotoPath*(self: Service, value: string): bool =
|
||||
if(self.saveSetting(KEY_PHOTO_PATH, value)):
|
||||
self.settings.photoPath = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc getPhotoPath*(self: Service): string =
|
||||
proc getPhotoPath*(self: Service): string =
|
||||
return self.settings.photoPath
|
||||
|
||||
proc savePreviewPrivacy*(self: Service, value: bool): bool =
|
||||
proc savePreviewPrivacy*(self: Service, value: bool): bool =
|
||||
if(self.saveSetting(KEY_PREVIEW_PRIVACY, value)):
|
||||
self.settings.previewPrivacy = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc getPreviewPrivacy*(self: Service): bool =
|
||||
proc getPreviewPrivacy*(self: Service): bool =
|
||||
self.settings.previewPrivacy
|
||||
|
||||
proc savePublicKey*(self: Service, value: string): bool =
|
||||
proc savePublicKey*(self: Service, value: string): bool =
|
||||
if(self.saveSetting(KEY_PUBLIC_KEY, value)):
|
||||
self.settings.publicKey = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc getPublicKey*(self: Service): string =
|
||||
proc getPublicKey*(self: Service): string =
|
||||
return self.settings.publicKey
|
||||
|
||||
proc saveSigningPhrase*(self: Service, value: string): bool =
|
||||
proc saveSigningPhrase*(self: Service, value: string): bool =
|
||||
if(self.saveSetting(KEY_SIGNING_PHRASE, value)):
|
||||
self.settings.signingPhrase = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc getSigningPhrase*(self: Service): string =
|
||||
proc getSigningPhrase*(self: Service): string =
|
||||
return self.settings.signingPhrase
|
||||
|
||||
proc saveDefaultSyncPeriod*(self: Service, value: int): bool =
|
||||
proc saveDefaultSyncPeriod*(self: Service, value: int): bool =
|
||||
if(self.saveSetting(KEY_DEFAULT_SYNC_PERIOD, value)):
|
||||
self.settings.defaultSyncPeriod = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc getDefaultSyncPeriod*(self: Service): int =
|
||||
proc getDefaultSyncPeriod*(self: Service): int =
|
||||
self.settings.defaultSyncPeriod
|
||||
|
||||
proc saveSendPushNotifications*(self: Service, value: bool): bool =
|
||||
proc saveSendPushNotifications*(self: Service, value: bool): bool =
|
||||
if(self.saveSetting(KEY_SEND_PUSH_NOTIFICATIONS, value)):
|
||||
self.settings.sendPushNotifications = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc getSendPushNotifications*(self: Service): bool =
|
||||
proc getSendPushNotifications*(self: Service): bool =
|
||||
self.settings.sendPushNotifications
|
||||
|
||||
proc saveAppearance*(self: Service, value: int): bool =
|
||||
proc saveAppearance*(self: Service, value: int): bool =
|
||||
if(self.saveSetting(KEY_APPEARANCE, value)):
|
||||
self.settings.appearance = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc getAppearance*(self: Service): int =
|
||||
proc getAppearance*(self: Service): int =
|
||||
self.settings.appearance
|
||||
|
||||
proc saveProfilePicturesShowTo*(self: Service, value: int): bool =
|
||||
proc saveProfilePicturesShowTo*(self: Service, value: int): bool =
|
||||
if(self.saveSetting(KEY_PROFILE_PICTURES_SHOW_TO, value)):
|
||||
self.settings.profilePicturesShowTo = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc getProfilePicturesShowTo*(self: Service): int =
|
||||
proc getProfilePicturesShowTo*(self: Service): int =
|
||||
self.settings.profilePicturesShowTo
|
||||
|
||||
proc saveProfilePicturesVisibility*(self: Service, value: int): bool =
|
||||
proc saveProfilePicturesVisibility*(self: Service, value: int): bool =
|
||||
if(self.saveSetting(KEY_PROFILE_PICTURES_VISIBILITY, value)):
|
||||
self.settings.profilePicturesVisibility = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc getProfilePicturesVisibility*(self: Service): int =
|
||||
proc getProfilePicturesVisibility*(self: Service): int =
|
||||
self.settings.profilePicturesVisibility
|
||||
|
||||
proc saveUseMailservers*(self: Service, value: bool): bool =
|
||||
proc saveUseMailservers*(self: Service, value: bool): bool =
|
||||
if(self.saveSetting(KEY_USE_MAILSERVERS, value)):
|
||||
self.settings.useMailservers = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc getUseMailservers*(self: Service): bool =
|
||||
proc getUseMailservers*(self: Service): bool =
|
||||
self.settings.useMailservers
|
||||
|
||||
proc saveWalletRootAddress*(self: Service, value: string): bool =
|
||||
proc saveWalletRootAddress*(self: Service, value: string): bool =
|
||||
if(self.saveSetting(KEY_WALLET_ROOT_ADDRESS, value)):
|
||||
self.settings.walletRootAddress = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc getWalletRootAddress*(self: Service): string =
|
||||
proc getWalletRootAddress*(self: Service): string =
|
||||
return self.settings.walletRootAddress
|
||||
|
||||
proc saveSendStatusUpdates*(self: Service, value: bool): bool =
|
||||
proc getSendStatusUpdates*(self: Service): bool =
|
||||
self.settings.sendStatusUpdates
|
||||
|
||||
proc saveTelemetryServerUrl*(self: Service, value: string): bool =
|
||||
if(self.saveSetting(KEY_TELEMETRY_SERVER_URL, value)):
|
||||
self.settings.telemetryServerUrl = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc getTelemetryServerUrl*(self: Service): string =
|
||||
return self.settings.telemetryServerUrl
|
||||
|
||||
proc saveSendStatusUpdates*(self: Service, value: bool): bool =
|
||||
var newStatus = StatusType.Online
|
||||
if not value:
|
||||
newStatus = StatusType.Offline
|
||||
|
@ -309,39 +325,27 @@ proc saveSendStatusUpdates*(self: Service, value: bool): bool =
|
|||
except:
|
||||
return false
|
||||
|
||||
proc getSendStatusUpdates*(self: Service): bool =
|
||||
self.settings.sendStatusUpdates
|
||||
|
||||
proc saveTelemetryServerUrl*(self: Service, value: string): bool =
|
||||
if(self.saveSetting(KEY_TELEMETRY_SERVER_URL, value)):
|
||||
self.settings.telemetryServerUrl = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc getTelemetryServerUrl*(self: Service): string =
|
||||
return self.settings.telemetryServerUrl
|
||||
|
||||
method saveFleet*(self: Service, value: string): bool =
|
||||
proc saveFleet*(self: Service, value: string): bool =
|
||||
self.settings.fleet = value
|
||||
return true
|
||||
|
||||
proc getFleetAsString*(self: Service): string =
|
||||
proc getFleetAsString*(self: Service): string =
|
||||
if(self.settings.fleet.len == 0):
|
||||
self.settings.fleet = DEFAULT_FLEET
|
||||
return self.settings.fleet
|
||||
|
||||
proc getFleet*(self: Service): Fleet =
|
||||
proc getFleet*(self: Service): Fleet =
|
||||
let fleetAsString = self.getFleetAsString()
|
||||
let fleet = parseEnum[Fleet](fleetAsString)
|
||||
return fleet
|
||||
|
||||
proc getAvailableNetworks*(self: Service): seq[Network] =
|
||||
proc getAvailableNetworks*(self: Service): seq[Network] =
|
||||
return self.settings.availableNetworks
|
||||
|
||||
proc getAvailableCustomNetworks*(self: Service): seq[Network] =
|
||||
proc getAvailableCustomNetworks*(self: Service): seq[Network] =
|
||||
return self.settings.availableNetworks.filterIt(it.id notin DEFAULT_NETWORKS_IDS)
|
||||
|
||||
proc getCurrentNetworkDetails*(self: Service): Network =
|
||||
proc getCurrentNetworkDetails*(self: Service): Network =
|
||||
for n in self.settings.availableNetworks:
|
||||
if(n.id == self.getCurrentNetwork()):
|
||||
return n
|
||||
|
@ -349,7 +353,7 @@ proc getCurrentNetworkDetails*(self: Service): Network =
|
|||
# we should never be here
|
||||
error "error: current network is not among available networks"
|
||||
|
||||
proc addCustomNetwork*(self: Service, network: Network): bool =
|
||||
proc addCustomNetwork*(self: Service, network: Network): bool =
|
||||
var newAvailableNetworks = self.settings.availableNetworks
|
||||
newAvailableNetworks.add(network)
|
||||
let availableNetworksAsJson = availableNetworksToJsonNode(newAvailableNetworks)
|
||||
|
@ -359,13 +363,13 @@ proc addCustomNetwork*(self: Service, network: Network): bool =
|
|||
return true
|
||||
return false
|
||||
|
||||
proc getCurrentNetworkId*(self: Service): int =
|
||||
proc getCurrentNetworkId*(self: Service): int =
|
||||
self.getCurrentNetworkDetails().config.NetworkId
|
||||
|
||||
proc getCurrentUserStatus*(self: Service): CurrentUserStatus =
|
||||
proc getCurrentUserStatus*(self: Service): CurrentUserStatus =
|
||||
self.settings.currentUserStatus
|
||||
|
||||
proc getPinnedMailserver*(self: Service, fleet: Fleet): string =
|
||||
proc getPinnedMailserver*(self: Service, fleet: Fleet): string =
|
||||
if (fleet == Fleet.Prod):
|
||||
return self.settings.pinnedMailserver.ethProd
|
||||
elif (fleet == Fleet.Staging):
|
||||
|
@ -384,7 +388,7 @@ proc getPinnedMailserver*(self: Service, fleet: Fleet): string =
|
|||
return self.settings.pinnedMailserver.statusProd
|
||||
return ""
|
||||
|
||||
proc pinMailserver*(self: Service, address: string, fleet: Fleet): bool =
|
||||
proc pinMailserver*(self: Service, address: string, fleet: Fleet): bool =
|
||||
var newMailserverJsonObj = self.settings.pinnedMailserver.pinnedMailserverToJsonNode()
|
||||
newMailserverJsonObj[$fleet] = %* address
|
||||
if(self.saveSetting(KEY_PINNED_MAILSERVERS, newMailserverJsonObj)):
|
||||
|
@ -407,10 +411,10 @@ proc pinMailserver*(self: Service, address: string, fleet: Fleet): bool =
|
|||
return true
|
||||
return false
|
||||
|
||||
proc unpinMailserver*(self: Service, fleet: Fleet): bool =
|
||||
proc unpinMailserver*(self: Service, fleet: Fleet): bool =
|
||||
return self.pinMailserver("", fleet)
|
||||
|
||||
proc isEIP1559Enabled*(self: Service, blockNumber: int): bool =
|
||||
proc isEIP1559Enabled*(self: Service, blockNumber: int): bool =
|
||||
let networkId = self.getCurrentNetworkDetails().config.NetworkId
|
||||
let activationBlock = case networkId:
|
||||
of 3: 10499401 # Ropsten
|
||||
|
@ -424,41 +428,419 @@ proc isEIP1559Enabled*(self: Service, blockNumber: int): bool =
|
|||
result = false
|
||||
self.eip1559Enabled = result
|
||||
|
||||
proc isEIP1559Enabled*(self: Service): bool =
|
||||
proc isEIP1559Enabled*(self: Service): bool =
|
||||
result = self.eip1559Enabled
|
||||
|
||||
proc saveNodeConfiguration*(self: Service, value: JsonNode): bool =
|
||||
proc saveNodeConfiguration*(self: Service, value: JsonNode): bool =
|
||||
if(self.saveSetting(KEY_NODE_CONFIG, value)):
|
||||
self.settings.nodeConfig = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc saveWakuBloomFilterMode*(self: Service, value: bool): bool =
|
||||
proc saveWakuBloomFilterMode*(self: Service, value: bool): bool =
|
||||
if(self.saveSetting(KEY_WAKU_BLOOM_FILTER_MODE, value)):
|
||||
self.settings.wakuBloomFilterMode = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc saveAutoMessageEnabled*(self: Service, value: bool): bool =
|
||||
proc saveAutoMessageEnabled*(self: Service, value: bool): bool =
|
||||
if(self.saveSetting(KEY_AUTO_MESSAGE_ENABLED, value)):
|
||||
self.settings.autoMessageEnabled = value
|
||||
return true
|
||||
return false
|
||||
|
||||
proc autoMessageEnabled*(self: Service): bool =
|
||||
proc autoMessageEnabled*(self: Service): bool =
|
||||
return self.settings.autoMessageEnabled
|
||||
|
||||
proc getWakuBloomFilterMode*(self: Service): bool =
|
||||
proc getWakuBloomFilterMode*(self: Service): bool =
|
||||
return self.settings.wakuBloomFilterMode
|
||||
|
||||
method areTestNetworksEnabled*(self: Service): bool =
|
||||
proc areTestNetworksEnabled*(self: Service): bool =
|
||||
return self.settings.testNetworksEnabled
|
||||
|
||||
method toggleTestNetworksEnabled*(self: Service): bool =
|
||||
proc toggleTestNetworksEnabled*(self: Service): bool =
|
||||
let newValue = not self.settings.testNetworksEnabled
|
||||
if(self.saveSetting(KEY_TEST_NETWORKS_ENABLED, newValue)):
|
||||
self.settings.testNetworksEnabled = newValue
|
||||
return true
|
||||
return false
|
||||
|
||||
proc notifSettingAllowNotificationsChanged*(self: Service) {.signal.}
|
||||
proc getNotifSettingAllowNotifications*(self: Service): bool {.slot.} =
|
||||
result = true #default value
|
||||
try:
|
||||
let response = status_settings.getAllowNotifications()
|
||||
if(not response.error.isNil):
|
||||
error "error reading allow notification setting: ", errDescription = response.error.message
|
||||
return
|
||||
result = response.result.getBool
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "reading allow notification setting error: ", errDesription
|
||||
|
||||
proc setNotifSettingAllowNotifications*(self: Service, value: bool) {.slot.} =
|
||||
try:
|
||||
let response = status_settings.setAllowNotifications(value)
|
||||
if(not response.error.isNil):
|
||||
error "error saving allow notification setting: ", errDescription = response.error.message
|
||||
return
|
||||
self.notifSettingAllowNotificationsChanged()
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "saving allow notification setting error: ", errDesription
|
||||
|
||||
QtProperty[bool] notifSettingAllowNotifications:
|
||||
read = getNotifSettingAllowNotifications
|
||||
write = setNotifSettingAllowNotifications
|
||||
notify = notifSettingAllowNotificationsChanged
|
||||
|
||||
proc notifSettingOneToOneChatsChanged*(self: Service) {.signal.}
|
||||
proc getNotifSettingOneToOneChats*(self: Service): string {.slot.} =
|
||||
result = VALUE_NOTIF_SEND_ALERTS #default value
|
||||
try:
|
||||
let response = status_settings.getOneToOneChats()
|
||||
if(not response.error.isNil):
|
||||
error "error reading one to one setting: ", errDescription = response.error.message
|
||||
return
|
||||
result = response.result.getStr
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "reading one to one setting error: ", errDesription
|
||||
|
||||
proc setNotifSettingOneToOneChats*(self: Service, value: string) {.slot.} =
|
||||
try:
|
||||
let response = status_settings.setOneToOneChats(value)
|
||||
if(not response.error.isNil):
|
||||
error "error saving one to one setting: ", errDescription = response.error.message
|
||||
return
|
||||
self.notifSettingOneToOneChatsChanged()
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "saving one to one setting error: ", errDesription
|
||||
|
||||
QtProperty[string] notifSettingOneToOneChats:
|
||||
read = getNotifSettingOneToOneChats
|
||||
write = setNotifSettingOneToOneChats
|
||||
notify = notifSettingOneToOneChatsChanged
|
||||
|
||||
proc notifSettingGroupChatsChanged*(self: Service) {.signal.}
|
||||
proc getNotifSettingGroupChats*(self: Service): string {.slot.} =
|
||||
result = VALUE_NOTIF_SEND_ALERTS #default value
|
||||
try:
|
||||
let response = status_settings.getGroupChats()
|
||||
if(not response.error.isNil):
|
||||
error "error reading group chats setting: ", errDescription = response.error.message
|
||||
return
|
||||
result = response.result.getStr
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "reading group chats setting error: ", errDesription
|
||||
|
||||
proc setNotifSettingGroupChats*(self: Service, value: string) {.slot.} =
|
||||
try:
|
||||
let response = status_settings.setGroupChats(value)
|
||||
if(not response.error.isNil):
|
||||
error "error saving group chats setting: ", errDescription = response.error.message
|
||||
return
|
||||
self.notifSettingGroupChatsChanged()
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "saving group chats setting error: ", errDesription
|
||||
|
||||
QtProperty[string] notifSettingGroupChats:
|
||||
read = getNotifSettingGroupChats
|
||||
write = setNotifSettingGroupChats
|
||||
notify = notifSettingGroupChatsChanged
|
||||
|
||||
proc notifSettingPersonalMentionsChanged*(self: Service) {.signal.}
|
||||
proc getNotifSettingPersonalMentions*(self: Service): string {.slot.} =
|
||||
result = VALUE_NOTIF_SEND_ALERTS #default value
|
||||
try:
|
||||
let response = status_settings.getPersonalMentions()
|
||||
if(not response.error.isNil):
|
||||
error "error reading personal mentions setting: ", errDescription = response.error.message
|
||||
return
|
||||
result = response.result.getStr
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "reading personal mentions setting error: ", errDesription
|
||||
|
||||
proc setNotifSettingPersonalMentions*(self: Service, value: string) {.slot.} =
|
||||
try:
|
||||
let response = status_settings.setPersonalMentions(value)
|
||||
if(not response.error.isNil):
|
||||
error "error saving personal mentions setting: ", errDescription = response.error.message
|
||||
return
|
||||
self.notifSettingPersonalMentionsChanged()
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "saving personal mentions setting error: ", errDesription
|
||||
|
||||
QtProperty[string] notifSettingPersonalMentions:
|
||||
read = getNotifSettingPersonalMentions
|
||||
write = setNotifSettingPersonalMentions
|
||||
notify = notifSettingPersonalMentionsChanged
|
||||
|
||||
proc notifSettingGlobalMentionsChanged*(self: Service) {.signal.}
|
||||
proc getNotifSettingGlobalMentions*(self: Service): string {.slot.} =
|
||||
result = VALUE_NOTIF_SEND_ALERTS #default value
|
||||
try:
|
||||
let response = status_settings.getGlobalMentions()
|
||||
if(not response.error.isNil):
|
||||
error "error reading global mentions setting: ", errDescription = response.error.message
|
||||
return
|
||||
result = response.result.getStr
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "reading global mentions setting error: ", errDesription
|
||||
|
||||
proc setNotifSettingGlobalMentions*(self: Service, value: string) {.slot.} =
|
||||
try:
|
||||
let response = status_settings.setGlobalMentions(value)
|
||||
if(not response.error.isNil):
|
||||
error "error saving global mentions setting: ", errDescription = response.error.message
|
||||
return
|
||||
self.notifSettingGlobalMentionsChanged()
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "saving global mentions setting error: ", errDesription
|
||||
|
||||
QtProperty[string] notifSettingGlobalMentions:
|
||||
read = getNotifSettingGlobalMentions
|
||||
write = setNotifSettingGlobalMentions
|
||||
notify = notifSettingGlobalMentionsChanged
|
||||
|
||||
proc notifSettingAllMessagesChanged*(self: Service) {.signal.}
|
||||
proc getNotifSettingAllMessages*(self: Service): string {.slot.} =
|
||||
result = VALUE_NOTIF_TURN_OFF #default value
|
||||
try:
|
||||
let response = status_settings.getAllMessages()
|
||||
if(not response.error.isNil):
|
||||
error "error reading all messages setting: ", errDescription = response.error.message
|
||||
return
|
||||
result = response.result.getStr
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "reading all messages setting error: ", errDesription
|
||||
|
||||
proc setNotifSettingAllMessages*(self: Service, value: string) {.slot.} =
|
||||
try:
|
||||
let response = status_settings.setAllMessages(value)
|
||||
if(not response.error.isNil):
|
||||
error "error saving all messages setting: ", errDescription = response.error.message
|
||||
return
|
||||
self.notifSettingAllMessagesChanged()
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "saving all messages setting error: ", errDesription
|
||||
|
||||
QtProperty[string] notifSettingAllMessages:
|
||||
read = getNotifSettingAllMessages
|
||||
write = setNotifSettingAllMessages
|
||||
notify = notifSettingAllMessagesChanged
|
||||
|
||||
proc notifSettingContactRequestsChanged*(self: Service) {.signal.}
|
||||
proc getNotifSettingContactRequests*(self: Service): string {.slot.} =
|
||||
result = VALUE_NOTIF_SEND_ALERTS #default value
|
||||
try:
|
||||
let response = status_settings.getContactRequests()
|
||||
if(not response.error.isNil):
|
||||
error "error reading contact request setting: ", errDescription = response.error.message
|
||||
return
|
||||
result = response.result.getStr
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "reading contact request setting error: ", errDesription
|
||||
|
||||
proc setNotifSettingContactRequests*(self: Service, value: string) {.slot.} =
|
||||
try:
|
||||
let response = status_settings.setContactRequests(value)
|
||||
if(not response.error.isNil):
|
||||
error "error saving contact request setting: ", errDescription = response.error.message
|
||||
return
|
||||
self.notifSettingContactRequestsChanged()
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "saving contact request setting error: ", errDesription
|
||||
|
||||
QtProperty[string] notifSettingContactRequests:
|
||||
read = getNotifSettingContactRequests
|
||||
write = setNotifSettingContactRequests
|
||||
notify = notifSettingContactRequestsChanged
|
||||
|
||||
proc notifSettingIdentityVerificationRequestsChanged*(self: Service) {.signal.}
|
||||
proc getNotifSettingIdentityVerificationRequests*(self: Service): string {.slot.} =
|
||||
result = VALUE_NOTIF_SEND_ALERTS #default value
|
||||
try:
|
||||
let response = status_settings.getIdentityVerificationRequests()
|
||||
if(not response.error.isNil):
|
||||
error "error reading identity verification request setting: ", errDescription = response.error.message
|
||||
return
|
||||
result = response.result.getStr
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "reading identity verification request setting error: ", errDesription
|
||||
|
||||
proc setNotifSettingIdentityVerificationRequests*(self: Service, value: string) {.slot.} =
|
||||
try:
|
||||
let response = status_settings.setIdentityVerificationRequests(value)
|
||||
if(not response.error.isNil):
|
||||
error "error saving identity verification request setting: ", errDescription = response.error.message
|
||||
return
|
||||
self.notifSettingIdentityVerificationRequestsChanged()
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "saving identity verification request setting error: ", errDesription
|
||||
|
||||
QtProperty[string] notifSettingIdentityVerificationRequests:
|
||||
read = getNotifSettingIdentityVerificationRequests
|
||||
write = setNotifSettingIdentityVerificationRequests
|
||||
notify = notifSettingIdentityVerificationRequestsChanged
|
||||
|
||||
proc notificationSoundsEnabledChanged*(self: Service) {.signal.}
|
||||
proc getNotificationSoundsEnabled*(self: Service): bool {.slot.} =
|
||||
result = true #default value
|
||||
try:
|
||||
let response = status_settings.getSoundEnabled()
|
||||
if(not response.error.isNil):
|
||||
error "error reading sound enabled setting: ", errDescription = response.error.message
|
||||
return
|
||||
result = response.result.getBool
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "reading sound enabled setting error: ", errDesription
|
||||
|
||||
proc setNotificationSoundsEnabled*(self: Service, value: bool) {.slot.} =
|
||||
try:
|
||||
let response = status_settings.setSoundEnabled(value)
|
||||
if(not response.error.isNil):
|
||||
error "error saving sound enabled setting: ", errDescription = response.error.message
|
||||
return
|
||||
self.notificationSoundsEnabledChanged()
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "saving sound enabled setting error: ", errDesription
|
||||
|
||||
QtProperty[bool] notificationSoundsEnabled:
|
||||
read = getNotificationSoundsEnabled
|
||||
write = setNotificationSoundsEnabled
|
||||
notify = notificationSoundsEnabledChanged
|
||||
|
||||
proc notificationVolumeChanged*(self: Service) {.signal.}
|
||||
proc getNotificationVolume*(self: Service): int {.slot.} =
|
||||
result = 50 #default value
|
||||
try:
|
||||
let response = status_settings.getVolume()
|
||||
if(not response.error.isNil):
|
||||
error "error reading volume setting: ", errDescription = response.error.message
|
||||
return
|
||||
result = response.result.getInt
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "reading volume setting error: ", errDesription
|
||||
|
||||
proc setNotificationVolume*(self: Service, value: int) {.slot.} =
|
||||
try:
|
||||
let response = status_settings.setVolume(value)
|
||||
if(not response.error.isNil):
|
||||
error "error saving volume setting: ", errDescription = response.error.message
|
||||
return
|
||||
self.notificationVolumeChanged()
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "saving volume setting error: ", errDesription
|
||||
|
||||
QtProperty[int] volume:
|
||||
read = getNotificationVolume
|
||||
write = setNotificationVolume
|
||||
notify = notificationVolumeChanged
|
||||
|
||||
|
||||
proc notificationMessagePreviewChanged*(self: Service) {.signal.}
|
||||
proc getNotificationMessagePreview*(self: Service): int {.slot.} =
|
||||
result = 2 #default value
|
||||
try:
|
||||
let response = status_settings.getMessagePreview()
|
||||
if(not response.error.isNil):
|
||||
error "error reading message preview setting: ", errDescription = response.error.message
|
||||
return
|
||||
result = response.result.getInt
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "reading message preview setting error: ", errDesription
|
||||
|
||||
proc setNotificationMessagePreview*(self: Service, value: int) {.slot.} =
|
||||
try:
|
||||
let response = status_settings.setMessagePreview(value)
|
||||
if(not response.error.isNil):
|
||||
error "error saving message preview setting: ", errDescription = response.error.message
|
||||
return
|
||||
self.notificationMessagePreviewChanged()
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "saving message preview setting error: ", errDesription
|
||||
|
||||
QtProperty[int] notificationMessagePreview:
|
||||
read = getNotificationMessagePreview
|
||||
write = setNotificationMessagePreview
|
||||
notify = notificationMessagePreviewChanged
|
||||
|
||||
proc setNotifSettingExemptions*(self: Service, id: string, exemptions: NotificationsExemptions): bool =
|
||||
result = false
|
||||
try:
|
||||
let response = status_settings.setExemptions(id, exemptions.muteAllMessages, exemptions.personalMentions,
|
||||
exemptions.globalMentions, exemptions.otherMessages)
|
||||
if(not response.error.isNil):
|
||||
error "error saving exemptions setting: ", id = id, errDescription = response.error.message
|
||||
return
|
||||
result = true
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "saving exemptions setting error: ", id = id, errDesription
|
||||
|
||||
proc removeNotifSettingExemptions*(self: Service, id: string): bool =
|
||||
result = false
|
||||
try:
|
||||
let response = status_settings.deleteExemptions(id)
|
||||
if(not response.error.isNil):
|
||||
error "error deleting exemptions setting: ", id = id, errDescription = response.error.message
|
||||
return
|
||||
result = true
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "saving deleting exemptions setting: ", id = id, errDesription
|
||||
|
||||
proc getNotifSettingExemptions*(self: Service, id: string): NotificationsExemptions =
|
||||
#default values
|
||||
result.muteAllMessages = false
|
||||
result.personalMentions = VALUE_NOTIF_SEND_ALERTS
|
||||
result.globalMentions = VALUE_NOTIF_SEND_ALERTS
|
||||
result.otherMessages = VALUE_NOTIF_TURN_OFF
|
||||
try:
|
||||
var response = status_settings.getExemptionMuteAllMessages(id)
|
||||
if(not response.error.isNil):
|
||||
error "error reading exemptions mute all messages request setting: ", id = id, errDescription = response.error.message
|
||||
return
|
||||
result.muteAllMessages = response.result.getBool
|
||||
|
||||
response = status_settings.getExemptionPersonalMentions(id)
|
||||
if(not response.error.isNil):
|
||||
error "error reading exemptions personal mentions request setting: ", id = id, errDescription = response.error.message
|
||||
return
|
||||
result.personalMentions = response.result.getStr
|
||||
|
||||
response = status_settings.getExemptionGlobalMentions(id)
|
||||
if(not response.error.isNil):
|
||||
error "error reading exemptions global mentions request setting: ", id = id, errDescription = response.error.message
|
||||
return
|
||||
result.globalMentions = response.result.getStr
|
||||
|
||||
response = status_settings.getExemptionOtherMessages(id)
|
||||
if(not response.error.isNil):
|
||||
error "error reading exemptions other messages request setting: ", id = id, errDescription = response.error.message
|
||||
return
|
||||
result.otherMessages = response.result.getStr
|
||||
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "reading exemptions setting error: ", id = id, errDesription
|
|
@ -9,3 +9,89 @@ proc getSettings*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
|||
proc saveSettings*(key: string, value: string | JsonNode | bool | int): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* [key, value]
|
||||
result = core.callPrivateRPC("settings_saveSetting", payload)
|
||||
|
||||
proc getAllowNotifications*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return core.callPrivateRPC("settings_notificationsGetAllowNotifications")
|
||||
|
||||
proc setAllowNotifications*(value: bool): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return core.callPrivateRPC("settings_notificationsSetAllowNotifications", %* [value])
|
||||
|
||||
proc getOneToOneChats*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return core.callPrivateRPC("settings_notificationsGetOneToOneChats")
|
||||
|
||||
proc setOneToOneChats*(value: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return core.callPrivateRPC("settings_notificationsSetOneToOneChats", %* [value])
|
||||
|
||||
proc getGroupChats*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return core.callPrivateRPC("settings_notificationsGetGroupChats")
|
||||
|
||||
proc setGroupChats*(value: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return core.callPrivateRPC("settings_notificationsSetGroupChats", %* [value])
|
||||
|
||||
proc getPersonalMentions*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return core.callPrivateRPC("settings_notificationsGetPersonalMentions")
|
||||
|
||||
proc setPersonalMentions*(value: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return core.callPrivateRPC("settings_notificationsSetPersonalMentions", %* [value])
|
||||
|
||||
proc getGlobalMentions*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return core.callPrivateRPC("settings_notificationsGetGlobalMentions")
|
||||
|
||||
proc setGlobalMentions*(value: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return core.callPrivateRPC("settings_notificationsSetGlobalMentions", %* [value])
|
||||
|
||||
proc getAllMessages*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return core.callPrivateRPC("settings_notificationsGetAllMessages")
|
||||
|
||||
proc setAllMessages*(value: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return core.callPrivateRPC("settings_notificationsSetAllMessages", %* [value])
|
||||
|
||||
proc getContactRequests*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return core.callPrivateRPC("settings_notificationsGetContactRequests")
|
||||
|
||||
proc setContactRequests*(value: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return core.callPrivateRPC("settings_notificationsSetContactRequests", %* [value])
|
||||
|
||||
proc getIdentityVerificationRequests*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return core.callPrivateRPC("settings_notificationsGetIdentityVerificationRequests")
|
||||
|
||||
proc setIdentityVerificationRequests*(value: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return core.callPrivateRPC("settings_notificationsSetIdentityVerificationRequests", %* [value])
|
||||
|
||||
proc getSoundEnabled*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return core.callPrivateRPC("settings_notificationsGetSoundEnabled")
|
||||
|
||||
proc setSoundEnabled*(value: bool): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return core.callPrivateRPC("settings_notificationsSetSoundEnabled", %* [value])
|
||||
|
||||
proc getVolume*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return core.callPrivateRPC("settings_notificationsGetVolume")
|
||||
|
||||
proc setVolume*(value: int): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return core.callPrivateRPC("settings_notificationsSetVolume", %* [value])
|
||||
|
||||
proc getMessagePreview*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return core.callPrivateRPC("settings_notificationsGetMessagePreview")
|
||||
|
||||
proc setMessagePreview*(value: int): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return core.callPrivateRPC("settings_notificationsSetMessagePreview", %* [value])
|
||||
|
||||
proc getExemptionMuteAllMessages*(id: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return core.callPrivateRPC("settings_notificationsGetExMuteAllMessages", %* [id])
|
||||
|
||||
proc getExemptionPersonalMentions*(id: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return core.callPrivateRPC("settings_notificationsGetExPersonalMentions", %* [id])
|
||||
|
||||
proc getExemptionGlobalMentions*(id: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return core.callPrivateRPC("settings_notificationsGetExGlobalMentions", %* [id])
|
||||
|
||||
proc getExemptionOtherMessages*(id: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return core.callPrivateRPC("settings_notificationsGetExOtherMessages", %* [id])
|
||||
|
||||
proc setExemptions*(id: string, muteAllMessages: bool, personalMentions: string, globalMentions: string,
|
||||
otherMessages: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* [id, muteAllMessages, personalMentions, globalMentions, otherMessages]
|
||||
return core.callPrivateRPC("settings_notificationsSetExemptions", payload)
|
||||
|
||||
proc deleteExemptions*(id: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return core.callPrivateRPC("settings_deleteExemptions", %* [id])
|
|
@ -245,9 +245,9 @@ SettingsContentBase {
|
|||
components: [
|
||||
StatusSwitch {
|
||||
id: allowNotifSwitch
|
||||
checked: localAccountSensitiveSettings.notifSettingAllowNotifications
|
||||
checked: appSettings.notifSettingAllowNotifications
|
||||
onClicked: {
|
||||
localAccountSensitiveSettings.notifSettingAllowNotifications = !localAccountSensitiveSettings.notifSettingAllowNotifications
|
||||
appSettings.notifSettingAllowNotifications = !appSettings.notifSettingAllowNotifications
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -269,10 +269,10 @@ SettingsContentBase {
|
|||
title: qsTr("1:1 Chats")
|
||||
components: [
|
||||
NotificationSelect {
|
||||
selected: localAccountSensitiveSettings.notifSettingOneToOneChats
|
||||
onSendAlertsClicked: localAccountSensitiveSettings.notifSettingOneToOneChats = Constants.settingsSection.notifications.sendAlertsValue
|
||||
onDeliverQuietlyClicked: localAccountSensitiveSettings.notifSettingOneToOneChats = Constants.settingsSection.notifications.deliverQuietlyValue
|
||||
onTurnOffClicked: localAccountSensitiveSettings.notifSettingOneToOneChats = Constants.settingsSection.notifications.turnOffValue
|
||||
selected: appSettings.notifSettingOneToOneChats
|
||||
onSendAlertsClicked: appSettings.notifSettingOneToOneChats = Constants.settingsSection.notifications.sendAlertsValue
|
||||
onDeliverQuietlyClicked: appSettings.notifSettingOneToOneChats = Constants.settingsSection.notifications.deliverQuietlyValue
|
||||
onTurnOffClicked: appSettings.notifSettingOneToOneChats = Constants.settingsSection.notifications.turnOffValue
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -282,10 +282,10 @@ SettingsContentBase {
|
|||
title: qsTr("Group Chats")
|
||||
components: [
|
||||
NotificationSelect {
|
||||
selected: localAccountSensitiveSettings.notifSettingGroupChats
|
||||
onSendAlertsClicked: localAccountSensitiveSettings.notifSettingGroupChats = Constants.settingsSection.notifications.sendAlertsValue
|
||||
onDeliverQuietlyClicked: localAccountSensitiveSettings.notifSettingGroupChats = Constants.settingsSection.notifications.deliverQuietlyValue
|
||||
onTurnOffClicked: localAccountSensitiveSettings.notifSettingGroupChats = Constants.settingsSection.notifications.turnOffValue
|
||||
selected: appSettings.notifSettingGroupChats
|
||||
onSendAlertsClicked: appSettings.notifSettingGroupChats = Constants.settingsSection.notifications.sendAlertsValue
|
||||
onDeliverQuietlyClicked: appSettings.notifSettingGroupChats = Constants.settingsSection.notifications.deliverQuietlyValue
|
||||
onTurnOffClicked: appSettings.notifSettingGroupChats = Constants.settingsSection.notifications.turnOffValue
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -296,10 +296,10 @@ SettingsContentBase {
|
|||
tertiaryTitle: qsTr("Messages containing @%1").arg(userProfile.name)
|
||||
components: [
|
||||
NotificationSelect {
|
||||
selected: localAccountSensitiveSettings.notifSettingPersonalMentions
|
||||
onSendAlertsClicked: localAccountSensitiveSettings.notifSettingPersonalMentions = Constants.settingsSection.notifications.sendAlertsValue
|
||||
onDeliverQuietlyClicked: localAccountSensitiveSettings.notifSettingPersonalMentions = Constants.settingsSection.notifications.deliverQuietlyValue
|
||||
onTurnOffClicked: localAccountSensitiveSettings.notifSettingPersonalMentions = Constants.settingsSection.notifications.turnOffValue
|
||||
selected: appSettings.notifSettingPersonalMentions
|
||||
onSendAlertsClicked: appSettings.notifSettingPersonalMentions = Constants.settingsSection.notifications.sendAlertsValue
|
||||
onDeliverQuietlyClicked: appSettings.notifSettingPersonalMentions = Constants.settingsSection.notifications.deliverQuietlyValue
|
||||
onTurnOffClicked: appSettings.notifSettingPersonalMentions = Constants.settingsSection.notifications.turnOffValue
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -310,10 +310,10 @@ SettingsContentBase {
|
|||
tertiaryTitle: qsTr("Messages containing @here and @channel")
|
||||
components: [
|
||||
NotificationSelect {
|
||||
selected: localAccountSensitiveSettings.notifSettingGlobalMentions
|
||||
onSendAlertsClicked: localAccountSensitiveSettings.notifSettingGlobalMentions = Constants.settingsSection.notifications.sendAlertsValue
|
||||
onDeliverQuietlyClicked: localAccountSensitiveSettings.notifSettingGlobalMentions = Constants.settingsSection.notifications.deliverQuietlyValue
|
||||
onTurnOffClicked: localAccountSensitiveSettings.notifSettingGlobalMentions = Constants.settingsSection.notifications.turnOffValue
|
||||
selected: appSettings.notifSettingGlobalMentions
|
||||
onSendAlertsClicked: appSettings.notifSettingGlobalMentions = Constants.settingsSection.notifications.sendAlertsValue
|
||||
onDeliverQuietlyClicked: appSettings.notifSettingGlobalMentions = Constants.settingsSection.notifications.deliverQuietlyValue
|
||||
onTurnOffClicked: appSettings.notifSettingGlobalMentions = Constants.settingsSection.notifications.turnOffValue
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -323,10 +323,10 @@ SettingsContentBase {
|
|||
title: qsTr("All Messages")
|
||||
components: [
|
||||
NotificationSelect {
|
||||
selected: localAccountSensitiveSettings.notifSettingAllMessages
|
||||
onSendAlertsClicked: localAccountSensitiveSettings.notifSettingAllMessages = Constants.settingsSection.notifications.sendAlertsValue
|
||||
onDeliverQuietlyClicked: localAccountSensitiveSettings.notifSettingAllMessages = Constants.settingsSection.notifications.deliverQuietlyValue
|
||||
onTurnOffClicked: localAccountSensitiveSettings.notifSettingAllMessages = Constants.settingsSection.notifications.turnOffValue
|
||||
selected: appSettings.notifSettingAllMessages
|
||||
onSendAlertsClicked: appSettings.notifSettingAllMessages = Constants.settingsSection.notifications.sendAlertsValue
|
||||
onDeliverQuietlyClicked: appSettings.notifSettingAllMessages = Constants.settingsSection.notifications.deliverQuietlyValue
|
||||
onTurnOffClicked: appSettings.notifSettingAllMessages = Constants.settingsSection.notifications.turnOffValue
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -344,10 +344,10 @@ SettingsContentBase {
|
|||
title: qsTr("Contact Requests")
|
||||
components: [
|
||||
NotificationSelect {
|
||||
selected: localAccountSensitiveSettings.notifSettingContactRequests
|
||||
onSendAlertsClicked: localAccountSensitiveSettings.notifSettingContactRequests = Constants.settingsSection.notifications.sendAlertsValue
|
||||
onDeliverQuietlyClicked: localAccountSensitiveSettings.notifSettingContactRequests = Constants.settingsSection.notifications.deliverQuietlyValue
|
||||
onTurnOffClicked: localAccountSensitiveSettings.notifSettingContactRequests = Constants.settingsSection.notifications.turnOffValue
|
||||
selected: appSettings.notifSettingContactRequests
|
||||
onSendAlertsClicked: appSettings.notifSettingContactRequests = Constants.settingsSection.notifications.sendAlertsValue
|
||||
onDeliverQuietlyClicked: appSettings.notifSettingContactRequests = Constants.settingsSection.notifications.deliverQuietlyValue
|
||||
onTurnOffClicked: appSettings.notifSettingContactRequests = Constants.settingsSection.notifications.turnOffValue
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -357,10 +357,10 @@ SettingsContentBase {
|
|||
title: qsTr("Identity Verification Requests")
|
||||
components: [
|
||||
NotificationSelect {
|
||||
selected: localAccountSensitiveSettings.notifSettingIdentityVerificationRequests
|
||||
onSendAlertsClicked: localAccountSensitiveSettings.notifSettingIdentityVerificationRequests = Constants.settingsSection.notifications.sendAlertsValue
|
||||
onDeliverQuietlyClicked: localAccountSensitiveSettings.notifSettingIdentityVerificationRequests = Constants.settingsSection.notifications.deliverQuietlyValue
|
||||
onTurnOffClicked: localAccountSensitiveSettings.notifSettingIdentityVerificationRequests = Constants.settingsSection.notifications.turnOffValue
|
||||
selected: appSettings.notifSettingIdentityVerificationRequests
|
||||
onSendAlertsClicked: appSettings.notifSettingIdentityVerificationRequests = Constants.settingsSection.notifications.sendAlertsValue
|
||||
onDeliverQuietlyClicked: appSettings.notifSettingIdentityVerificationRequests = Constants.settingsSection.notifications.deliverQuietlyValue
|
||||
onTurnOffClicked: appSettings.notifSettingIdentityVerificationRequests = Constants.settingsSection.notifications.turnOffValue
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -386,10 +386,10 @@ SettingsContentBase {
|
|||
notificationTitle: "Vitalik Buterin"
|
||||
notificationMessage: qsTr("Hi there! So EIP-1559 will defini...")
|
||||
buttonGroup: messageSetting
|
||||
checked: localAccountSensitiveSettings.notificationMessagePreviewSetting === Constants.settingsSection.notificationsBubble.previewNameAndMessage
|
||||
checked: appSettings.notificationMessagePreview === Constants.settingsSection.notificationsBubble.previewNameAndMessage
|
||||
onRadioCheckedChanged: {
|
||||
if (checked) {
|
||||
localAccountSensitiveSettings.notificationMessagePreviewSetting = Constants.settingsSection.notificationsBubble.previewNameAndMessage
|
||||
appSettings.notificationMessagePreview = Constants.settingsSection.notificationsBubble.previewNameAndMessage
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -401,10 +401,10 @@ SettingsContentBase {
|
|||
notificationTitle: "Vitalik Buterin"
|
||||
notificationMessage: qsTr("You have a new message")
|
||||
buttonGroup: messageSetting
|
||||
checked: localAccountSensitiveSettings.notificationMessagePreviewSetting === Constants.settingsSection.notificationsBubble.previewNameOnly
|
||||
checked: appSettings.notificationMessagePreview === Constants.settingsSection.notificationsBubble.previewNameOnly
|
||||
onRadioCheckedChanged: {
|
||||
if (checked) {
|
||||
localAccountSensitiveSettings.notificationMessagePreviewSetting = Constants.settingsSection.notificationsBubble.previewNameOnly
|
||||
appSettings.notificationMessagePreview = Constants.settingsSection.notificationsBubble.previewNameOnly
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -416,10 +416,10 @@ SettingsContentBase {
|
|||
notificationTitle: "Status"
|
||||
notificationMessage: qsTr("You have a new message")
|
||||
buttonGroup: messageSetting
|
||||
checked: localAccountSensitiveSettings.notificationMessagePreviewSetting === Constants.settingsSection.notificationsBubble.previewAnonymous
|
||||
checked: appSettings.notificationMessagePreview === Constants.settingsSection.notificationsBubble.previewAnonymous
|
||||
onRadioCheckedChanged: {
|
||||
if (checked) {
|
||||
localAccountSensitiveSettings.notificationMessagePreviewSetting = Constants.settingsSection.notificationsBubble.previewAnonymous
|
||||
appSettings.notificationMessagePreview = Constants.settingsSection.notificationsBubble.previewAnonymous
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -430,9 +430,9 @@ SettingsContentBase {
|
|||
components: [
|
||||
StatusSwitch {
|
||||
id: soundSwitch
|
||||
checked: localAccountSensitiveSettings.notificationSoundsEnabled
|
||||
checked: appSettings.notificationSoundsEnabled
|
||||
onClicked: {
|
||||
localAccountSensitiveSettings.notificationSoundsEnabled = !localAccountSensitiveSettings.notificationSoundsEnabled
|
||||
appSettings.notificationSoundsEnabled = !appSettings.notificationSoundsEnabled
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -466,11 +466,11 @@ SettingsContentBase {
|
|||
stepSize: 1
|
||||
|
||||
onValueChanged: {
|
||||
localAccountSensitiveSettings.volume = value
|
||||
appSettings.volume = value
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
value = localAccountSensitiveSettings.volume
|
||||
value = appSettings.volume
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -168,9 +168,9 @@ QtObject {
|
|||
}
|
||||
|
||||
readonly property QtObject notifications: QtObject {
|
||||
readonly property string sendAlertsValue: "sendAlerts"
|
||||
readonly property string deliverQuietlyValue: "deliverQuietly"
|
||||
readonly property string turnOffValue: "turnOff"
|
||||
readonly property string sendAlertsValue: "SendAlerts"
|
||||
readonly property string deliverQuietlyValue: "DeliverQuietly"
|
||||
readonly property string turnOffValue: "TurnOff"
|
||||
}
|
||||
|
||||
readonly property QtObject exemptions: QtObject {
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 7227ae1c8ef1f74e180f324185d01f564730af70
|
||||
Subproject commit 78cba969cc90f463184509c6bde9bcb44d7bb3f9
|
Loading…
Reference in New Issue