mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 02:00:11 -08:00
refactoring / bug fixing in history preferences
This commit is contained in:
parent
7f4c50b81d
commit
b45f8436a4
5 changed files with 99 additions and 85 deletions
|
|
@ -185,25 +185,40 @@ func historyStatusToString(status HistoryStatus) string {
|
|||
}
|
||||
}
|
||||
|
||||
// XXX you must have already checked History.Enabled before calling this
|
||||
func historyEnabled(serverSetting PersistentStatus, localSetting HistoryStatus) (result HistoryStatus) {
|
||||
if serverSetting == PersistentDisabled {
|
||||
return HistoryDisabled
|
||||
} else if serverSetting == PersistentMandatory {
|
||||
switch serverSetting {
|
||||
case PersistentMandatory:
|
||||
return HistoryPersistent
|
||||
} else if serverSetting == PersistentOptOut {
|
||||
case PersistentOptOut:
|
||||
if localSetting == HistoryDefault {
|
||||
return HistoryPersistent
|
||||
} else {
|
||||
return localSetting
|
||||
}
|
||||
} else if serverSetting == PersistentOptIn {
|
||||
if localSetting >= HistoryEphemeral {
|
||||
return localSetting
|
||||
} else {
|
||||
case PersistentOptIn:
|
||||
switch localSetting {
|
||||
case HistoryPersistent:
|
||||
return HistoryPersistent
|
||||
case HistoryEphemeral, HistoryDefault:
|
||||
return HistoryEphemeral
|
||||
default:
|
||||
return HistoryDisabled
|
||||
}
|
||||
} else {
|
||||
return HistoryDisabled
|
||||
case PersistentDisabled:
|
||||
if localSetting == HistoryDisabled {
|
||||
return HistoryDisabled
|
||||
} else {
|
||||
return HistoryEphemeral
|
||||
}
|
||||
default:
|
||||
// PersistentUnspecified: shouldn't happen because the deserializer converts it
|
||||
// to PersistentDisabled
|
||||
if localSetting == HistoryDefault {
|
||||
return HistoryEphemeral
|
||||
} else {
|
||||
return localSetting
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue