Renamed show_hide preference to show

This commit is contained in:
hmhealey
2015-10-05 12:03:27 -04:00
parent 415f959614
commit 599644fb2f
9 changed files with 34 additions and 26 deletions

View File

@@ -27,7 +27,7 @@ func TestSetPreferences(t *testing.T) {
preference := model.Preference{
UserId: user1.Id,
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
Name: model.PREFERENCE_NAME_SHOWHIDE,
Name: model.PREFERENCE_NAME_SHOW,
AltId: model.NewId(),
}
preferences = append(preferences, &preference)
@@ -74,13 +74,13 @@ func TestGetPreferencesByName(t *testing.T) {
&model.Preference{
UserId: user1.Id,
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
Name: model.PREFERENCE_NAME_SHOWHIDE,
Name: model.PREFERENCE_NAME_SHOW,
AltId: model.NewId(),
},
&model.Preference{
UserId: user1.Id,
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
Name: model.PREFERENCE_NAME_SHOWHIDE,
Name: model.PREFERENCE_NAME_SHOW,
AltId: model.NewId(),
},
&model.Preference{
@@ -92,7 +92,7 @@ func TestGetPreferencesByName(t *testing.T) {
&model.Preference{
UserId: user1.Id,
Category: model.PREFERENCE_CATEGORY_TEST,
Name: model.PREFERENCE_NAME_SHOWHIDE,
Name: model.PREFERENCE_NAME_SHOW,
AltId: model.NewId(),
},
}
@@ -101,7 +101,7 @@ func TestGetPreferencesByName(t *testing.T) {
&model.Preference{
UserId: user2.Id,
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
Name: model.PREFERENCE_NAME_SHOWHIDE,
Name: model.PREFERENCE_NAME_SHOW,
AltId: model.NewId(),
},
}
@@ -114,7 +114,7 @@ func TestGetPreferencesByName(t *testing.T) {
Client.LoginByEmail(team.Name, user1.Email, "pwd")
if result, err := Client.GetPreferencesByName(model.PREFERENCE_CATEGORY_DIRECT_CHANNELS, model.PREFERENCE_NAME_SHOWHIDE); err != nil {
if result, err := Client.GetPreferencesByName(model.PREFERENCE_CATEGORY_DIRECT_CHANNELS, model.PREFERENCE_NAME_SHOW); err != nil {
t.Fatal(err)
} else if data := result.Data.([]*model.Preference); len(data) != 2 {
t.Fatal("received the wrong number of preferences")
@@ -124,7 +124,7 @@ func TestGetPreferencesByName(t *testing.T) {
Client.LoginByEmail(team.Name, user2.Email, "pwd")
if result, err := Client.GetPreferencesByName(model.PREFERENCE_CATEGORY_DIRECT_CHANNELS, model.PREFERENCE_NAME_SHOWHIDE); err != nil {
if result, err := Client.GetPreferencesByName(model.PREFERENCE_CATEGORY_DIRECT_CHANNELS, model.PREFERENCE_NAME_SHOW); err != nil {
t.Fatal(err)
} else if data := result.Data.([]*model.Preference); len(data) != 1 {
t.Fatal("received the wrong number of preferences")
@@ -148,7 +148,7 @@ func TestSetAndGetProperties(t *testing.T) {
p := model.Preference{
UserId: user.Id,
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
Name: model.PREFERENCE_NAME_SHOWHIDE,
Name: model.PREFERENCE_NAME_SHOW,
AltId: model.NewId(),
Value: model.NewId(),
}

View File

@@ -242,7 +242,7 @@ func fireAndForgetAddDirectChannels(user *model.User, team *model.Team) {
preference := &model.Preference{
UserId: user.Id,
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
Name: model.PREFERENCE_NAME_SHOWHIDE,
Name: model.PREFERENCE_NAME_SHOW,
AltId: profile.Id,
Value: "true",
}

View File

@@ -11,7 +11,7 @@ import (
const (
PREFERENCE_CATEGORY_DIRECT_CHANNELS = "direct_channels"
PREFERENCE_CATEGORY_TEST = "test" // do not use, just for testing uniqueness while there's only one real category
PREFERENCE_NAME_SHOWHIDE = "show_hide"
PREFERENCE_NAME_SHOW = "show"
PREFERENCE_NAME_TEST = "test" // do not use, just for testing uniqueness while there's only one real name
)
@@ -92,5 +92,5 @@ func IsPreferenceCategoryValid(category string) bool {
}
func IsPreferenceNameValid(name string) bool {
return name == PREFERENCE_NAME_SHOWHIDE || name == PREFERENCE_NAME_TEST
return name == PREFERENCE_NAME_SHOW || name == PREFERENCE_NAME_TEST
}

View File

@@ -35,7 +35,7 @@ func TestPreferenceIsValid(t *testing.T) {
t.Fatal()
}
preference.Name = PREFERENCE_NAME_SHOWHIDE
preference.Name = PREFERENCE_NAME_SHOW
if err := preference.IsValid(); err != nil {
t.Fatal()
}

View File

@@ -14,7 +14,7 @@ func TestPreferenceStoreSave(t *testing.T) {
p1 := model.Preference{
UserId: model.NewId(),
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
Name: model.PREFERENCE_NAME_SHOWHIDE,
Name: model.PREFERENCE_NAME_SHOW,
AltId: model.NewId(),
}
@@ -29,7 +29,7 @@ func TestPreferenceStoreSave(t *testing.T) {
p2 := model.Preference{
UserId: model.NewId(),
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
Name: model.PREFERENCE_NAME_SHOWHIDE,
Name: model.PREFERENCE_NAME_SHOW,
AltId: p1.AltId,
}
@@ -40,7 +40,7 @@ func TestPreferenceStoreSave(t *testing.T) {
p3 := model.Preference{
UserId: p1.UserId,
Category: model.PREFERENCE_CATEGORY_TEST,
Name: model.PREFERENCE_NAME_SHOWHIDE,
Name: model.PREFERENCE_NAME_SHOW,
AltId: p1.AltId,
}
@@ -62,7 +62,7 @@ func TestPreferenceStoreSave(t *testing.T) {
p5 := model.Preference{
UserId: p1.UserId,
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
Name: model.PREFERENCE_NAME_SHOWHIDE,
Name: model.PREFERENCE_NAME_SHOW,
AltId: model.NewId(),
}
@@ -79,7 +79,7 @@ func TestPreferenceStoreUpdate(t *testing.T) {
p1 := model.Preference{
UserId: id,
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
Name: model.PREFERENCE_NAME_SHOWHIDE,
Name: model.PREFERENCE_NAME_SHOW,
}
Must(store.Preference().Save(&p1))
@@ -105,7 +105,7 @@ func TestPreferenceStoreUpdate(t *testing.T) {
t.Fatal("update should have failed because of changed name")
}
p1.Name = model.PREFERENCE_NAME_SHOWHIDE
p1.Name = model.PREFERENCE_NAME_SHOW
p1.AltId = model.NewId()
if err := (<-store.Preference().Update(&p1)).Err; err == nil {
t.Fatal("update should have failed because of changed alternate id")
@@ -118,7 +118,7 @@ func TestPreferenceGetByName(t *testing.T) {
p1 := model.Preference{
UserId: model.NewId(),
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
Name: model.PREFERENCE_NAME_SHOWHIDE,
Name: model.PREFERENCE_NAME_SHOW,
AltId: model.NewId(),
}

View File

@@ -3,6 +3,7 @@
var TeamStore = require('../stores/team_store.jsx');
var Client = require('../utils/client.jsx');
var Constants = require('../utils/constants.jsx');
var AsyncClient = require('../utils/async_client.jsx');
var PreferenceStore = require('../stores/preference_store.jsx');
var utils = require('../utils/utils.jsx');
@@ -23,7 +24,8 @@ export default class MoreDirectChannels extends React.Component {
}
handleJoinDirectChannel(channel) {
const preference = PreferenceStore.setPreferenceWithAltId('direct_channels', 'show_hide', channel.teammate_id, 'true');
const preference = PreferenceStore.setPreferenceWithAltId(Constants.Preferences.CATEGORY_DIRECT_CHANNELS,
Constants.Preferences.NAME_SHOW, channel.teammate_id, 'true');
AsyncClient.setPreferences([preference]);
}

View File

@@ -52,7 +52,7 @@ export default class Sidebar extends React.Component {
teammates.push(teamMemberMap[id]);
}
const preferences = PreferenceStore.getPreferences('direct_channels', 'show_hide');
const preferences = PreferenceStore.getPreferences(Constants.Preferences.CATEGORY_DIRECT_CHANNELS, Constants.Preferences.NAME_SHOW);
// Create lists of all read and unread direct channels
var visibleDirectChannels = [];
@@ -96,7 +96,8 @@ export default class Sidebar extends React.Component {
visibleDirectChannels.push(channel);
} else if (forceShow) {
// make sure that unread direct channels are visible
const preference = PreferenceStore.setPreferenceWithAltId('direct_channels', 'show_hide', teammate.id, 'true');
const preference = PreferenceStore.setPreferenceWithAltId(Constants.Preferences.CATEGORY_DIRECT_CHANNELS,
Constants.Preferences.NAME_SHOW, teammate.id, 'true');
AsyncClient.setPreferences([preference]);
visibleDirectChannels.push(channel);
@@ -306,7 +307,8 @@ export default class Sidebar extends React.Component {
if (!channel.leaving) {
channel.leaving = true;
const preference = PreferenceStore.setPreferenceWithAltId('direct_channels', 'show_hide', channel.teammate_id, 'false');
const preference = PreferenceStore.setPreferenceWithAltId(Constants.Preferences.CATEGORY_DIRECT_CHANNELS,
Constants.Preferences.NAME_SHOW, channel.teammate_id, 'false');
AsyncClient.setPreferences(
[preference],
() => {

View File

@@ -645,8 +645,8 @@ export function getDirectChannels() {
callTracker.getDirectChannels = utils.getTimestamp();
client.getPreferencesByName(
'direct_channels',
'show_hide',
Constants.Preferences.CATEGORY_DIRECT_CHANNELS,
Constants.Preferences.NAME_SHOW,
(data, textStatus, xhr) => {
callTracker.getDirectChannels = 0;

View File

@@ -286,5 +286,9 @@ module.exports = {
id: 'mentionHighlightLink',
uiName: 'Mention Highlight Link'
}
]
],
Preferences: {
CATEGORY_DIRECT_CHANNELS: 'direct_channels',
NAME_SHOW: 'show'
}
};