Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Display message failed to send for MLS (FS-2030) #15273

Merged
merged 3 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"@emotion/react": "11.11.0",
"@types/eslint": "8.37.0",
"@wireapp/avs": "9.2.15",
"@wireapp/core": "40.3.0",
"@wireapp/core": "40.3.1",
"@wireapp/lru-cache": "3.8.1",
"@wireapp/react-ui-kit": "9.7.2",
"@wireapp/store-engine-dexie": "2.1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ import {backendErrorLink, warning} from '../Warnings.styles';

export type User = {qualifiedId: QualifiedId; name: () => string};
type Props = {
failedToSend: {queued?: QualifiedUserClients; failed?: QualifiedId[]};
failedToSend: {
queued?: QualifiedUserClients | QualifiedId[];
failed?: QualifiedId[];
};
isMessageFocused: boolean;
knownUsers: User[];
};
Expand All @@ -43,8 +46,25 @@ const config = Config.getConfig();

type ParsedUsers = {namedUsers: User[]; unknownUsers: QualifiedId[]};

function generateNamedUsers(users: User[], userClients: QualifiedUserClients): ParsedUsers {
return Object.entries(userClients).reduce<ParsedUsers>(
function generateNamedUsers(
users: User[],
userClientsOrQualifiedIds: QualifiedUserClients | QualifiedId[],
): ParsedUsers {
if (Array.isArray(userClientsOrQualifiedIds)) {
return userClientsOrQualifiedIds.reduce<ParsedUsers>(
(parsedUsers, currentQulifiedId) => {
const user = users.find(user => matchQualifiedIds(user.qualifiedId, currentQulifiedId));
if (user && user.name()) {
parsedUsers.namedUsers.push(user);
} else {
parsedUsers.unknownUsers.push(currentQulifiedId);
}
return parsedUsers;
},
{namedUsers: [], unknownUsers: []},
);
}
return Object.entries(userClientsOrQualifiedIds).reduce<ParsedUsers>(
(namedUsers, [domain, domainUsers]) => {
const domainNamedUsers = Object.keys(domainUsers).reduce<ParsedUsers>(
(domainNamedUsers, userId) => {
Expand Down Expand Up @@ -81,11 +101,11 @@ export const PartialFailureToSendWarning = ({failedToSend, isMessageFocused, kno
const [isOpen, setIsOpen] = useState(false);
const {queued = {}, failed = []} = failedToSend;

const userCount = Array.isArray(queued)
? queued.length
: Object.entries(queued).reduce((count, [_domain, users]) => count + Object.keys(users).length, 0) + failed.length;
const messageFocusedTabIndex = useMessageFocusedTabIndex(isMessageFocused);

const userCount =
Object.entries(queued).reduce((count, [_domain, users]) => count + Object.keys(users).length, 0) + failed.length;

const showToggle = userCount > 1;

const {namedUsers, unknownUsers} = generateNamedUsers(knownUsers, queued);
Expand Down
5 changes: 3 additions & 2 deletions src/script/entity/message/ContentMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ export class ContentMessage extends Message {
public readonly is_liked: ko.PureComputed<boolean>;
public readonly like_caption: ko.PureComputed<string>;
public readonly other_likes: ko.PureComputed<User[]>;
public readonly failedToSend: ko.Observable<{queued?: QualifiedUserClients; failed?: QualifiedId[]} | undefined> =
ko.observable();
public readonly failedToSend: ko.Observable<
{queued?: QualifiedUserClients | QualifiedId[]; failed?: QualifiedId[]} | undefined
> = ko.observable();
// raw content of a file that was supposed to be sent but failed. Is undefined if the message has been successfully sent
public readonly fileData: ko.Observable<Blob | undefined> = ko.observable();
public readonly quote: ko.Observable<QuoteEntity>;
Expand Down
2 changes: 1 addition & 1 deletion src/script/storage/record/EventRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type SentEvent = {
/** raw content of a file that was supposed to be sent but failed. Is undefined if the message has been successfully sent */
fileData?: Blob;
failedToSend?: {
queue?: QualifiedUserClients;
queue?: QualifiedUserClients | QualifiedId[];
failed?: QualifiedId[];
};
};
Expand Down
20 changes: 10 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5747,9 +5747,9 @@ __metadata:
languageName: node
linkType: hard

"@wireapp/api-client@npm:^24.15.0":
version: 24.15.0
resolution: "@wireapp/api-client@npm:24.15.0"
"@wireapp/api-client@npm:^24.15.1":
version: 24.15.1
resolution: "@wireapp/api-client@npm:24.15.1"
dependencies:
"@wireapp/commons": ^5.1.0
"@wireapp/priority-queue": ^2.1.1
Expand All @@ -5762,7 +5762,7 @@ __metadata:
spark-md5: 3.0.2
tough-cookie: 4.1.2
ws: 8.11.0
checksum: 5a2a6dad73b56110690f6e62bd7f45bb7ed1ccdaaa748f8207fb7da987150dd7e2c8cf8cfd68a7c3c951e9ac69afd49dd2335157156dff277c3f72efc3695273
checksum: a0b0d3bc398ddb5dec12642c61efb46306228ff2f2875abb4d62406612ce2e7e31b6f21433b8597b90adcc9e83bc744f070b2664a54d872401b216c72b7d3162
languageName: node
linkType: hard

Expand Down Expand Up @@ -5815,11 +5815,11 @@ __metadata:
languageName: node
linkType: hard

"@wireapp/core@npm:40.3.0":
version: 40.3.0
resolution: "@wireapp/core@npm:40.3.0"
"@wireapp/core@npm:40.3.1":
version: 40.3.1
resolution: "@wireapp/core@npm:40.3.1"
dependencies:
"@wireapp/api-client": ^24.15.0
"@wireapp/api-client": ^24.15.1
"@wireapp/commons": ^5.1.0
"@wireapp/core-crypto": 0.8.2
"@wireapp/cryptobox": 12.8.0
Expand All @@ -5836,7 +5836,7 @@ __metadata:
logdown: 3.3.1
long: ^5.2.0
uuidjs: 4.2.13
checksum: 975932a904843790651cf7f28b0a0df5e83cdd3d3a631caef5ded9e08b91e316e128310427e75fd91650083dcaace8cecd2df46b321b52ac9b4cfbd4313803f4
checksum: 16c5d181043300a7e77a4a9012ef5faf828488a49c62db923663dadc96cfde93a84568f8f92e92750eabb42b87b7db5d5bd3fd5832d759302e3331864262721e
languageName: node
linkType: hard

Expand Down Expand Up @@ -18625,7 +18625,7 @@ dexie@latest:
"@typescript-eslint/parser": ^5.59.8
"@wireapp/avs": 9.2.15
"@wireapp/copy-config": 2.1.0
"@wireapp/core": 40.3.0
"@wireapp/core": 40.3.1
"@wireapp/eslint-config": 2.2.1
"@wireapp/lru-cache": 3.8.1
"@wireapp/prettier-config": 0.6.0
Expand Down