Merge pull request #1079 from hmhealey/initprefs

Added an initial call to get all user preferences on page load
Этот коммит содержится в:
Christopher Speller
2015-10-16 08:16:40 -04:00
родитель 269476d694 327b0b5a21
Коммит 099d853877
11 изменённых файлов: 179 добавлений и 13 удалений

Просмотреть файл

@@ -212,3 +212,30 @@ func (s SqlPreferenceStore) GetCategory(userId string, category string) StoreCha
return storeChannel
}
func (s SqlPreferenceStore) GetAll(userId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
result := StoreResult{}
var preferences model.Preferences
if _, err := s.GetReplica().Select(&preferences,
`SELECT
*
FROM
Preferences
WHERE
UserId = :UserId`, map[string]interface{}{"UserId": userId}); err != nil {
result.Err = model.NewAppError("SqlPreferenceStore.GetAll", "We encounted an error while finding preferences", err.Error())
} else {
result.Data = preferences
}
storeChannel <- result
close(storeChannel)
}()
return storeChannel
}