[mobile] Fix users into collaboration

This commit is contained in:
JuliaSvinareva 2021-05-14 14:03:06 +03:00
parent d16354f4f6
commit 7e7ce909ac
2 changed files with 40 additions and 5 deletions

View file

@ -11,7 +11,8 @@ export class storeUsers {
connection: action,
isDisconnected: observable,
resetDisconnected: action,
hasEditUsers: computed
hasEditUsers: computed,
editUsers: computed
})
}
@ -91,4 +92,38 @@ export class storeUsers {
});
return (length >= 1);
}
get editUsers () {
const idArray = [];
const usersArray = [];
const curUserId = this.currentUser.asc_getIdOriginal();
this.users.forEach((item) => {
const name = AscCommon.UserInfoParser.getParsedName(item.asc_getUserName());
if((item.asc_getState() !== false) && !item.asc_getView()) {
const idOriginal = item.asc_getIdOriginal();
const ind = idArray.indexOf(idOriginal);
if (ind !== -1) {
usersArray[ind].count = usersArray[ind].count + 1;
} else {
const userAttr = {
color: item.asc_getColor(),
id: item.asc_getId(),
idOriginal: item.asc_getIdOriginal(),
name: name,
view: item.asc_getView(),
initials: this.getInitials(name),
count: 1
};
if(idOriginal === curUserId) {
usersArray.unshift(userAttr);
idArray.unshift(idOriginal);
} else {
usersArray.push(userAttr);
idArray.push(idOriginal);
}
}
}
});
return usersArray;
}
}

View file

@ -27,10 +27,10 @@ const PageUsers = inject("users")(observer(props => {
</Navbar>
<BlockTitle>{_t.textEditUser}</BlockTitle>
<List className="coauth__list">
{storeUsers.users.map((model, i) => (
<ListItem title={model.asc_getUserName()} key={i}>
<div slot="media" className='color' style={{backgroundColor: model.asc_getColor()}}>
{storeUsers.getInitials(model.asc_getUserName())}
{storeUsers.editUsers.map((user, i) => (
<ListItem title={user.name + (user.count > 1 ? ` (${user.count})` : '')} key={i}>
<div slot="media" className='color' style={{backgroundColor: user.color}}>
{user.initials}
</div>
</ListItem>
))}