[FIX] Spotlight returning duplicated entries (#2805)
* Update rocketchat.js * Updated search function * Minor improvements * Remove atIndex * Add remove logic to remove duplicate data from response Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
parent
61bc2a4213
commit
d83631d7f2
|
@ -627,8 +627,7 @@ const RocketChat = {
|
||||||
fname: sub.fname,
|
fname: sub.fname,
|
||||||
avatarETag: sub.avatarETag,
|
avatarETag: sub.avatarETag,
|
||||||
t: sub.t,
|
t: sub.t,
|
||||||
encrypted: sub.encrypted,
|
encrypted: sub.encrypted
|
||||||
search: true
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return sub;
|
return sub;
|
||||||
|
@ -648,7 +647,7 @@ const RocketChat = {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
let data = await this.localSearch({ text, filterUsers, filterRooms });
|
const data = await this.localSearch({ text, filterUsers, filterRooms });
|
||||||
|
|
||||||
const usernames = data.map(sub => sub.name);
|
const usernames = data.map(sub => sub.name);
|
||||||
try {
|
try {
|
||||||
|
@ -658,13 +657,18 @@ const RocketChat = {
|
||||||
new Promise((resolve, reject) => this.oldPromise = reject)
|
new Promise((resolve, reject) => this.oldPromise = reject)
|
||||||
]);
|
]);
|
||||||
if (filterUsers) {
|
if (filterUsers) {
|
||||||
data = data.concat(users.map(user => ({
|
users
|
||||||
...user,
|
.filter((item1, index) => users.findIndex(item2 => item2._id === item1._id) === index) // Remove duplicated data from response
|
||||||
rid: user.username,
|
.filter(user => !data.some(sub => user.username === sub.name)) // Make sure to remove users already on local database
|
||||||
name: user.username,
|
.forEach((user) => {
|
||||||
t: 'd',
|
data.push({
|
||||||
search: true
|
...user,
|
||||||
})));
|
rid: user.username,
|
||||||
|
name: user.username,
|
||||||
|
t: 'd',
|
||||||
|
search: true
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (filterRooms) {
|
if (filterRooms) {
|
||||||
rooms.forEach((room) => {
|
rooms.forEach((room) => {
|
||||||
|
|
|
@ -9,8 +9,8 @@ const room = data.channels.detoxpublic.name;
|
||||||
|
|
||||||
async function navigateToRoom() {
|
async function navigateToRoom() {
|
||||||
await searchRoom(room);
|
await searchRoom(room);
|
||||||
await waitFor(element(by.id(`rooms-list-view-item-${ room }`)).atIndex(0)).toBeVisible().withTimeout(60000);
|
await waitFor(element(by.id(`rooms-list-view-item-${ room }`))).toBeVisible().withTimeout(60000);
|
||||||
await element(by.id(`rooms-list-view-item-${ room }`)).atIndex(0).tap();
|
await element(by.id(`rooms-list-view-item-${ room }`)).tap();
|
||||||
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000);
|
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,8 @@ const joinCode = data.channels.detoxpublicprotected.joinCode
|
||||||
|
|
||||||
async function navigateToRoom() {
|
async function navigateToRoom() {
|
||||||
await searchRoom(room);
|
await searchRoom(room);
|
||||||
await waitFor(element(by.id(`rooms-list-view-item-${ room }`)).atIndex(0)).toBeVisible().withTimeout(60000);
|
await waitFor(element(by.id(`rooms-list-view-item-${ room }`))).toBeVisible().withTimeout(60000);
|
||||||
await element(by.id(`rooms-list-view-item-${ room }`)).atIndex(0).tap();
|
await element(by.id(`rooms-list-view-item-${ room }`)).tap();
|
||||||
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000);
|
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ describe('Rooms list screen', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have room item', async() => {
|
it('should have room item', async() => {
|
||||||
await expect(element(by.id('rooms-list-view-item-general')).atIndex(0)).toExist();
|
await expect(element(by.id('rooms-list-view-item-general'))).toExist();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Render - Header
|
// Render - Header
|
||||||
|
|
|
@ -67,12 +67,12 @@ describe('Create room screen', () => {
|
||||||
|
|
||||||
it('should select/unselect user', async() => {
|
it('should select/unselect user', async() => {
|
||||||
// Spotlight issues
|
// Spotlight issues
|
||||||
await element(by.id('select-users-view-item-rocket.cat')).atIndex(0).tap();
|
await element(by.id('select-users-view-item-rocket.cat')).tap();
|
||||||
await waitFor(element(by.id('selected-user-rocket.cat'))).toBeVisible().withTimeout(10000);
|
await waitFor(element(by.id('selected-user-rocket.cat'))).toBeVisible().withTimeout(10000);
|
||||||
await element(by.id('selected-user-rocket.cat')).tap();
|
await element(by.id('selected-user-rocket.cat')).tap();
|
||||||
await waitFor(element(by.id('selected-user-rocket.cat'))).toBeNotVisible().withTimeout(10000);
|
await waitFor(element(by.id('selected-user-rocket.cat'))).toBeNotVisible().withTimeout(10000);
|
||||||
// Spotlight issues
|
// Spotlight issues
|
||||||
await element(by.id('select-users-view-item-rocket.cat')).atIndex(0).tap();
|
await element(by.id('select-users-view-item-rocket.cat')).tap();
|
||||||
await waitFor(element(by.id('selected-user-rocket.cat'))).toBeVisible().withTimeout(10000);
|
await waitFor(element(by.id('selected-user-rocket.cat'))).toBeVisible().withTimeout(10000);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@ async function navigateToRoomActions(type) {
|
||||||
room = data.groups.private.name;
|
room = data.groups.private.name;
|
||||||
}
|
}
|
||||||
await searchRoom(room);
|
await searchRoom(room);
|
||||||
await waitFor(element(by.id(`rooms-list-view-item-${ room }`)).atIndex(0)).toExist().withTimeout(60000);
|
await waitFor(element(by.id(`rooms-list-view-item-${ room }`))).toExist().withTimeout(60000);
|
||||||
await element(by.id(`rooms-list-view-item-${ room }`)).atIndex(0).tap();
|
await element(by.id(`rooms-list-view-item-${ room }`)).tap();
|
||||||
await waitFor(element(by.id('room-view'))).toExist().withTimeout(2000);
|
await waitFor(element(by.id('room-view'))).toExist().withTimeout(2000);
|
||||||
await element(by.id('room-view-header-actions')).tap();
|
await element(by.id('room-view-header-actions')).tap();
|
||||||
await waitFor(element(by.id('room-actions-view'))).toExist().withTimeout(5000);
|
await waitFor(element(by.id('room-actions-view'))).toExist().withTimeout(5000);
|
||||||
|
|
|
@ -14,8 +14,8 @@ async function navigateToRoomInfo(type) {
|
||||||
room = privateRoomName;
|
room = privateRoomName;
|
||||||
}
|
}
|
||||||
await searchRoom(room);
|
await searchRoom(room);
|
||||||
await waitFor(element(by.id(`rooms-list-view-item-${ room }`)).atIndex(0)).toExist().withTimeout(60000);
|
await waitFor(element(by.id(`rooms-list-view-item-${ room }`))).toExist().withTimeout(60000);
|
||||||
await element(by.id(`rooms-list-view-item-${ room }`)).atIndex(0).tap();
|
await element(by.id(`rooms-list-view-item-${ room }`)).tap();
|
||||||
await waitFor(element(by.id('room-view'))).toExist().withTimeout(2000);
|
await waitFor(element(by.id('room-view'))).toExist().withTimeout(2000);
|
||||||
await element(by.id('room-view-header-actions')).tap();
|
await element(by.id('room-view-header-actions')).tap();
|
||||||
await waitFor(element(by.id('room-actions-view'))).toExist().withTimeout(5000);
|
await waitFor(element(by.id('room-actions-view'))).toExist().withTimeout(5000);
|
||||||
|
|
|
@ -193,7 +193,8 @@
|
||||||
"build": "xcodebuild -workspace ios/RocketChatRN.xcworkspace -scheme RocketChatRN -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
|
"build": "xcodebuild -workspace ios/RocketChatRN.xcworkspace -scheme RocketChatRN -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
|
||||||
"type": "ios.simulator",
|
"type": "ios.simulator",
|
||||||
"device": {
|
"device": {
|
||||||
"type": "iPhone 11 Pro"
|
"type": "iPhone 11 Pro",
|
||||||
|
"os": "13.7"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ios.sim.release": {
|
"ios.sim.release": {
|
||||||
|
@ -201,7 +202,8 @@
|
||||||
"build": "xcodebuild -workspace ios/RocketChatRN.xcworkspace -scheme RocketChatRN -configuration Release -sdk iphonesimulator -derivedDataPath ios/build",
|
"build": "xcodebuild -workspace ios/RocketChatRN.xcworkspace -scheme RocketChatRN -configuration Release -sdk iphonesimulator -derivedDataPath ios/build",
|
||||||
"type": "ios.simulator",
|
"type": "ios.simulator",
|
||||||
"device": {
|
"device": {
|
||||||
"type": "iPhone 11 Pro"
|
"type": "iPhone 11 Pro",
|
||||||
|
"os": "13.7"
|
||||||
},
|
},
|
||||||
"artifacts": {
|
"artifacts": {
|
||||||
"plugins": {
|
"plugins": {
|
||||||
|
|
Loading…
Reference in New Issue