Renamed show_hide preference to show
Этот коммит содержится в:
@@ -27,7 +27,7 @@ func TestSetPreferences(t *testing.T) {
|
|||||||
preference := model.Preference{
|
preference := model.Preference{
|
||||||
UserId: user1.Id,
|
UserId: user1.Id,
|
||||||
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
|
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
|
||||||
Name: model.PREFERENCE_NAME_SHOWHIDE,
|
Name: model.PREFERENCE_NAME_SHOW,
|
||||||
AltId: model.NewId(),
|
AltId: model.NewId(),
|
||||||
}
|
}
|
||||||
preferences = append(preferences, &preference)
|
preferences = append(preferences, &preference)
|
||||||
@@ -74,13 +74,13 @@ func TestGetPreferencesByName(t *testing.T) {
|
|||||||
&model.Preference{
|
&model.Preference{
|
||||||
UserId: user1.Id,
|
UserId: user1.Id,
|
||||||
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
|
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
|
||||||
Name: model.PREFERENCE_NAME_SHOWHIDE,
|
Name: model.PREFERENCE_NAME_SHOW,
|
||||||
AltId: model.NewId(),
|
AltId: model.NewId(),
|
||||||
},
|
},
|
||||||
&model.Preference{
|
&model.Preference{
|
||||||
UserId: user1.Id,
|
UserId: user1.Id,
|
||||||
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
|
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
|
||||||
Name: model.PREFERENCE_NAME_SHOWHIDE,
|
Name: model.PREFERENCE_NAME_SHOW,
|
||||||
AltId: model.NewId(),
|
AltId: model.NewId(),
|
||||||
},
|
},
|
||||||
&model.Preference{
|
&model.Preference{
|
||||||
@@ -92,7 +92,7 @@ func TestGetPreferencesByName(t *testing.T) {
|
|||||||
&model.Preference{
|
&model.Preference{
|
||||||
UserId: user1.Id,
|
UserId: user1.Id,
|
||||||
Category: model.PREFERENCE_CATEGORY_TEST,
|
Category: model.PREFERENCE_CATEGORY_TEST,
|
||||||
Name: model.PREFERENCE_NAME_SHOWHIDE,
|
Name: model.PREFERENCE_NAME_SHOW,
|
||||||
AltId: model.NewId(),
|
AltId: model.NewId(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,7 @@ func TestGetPreferencesByName(t *testing.T) {
|
|||||||
&model.Preference{
|
&model.Preference{
|
||||||
UserId: user2.Id,
|
UserId: user2.Id,
|
||||||
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
|
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
|
||||||
Name: model.PREFERENCE_NAME_SHOWHIDE,
|
Name: model.PREFERENCE_NAME_SHOW,
|
||||||
AltId: model.NewId(),
|
AltId: model.NewId(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ func TestGetPreferencesByName(t *testing.T) {
|
|||||||
|
|
||||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
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)
|
t.Fatal(err)
|
||||||
} else if data := result.Data.([]*model.Preference); len(data) != 2 {
|
} else if data := result.Data.([]*model.Preference); len(data) != 2 {
|
||||||
t.Fatal("received the wrong number of preferences")
|
t.Fatal("received the wrong number of preferences")
|
||||||
@@ -124,7 +124,7 @@ func TestGetPreferencesByName(t *testing.T) {
|
|||||||
|
|
||||||
Client.LoginByEmail(team.Name, user2.Email, "pwd")
|
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)
|
t.Fatal(err)
|
||||||
} else if data := result.Data.([]*model.Preference); len(data) != 1 {
|
} else if data := result.Data.([]*model.Preference); len(data) != 1 {
|
||||||
t.Fatal("received the wrong number of preferences")
|
t.Fatal("received the wrong number of preferences")
|
||||||
@@ -148,7 +148,7 @@ func TestSetAndGetProperties(t *testing.T) {
|
|||||||
p := model.Preference{
|
p := model.Preference{
|
||||||
UserId: user.Id,
|
UserId: user.Id,
|
||||||
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
|
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
|
||||||
Name: model.PREFERENCE_NAME_SHOWHIDE,
|
Name: model.PREFERENCE_NAME_SHOW,
|
||||||
AltId: model.NewId(),
|
AltId: model.NewId(),
|
||||||
Value: model.NewId(),
|
Value: model.NewId(),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ func fireAndForgetAddDirectChannels(user *model.User, team *model.Team) {
|
|||||||
preference := &model.Preference{
|
preference := &model.Preference{
|
||||||
UserId: user.Id,
|
UserId: user.Id,
|
||||||
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
|
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
|
||||||
Name: model.PREFERENCE_NAME_SHOWHIDE,
|
Name: model.PREFERENCE_NAME_SHOW,
|
||||||
AltId: profile.Id,
|
AltId: profile.Id,
|
||||||
Value: "true",
|
Value: "true",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
const (
|
const (
|
||||||
PREFERENCE_CATEGORY_DIRECT_CHANNELS = "direct_channels"
|
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_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
|
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 {
|
func IsPreferenceNameValid(name string) bool {
|
||||||
return name == PREFERENCE_NAME_SHOWHIDE || name == PREFERENCE_NAME_TEST
|
return name == PREFERENCE_NAME_SHOW || name == PREFERENCE_NAME_TEST
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ func TestPreferenceIsValid(t *testing.T) {
|
|||||||
t.Fatal()
|
t.Fatal()
|
||||||
}
|
}
|
||||||
|
|
||||||
preference.Name = PREFERENCE_NAME_SHOWHIDE
|
preference.Name = PREFERENCE_NAME_SHOW
|
||||||
if err := preference.IsValid(); err != nil {
|
if err := preference.IsValid(); err != nil {
|
||||||
t.Fatal()
|
t.Fatal()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ func TestPreferenceStoreSave(t *testing.T) {
|
|||||||
p1 := model.Preference{
|
p1 := model.Preference{
|
||||||
UserId: model.NewId(),
|
UserId: model.NewId(),
|
||||||
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
|
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
|
||||||
Name: model.PREFERENCE_NAME_SHOWHIDE,
|
Name: model.PREFERENCE_NAME_SHOW,
|
||||||
AltId: model.NewId(),
|
AltId: model.NewId(),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ func TestPreferenceStoreSave(t *testing.T) {
|
|||||||
p2 := model.Preference{
|
p2 := model.Preference{
|
||||||
UserId: model.NewId(),
|
UserId: model.NewId(),
|
||||||
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
|
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
|
||||||
Name: model.PREFERENCE_NAME_SHOWHIDE,
|
Name: model.PREFERENCE_NAME_SHOW,
|
||||||
AltId: p1.AltId,
|
AltId: p1.AltId,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ func TestPreferenceStoreSave(t *testing.T) {
|
|||||||
p3 := model.Preference{
|
p3 := model.Preference{
|
||||||
UserId: p1.UserId,
|
UserId: p1.UserId,
|
||||||
Category: model.PREFERENCE_CATEGORY_TEST,
|
Category: model.PREFERENCE_CATEGORY_TEST,
|
||||||
Name: model.PREFERENCE_NAME_SHOWHIDE,
|
Name: model.PREFERENCE_NAME_SHOW,
|
||||||
AltId: p1.AltId,
|
AltId: p1.AltId,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ func TestPreferenceStoreSave(t *testing.T) {
|
|||||||
p5 := model.Preference{
|
p5 := model.Preference{
|
||||||
UserId: p1.UserId,
|
UserId: p1.UserId,
|
||||||
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
|
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
|
||||||
Name: model.PREFERENCE_NAME_SHOWHIDE,
|
Name: model.PREFERENCE_NAME_SHOW,
|
||||||
AltId: model.NewId(),
|
AltId: model.NewId(),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ func TestPreferenceStoreUpdate(t *testing.T) {
|
|||||||
p1 := model.Preference{
|
p1 := model.Preference{
|
||||||
UserId: id,
|
UserId: id,
|
||||||
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
|
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
|
||||||
Name: model.PREFERENCE_NAME_SHOWHIDE,
|
Name: model.PREFERENCE_NAME_SHOW,
|
||||||
}
|
}
|
||||||
Must(store.Preference().Save(&p1))
|
Must(store.Preference().Save(&p1))
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ func TestPreferenceStoreUpdate(t *testing.T) {
|
|||||||
t.Fatal("update should have failed because of changed name")
|
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()
|
p1.AltId = model.NewId()
|
||||||
if err := (<-store.Preference().Update(&p1)).Err; err == nil {
|
if err := (<-store.Preference().Update(&p1)).Err; err == nil {
|
||||||
t.Fatal("update should have failed because of changed alternate id")
|
t.Fatal("update should have failed because of changed alternate id")
|
||||||
@@ -118,7 +118,7 @@ func TestPreferenceGetByName(t *testing.T) {
|
|||||||
p1 := model.Preference{
|
p1 := model.Preference{
|
||||||
UserId: model.NewId(),
|
UserId: model.NewId(),
|
||||||
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
|
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNELS,
|
||||||
Name: model.PREFERENCE_NAME_SHOWHIDE,
|
Name: model.PREFERENCE_NAME_SHOW,
|
||||||
AltId: model.NewId(),
|
AltId: model.NewId(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
var TeamStore = require('../stores/team_store.jsx');
|
var TeamStore = require('../stores/team_store.jsx');
|
||||||
var Client = require('../utils/client.jsx');
|
var Client = require('../utils/client.jsx');
|
||||||
|
var Constants = require('../utils/constants.jsx');
|
||||||
var AsyncClient = require('../utils/async_client.jsx');
|
var AsyncClient = require('../utils/async_client.jsx');
|
||||||
var PreferenceStore = require('../stores/preference_store.jsx');
|
var PreferenceStore = require('../stores/preference_store.jsx');
|
||||||
var utils = require('../utils/utils.jsx');
|
var utils = require('../utils/utils.jsx');
|
||||||
@@ -23,7 +24,8 @@ export default class MoreDirectChannels extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleJoinDirectChannel(channel) {
|
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]);
|
AsyncClient.setPreferences([preference]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ export default class Sidebar extends React.Component {
|
|||||||
teammates.push(teamMemberMap[id]);
|
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
|
// Create lists of all read and unread direct channels
|
||||||
var visibleDirectChannels = [];
|
var visibleDirectChannels = [];
|
||||||
@@ -96,7 +96,8 @@ export default class Sidebar extends React.Component {
|
|||||||
visibleDirectChannels.push(channel);
|
visibleDirectChannels.push(channel);
|
||||||
} else if (forceShow) {
|
} else if (forceShow) {
|
||||||
// make sure that unread direct channels are visible
|
// 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]);
|
AsyncClient.setPreferences([preference]);
|
||||||
|
|
||||||
visibleDirectChannels.push(channel);
|
visibleDirectChannels.push(channel);
|
||||||
@@ -306,7 +307,8 @@ export default class Sidebar extends React.Component {
|
|||||||
if (!channel.leaving) {
|
if (!channel.leaving) {
|
||||||
channel.leaving = true;
|
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(
|
AsyncClient.setPreferences(
|
||||||
[preference],
|
[preference],
|
||||||
() => {
|
() => {
|
||||||
|
|||||||
@@ -645,8 +645,8 @@ export function getDirectChannels() {
|
|||||||
|
|
||||||
callTracker.getDirectChannels = utils.getTimestamp();
|
callTracker.getDirectChannels = utils.getTimestamp();
|
||||||
client.getPreferencesByName(
|
client.getPreferencesByName(
|
||||||
'direct_channels',
|
Constants.Preferences.CATEGORY_DIRECT_CHANNELS,
|
||||||
'show_hide',
|
Constants.Preferences.NAME_SHOW,
|
||||||
(data, textStatus, xhr) => {
|
(data, textStatus, xhr) => {
|
||||||
callTracker.getDirectChannels = 0;
|
callTracker.getDirectChannels = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -286,5 +286,9 @@ module.exports = {
|
|||||||
id: 'mentionHighlightLink',
|
id: 'mentionHighlightLink',
|
||||||
uiName: 'Mention Highlight Link'
|
uiName: 'Mention Highlight Link'
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
Preferences: {
|
||||||
|
CATEGORY_DIRECT_CHANNELS: 'direct_channels',
|
||||||
|
NAME_SHOW: 'show'
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user