Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Fix regressions around media uploads failing and causing soft crashes (
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored Nov 7, 2022
1 parent be5a8ca commit 77764d8
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 218 deletions.
4 changes: 2 additions & 2 deletions src/Notifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ export const Notifier = {
return null;
}

if (!content.url) {
logger.warn(`${roomId} has custom notification sound event, but no url key`);
if (typeof content.url !== "string") {
logger.warn(`${roomId} has custom notification sound event, but no url string`);
return null;
}

Expand Down
209 changes: 0 additions & 209 deletions src/components/views/settings/ChangeAvatar.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export default class NotificationsSettingsTab extends React.Component<IProps, IS
type = "audio/ogg";
}

const url = await MatrixClientPeg.get().uploadContent(
const { content_uri: url } = await MatrixClientPeg.get().uploadContent(
this.state.uploadedFile, {
type,
},
Expand Down
9 changes: 5 additions & 4 deletions src/components/views/spaces/SpaceSettingsGeneralTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,14 @@ const SpaceSettingsGeneralTab = ({ matrixClient: cli, space, onFinished }: IProp

const onSave = async () => {
setBusy(true);
const promises = [];
const promises: Promise<unknown>[] = [];

if (avatarChanged) {
if (newAvatar) {
promises.push(cli.sendStateEvent(space.roomId, EventType.RoomAvatar, {
url: await cli.uploadContent(newAvatar),
}, ""));
promises.push((async () => {
const { content_uri: url } = await cli.uploadContent(newAvatar);
await cli.sendStateEvent(space.roomId, EventType.RoomAvatar, { url }, "");
})());
} else {
promises.push(cli.sendStateEvent(space.roomId, EventType.RoomAvatar, {}, ""));
}
Expand Down
2 changes: 0 additions & 2 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1283,8 +1283,6 @@
"This bridge is managed by <user />.": "This bridge is managed by <user />.",
"Workspace: <networkLink/>": "Workspace: <networkLink/>",
"Channel: <channelLink/>": "Channel: <channelLink/>",
"Failed to upload profile picture!": "Failed to upload profile picture!",
"Upload new:": "Upload new:",
"No display name": "No display name",
"Warning!": "Warning!",
"Changing your password on this homeserver will cause all of your other devices to be signed out. This will delete the message encryption keys stored on them, and may make encrypted chat history unreadable.": "Changing your password on this homeserver will cause all of your other devices to be signed out. This will delete the message encryption keys stored on them, and may make encrypted chat history unreadable.",
Expand Down
9 changes: 9 additions & 0 deletions test/Notifier-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,15 @@ describe("Notifier", () => {
});
});

describe("getSoundForRoom", () => {
it("should not explode if given invalid url", () => {
jest.spyOn(SettingsStore, "getValue").mockImplementation((name: string) => {
return { url: { content_uri: "foobar" } };
});
expect(Notifier.getSoundForRoom("!roomId:server")).toBeNull();
});
});

describe("_playAudioNotification", () => {
it.each([
{ event: { is_silenced: true }, count: 0 },
Expand Down

0 comments on commit 77764d8

Please sign in to comment.