Purge on Startup + Fix SetSZA eventbus safety
This commit is contained in:
parent
af8322b734
commit
5a3d393472
|
@ -159,8 +159,9 @@ func (cp *cwtchPeer) SetScopedZonedAttribute(scope attr.Scope, zone attr.Zone, k
|
||||||
|
|
||||||
// We always want to publish profile level attributes to the ui
|
// We always want to publish profile level attributes to the ui
|
||||||
// This should be low traffic.
|
// This should be low traffic.
|
||||||
|
if cp.eventBus != nil {
|
||||||
cp.eventBus.Publish(event.NewEvent(event.UpdatedProfileAttribute, map[event.Field]string{event.Key: scopedZonedKey.ToString(), event.Data: value}))
|
cp.eventBus.Publish(event.NewEvent(event.UpdatedProfileAttribute, map[event.Field]string{event.Key: scopedZonedKey.ToString(), event.Data: value}))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendMessage is a higher level that merges sending messages to contacts and group handles
|
// SendMessage is a higher level that merges sending messages to contacts and group handles
|
||||||
|
@ -266,6 +267,9 @@ func FromEncryptedStorage(cps *CwtchProfileStorage) CwtchPeer {
|
||||||
cp.state = make(map[string]connections.ConnectionState)
|
cp.state = make(map[string]connections.ConnectionState)
|
||||||
// At some point we may want to populate caches here, for now we will assume hitting the
|
// At some point we may want to populate caches here, for now we will assume hitting the
|
||||||
// database directly is tolerable
|
// database directly is tolerable
|
||||||
|
// Clean up anything that wasn't cleaned up on shutdown
|
||||||
|
// TODO ideally this shouldn't need to be done but the UI sometimes doesn't shut down cleanly
|
||||||
|
cp.storage.PurgeNonSavedMessages()
|
||||||
return cp
|
return cp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -693,10 +693,8 @@ func (cps *CwtchProfileStorage) PurgeConversationChannel(conversation int, chann
|
||||||
return conversationStmt.Close()
|
return conversationStmt.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close closes the underlying database and prepared statements
|
// PurgeNonSavedMessages deletes all message conversations that are not explicitly set to saved.
|
||||||
func (cps *CwtchProfileStorage) Close() {
|
func (cps *CwtchProfileStorage) PurgeNonSavedMessages() {
|
||||||
if cps.db != nil {
|
|
||||||
|
|
||||||
// Purge Messages that are not stored...
|
// Purge Messages that are not stored...
|
||||||
ci, err := cps.FetchConversations()
|
ci, err := cps.FetchConversations()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -710,6 +708,13 @@ func (cps *CwtchProfileStorage) Close() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close closes the underlying database and prepared statements
|
||||||
|
func (cps *CwtchProfileStorage) Close() {
|
||||||
|
if cps.db != nil {
|
||||||
|
|
||||||
|
cps.PurgeNonSavedMessages()
|
||||||
|
|
||||||
cps.insertProfileKeyValueStmt.Close()
|
cps.insertProfileKeyValueStmt.Close()
|
||||||
cps.selectProfileKeyValueStmt.Close()
|
cps.selectProfileKeyValueStmt.Close()
|
||||||
|
|
Loading…
Reference in New Issue