mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
show error for attachments still need upload but missing after refresh
This commit is contained in:
parent
18407e17a8
commit
8b8d06cf3e
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import {MessageTile} from "./MessageTile.js";
|
||||||
|
|
||||||
|
export class MissingAttachmentTile extends MessageTile {
|
||||||
|
get shape() {
|
||||||
|
return "missing-attachment"
|
||||||
|
}
|
||||||
|
|
||||||
|
get label() {
|
||||||
|
const name = this._getContent().body;
|
||||||
|
const msgtype = this._getContent().msgtype;
|
||||||
|
if (msgtype === "m.image") {
|
||||||
|
return this.i18n`The image ${name} wasn't fully sent previously and could not be recovered.`;
|
||||||
|
} else {
|
||||||
|
return this.i18n`The file ${name} wasn't fully sent previously and could not be recovered.`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -23,12 +23,15 @@ import {RoomNameTile} from "./tiles/RoomNameTile.js";
|
|||||||
import {RoomMemberTile} from "./tiles/RoomMemberTile.js";
|
import {RoomMemberTile} from "./tiles/RoomMemberTile.js";
|
||||||
import {EncryptedEventTile} from "./tiles/EncryptedEventTile.js";
|
import {EncryptedEventTile} from "./tiles/EncryptedEventTile.js";
|
||||||
import {EncryptionEnabledTile} from "./tiles/EncryptionEnabledTile.js";
|
import {EncryptionEnabledTile} from "./tiles/EncryptionEnabledTile.js";
|
||||||
|
import {MissingAttachmentTile} from "./tiles/MissingAttachmentTile.js";
|
||||||
|
|
||||||
export function tilesCreator(baseOptions) {
|
export function tilesCreator(baseOptions) {
|
||||||
return function tilesCreator(entry, emitUpdate) {
|
return function tilesCreator(entry, emitUpdate) {
|
||||||
const options = Object.assign({entry, emitUpdate}, baseOptions);
|
const options = Object.assign({entry, emitUpdate}, baseOptions);
|
||||||
if (entry.isGap) {
|
if (entry.isGap) {
|
||||||
return new GapTile(options);
|
return new GapTile(options);
|
||||||
|
} else if (entry.isPending && entry.pendingEvent.isMissingAttachments) {
|
||||||
|
return new MissingAttachmentTile(options);
|
||||||
} else if (entry.eventType) {
|
} else if (entry.eventType) {
|
||||||
switch (entry.eventType) {
|
switch (entry.eventType) {
|
||||||
case "m.room.message": {
|
case "m.room.message": {
|
||||||
|
@ -64,6 +64,10 @@ export class PendingEvent {
|
|||||||
return this._data.needsUpload && !this.aborted;
|
return this._data.needsUpload && !this.aborted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isMissingAttachments() {
|
||||||
|
return this.needsUpload && !this._attachments;
|
||||||
|
}
|
||||||
|
|
||||||
setEncrypting() {
|
setEncrypting() {
|
||||||
this._status = SendStatus.Encrypting;
|
this._status = SendStatus.Encrypting;
|
||||||
this._emitUpdate("status");
|
this._emitUpdate("status");
|
||||||
@ -96,6 +100,9 @@ export class PendingEvent {
|
|||||||
if (!this.needsUpload) {
|
if (!this.needsUpload) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!this._attachments) {
|
||||||
|
throw new Error("attachments missing");
|
||||||
|
}
|
||||||
if (this.needsEncryption) {
|
if (this.needsEncryption) {
|
||||||
this._status = SendStatus.EncryptingAttachments;
|
this._status = SendStatus.EncryptingAttachments;
|
||||||
this._emitUpdate("status");
|
this._emitUpdate("status");
|
||||||
|
@ -19,6 +19,7 @@ import {GapView} from "./timeline/GapView.js";
|
|||||||
import {TextMessageView} from "./timeline/TextMessageView.js";
|
import {TextMessageView} from "./timeline/TextMessageView.js";
|
||||||
import {ImageView} from "./timeline/ImageView.js";
|
import {ImageView} from "./timeline/ImageView.js";
|
||||||
import {FileView} from "./timeline/FileView.js";
|
import {FileView} from "./timeline/FileView.js";
|
||||||
|
import {MissingAttachmentView} from "./timeline/MissingAttachmentView.js";
|
||||||
import {AnnouncementView} from "./timeline/AnnouncementView.js";
|
import {AnnouncementView} from "./timeline/AnnouncementView.js";
|
||||||
|
|
||||||
function viewClassForEntry(entry) {
|
function viewClassForEntry(entry) {
|
||||||
@ -30,6 +31,7 @@ function viewClassForEntry(entry) {
|
|||||||
return TextMessageView;
|
return TextMessageView;
|
||||||
case "image": return ImageView;
|
case "image": return ImageView;
|
||||||
case "file": return FileView;
|
case "file": return FileView;
|
||||||
|
case "missing-attachment": return MissingAttachmentView;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import {TemplateView} from "../../../general/TemplateView.js";
|
||||||
|
import {renderMessage} from "./common.js";
|
||||||
|
|
||||||
|
export class MissingAttachmentView extends TemplateView {
|
||||||
|
render(t, vm) {
|
||||||
|
const cancel = t.button({className: "link", onClick: () => vm.abortSending()}, vm.i18n`Cancel`);
|
||||||
|
return renderMessage(t, vm, t.p([vm.label, " ", cancel]));
|
||||||
|
}
|
||||||
|
}
|
@ -24,7 +24,7 @@ export function renderMessage(t, vm, children) {
|
|||||||
pending: vm.isPending,
|
pending: vm.isPending,
|
||||||
unverified: vm.isUnverified,
|
unverified: vm.isUnverified,
|
||||||
continuation: vm => vm.isContinuation,
|
continuation: vm => vm.isContinuation,
|
||||||
messageStatus: vm => vm.shape === "message-status",
|
messageStatus: vm => vm.shape === "message-status" || vm.shape === "missing-attachment",
|
||||||
};
|
};
|
||||||
|
|
||||||
const profile = t.div({className: "profile"}, [
|
const profile = t.div({className: "profile"}, [
|
||||||
|
Loading…
Reference in New Issue
Block a user