minor fixes around remote avatars

This commit is contained in:
or-else
2022-01-27 15:17:42 -08:00
parent 5cfcd5789f
commit a02be831f2
7 changed files with 14 additions and 16 deletions
+3 -3
View File
@@ -1,6 +1,4 @@
// File and image helper functions.
import { MAX_INBAND_ATTACHMENT_SIZE, MAX_IMAGE_DIM } from '../config.js';
import { bytesToHumanSize } from './strformat.js'
// Supported image MIME types and corresponding file extensions.
export const SUPPORTED_IMAGE_FORMATS = ['image/jpeg', 'image/gif', 'image/png', 'image/svg', 'image/svg+xml'];
@@ -9,11 +7,13 @@ export const MIME_EXTENSIONS = ['jpg', 'gif', 'png',
// Get an URL from a theCard photo: either create a data: URL or return reference URL.
export function makeImageUrl(photo) {
if (photo && typeof photo == 'object') {
if (photo.ref) {
return photo.ref
}
if (photo.data && photo.type) {
const mime = photo.type.startsWith('image/') ? photo.type : ('image/' + photo.type);
return 'data:' + mime + ';base64,' + photo.data;
}
return photo.ref;
}
return null;
}
+1 -1
View File
@@ -34,7 +34,7 @@ export default class AvatarUpload extends React.Component {
render() {
// Randomize id value in case more than one AvatarUpload is shown
// at the same time.
const randId = 'file-input-avatar-' + (Math.random() + '').substr(2);
const randId = 'file-input-avatar-' + ('' + Math.random()).substring(0, 4);
const className = 'avatar-upload' + (this.props.readOnly ? ' read-only' : '');
return (
<div className={className}>
+2 -2
View File
@@ -10,8 +10,8 @@ import AvatarUpload from './avatar-upload.jsx';
import InPlaceEdit from './in-place-edit.jsx';
import TagManager from './tag-manager.jsx';
import { AVATAR_SIZE, MAX_AVATAR_BYTES, MAX_EXTERN_ATTACHMENT_SIZE,
MAX_INBAND_ATTACHMENT_SIZE, MAX_TITLE_LENGTH, MAX_TOPIC_DESCRIPTION_LENGTH } from '../config.js';
import { AVATAR_SIZE, MAX_AVATAR_BYTES, MAX_EXTERN_ATTACHMENT_SIZE, MAX_TITLE_LENGTH,
MAX_TOPIC_DESCRIPTION_LENGTH } from '../config.js';
import { imageScaled, blobToBase64, makeImageUrl } from '../lib/blob-helpers.js';
import { arrayEqual, theCard } from '../lib/utils.js';
+5 -7
View File
@@ -113,20 +113,18 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export */ "base64ReEncode": () => (/* binding */ base64ReEncode),
/* harmony export */ "base64ToBlob": () => (/* binding */ base64ToBlob)
/* harmony export */ });
/* harmony import */ var _config_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../config.js */ "./src/config.js");
/* harmony import */ var _strformat_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./strformat.js */ "./src/lib/strformat.js");
const SUPPORTED_IMAGE_FORMATS = ['image/jpeg', 'image/gif', 'image/png', 'image/svg', 'image/svg+xml'];
const MIME_EXTENSIONS = ['jpg', 'gif', 'png', 'svg', 'svg'];
function makeImageUrl(photo) {
if (photo && typeof photo == 'object') {
if (photo.ref) {
return photo.ref;
}
if (photo.data && photo.type) {
const mime = photo.type.startsWith('image/') ? photo.type : 'image/' + photo.type;
return 'data:' + mime + ';base64,' + photo.data;
}
return photo.ref;
}
return null;
@@ -7638,7 +7636,7 @@ class AvatarUpload extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
}
render() {
const randId = 'file-input-avatar-' + (Math.random() + '').substr(2);
const randId = 'file-input-avatar-' + ('' + Math.random()).substring(0, 4);
const className = 'avatar-upload' + (this.props.readOnly ? ' read-only' : '');
return react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
className: className
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long