forked from Ivasoft/mattermost-mobile
[Gekidou] - Channel Intro (#5846)
* Channel Intro * Move avatar margins to post component per feedback review * Channel intro redesign * Fix preferences unit test * Change group intro sizes * Add Bot tag to DM Intro if they have it * fix channel isTablet layout on split screen * update snapshot
This commit is contained in:
@@ -151,9 +151,8 @@ describe('*** Operator: User Handlers tests ***', () => {
|
||||
expect(spyOnHandleRecords).toHaveBeenCalledWith({
|
||||
fieldName: 'user_id',
|
||||
createOrUpdateRawValues: preferences,
|
||||
deleteRawValues: [],
|
||||
tableName: 'Preference',
|
||||
prepareRecordsOnly: false,
|
||||
prepareRecordsOnly: true,
|
||||
findMatchingRecordBy: isRecordPreferenceEqualToRaw,
|
||||
transformer: transformPreferenceRecord,
|
||||
});
|
||||
@@ -163,6 +162,7 @@ describe('*** Operator: User Handlers tests ***', () => {
|
||||
expect.assertions(2);
|
||||
const channelMemberships: ChannelMembership[] = [
|
||||
{
|
||||
id: '17bfnb1uwb8epewp4q3x3rx9go-9ciscaqbrpd6d8s68k76xb9bte',
|
||||
channel_id: '17bfnb1uwb8epewp4q3x3rx9go',
|
||||
user_id: '9ciscaqbrpd6d8s68k76xb9bte',
|
||||
roles: 'wqyby5r5pinxxdqhoaomtacdhc',
|
||||
@@ -181,6 +181,7 @@ describe('*** Operator: User Handlers tests ***', () => {
|
||||
scheme_admin: false,
|
||||
},
|
||||
{
|
||||
id: '1yw6gxfr4bn1jbyp9nr7d53yew-9ciscaqbrpd6d8s68k76xb9bte',
|
||||
channel_id: '1yw6gxfr4bn1jbyp9nr7d53yew',
|
||||
user_id: '9ciscaqbrpd6d8s68k76xb9bte',
|
||||
roles: 'channel_user',
|
||||
|
||||
@@ -59,7 +59,12 @@ const UserHandler = (superclass: any) => class extends superclass {
|
||||
);
|
||||
}
|
||||
|
||||
const createOrUpdateRawValues = getUniqueRawsBy({raws: channelMemberships, key: 'channel_id'});
|
||||
const memberships: ChannelMember[] = channelMemberships.map((m) => ({
|
||||
id: `${m.channel_id}-${m.user_id}`,
|
||||
...m,
|
||||
}));
|
||||
|
||||
const createOrUpdateRawValues = getUniqueRawsBy({raws: memberships, key: 'id'});
|
||||
|
||||
return this.handleRecords({
|
||||
fieldName: 'user_id',
|
||||
@@ -87,33 +92,36 @@ const UserHandler = (superclass: any) => class extends superclass {
|
||||
}
|
||||
|
||||
// WE NEED TO SYNC THE PREFS FROM WHAT WE GOT AND WHAT WE HAVE
|
||||
const deleteRawValues: PreferenceType[] = [];
|
||||
const deleteValues: PreferenceModel[] = [];
|
||||
if (sync) {
|
||||
const stored = await this.database.get(PREFERENCE).fetch() as PreferenceModel[];
|
||||
const stored = await this.database.get(PREFERENCE).query().fetch() as PreferenceModel[];
|
||||
for (const pref of stored) {
|
||||
const exists = preferences.findIndex((p) => p.category === pref.category && p.name === pref.name) > -1;
|
||||
if (!exists) {
|
||||
deleteRawValues.push({
|
||||
category: pref.category,
|
||||
name: pref.name,
|
||||
user_id: pref.userId,
|
||||
value: pref.value,
|
||||
});
|
||||
pref.prepareDestroyPermanently();
|
||||
deleteValues.push(pref);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const createOrUpdateRawValues = getUniqueRawsBy({raws: preferences, key: 'name'});
|
||||
|
||||
return this.handleRecords({
|
||||
const records: PreferenceModel[] = await this.handleRecords({
|
||||
fieldName: 'user_id',
|
||||
findMatchingRecordBy: isRecordPreferenceEqualToRaw,
|
||||
transformer: transformPreferenceRecord,
|
||||
prepareRecordsOnly,
|
||||
createOrUpdateRawValues,
|
||||
deleteRawValues,
|
||||
prepareRecordsOnly: true,
|
||||
createOrUpdateRawValues: preferences,
|
||||
tableName: PREFERENCE,
|
||||
});
|
||||
|
||||
if (deleteValues.length) {
|
||||
records.push(...deleteValues);
|
||||
}
|
||||
|
||||
if (records.length && !prepareRecordsOnly) {
|
||||
await this.batchRecords(records);
|
||||
}
|
||||
|
||||
return records;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user