forked from mystiq/hydrogen-web
Merge pull request #19 from vector-im/bwindels/small-bits
Various small bits
This commit is contained in:
commit
0d3ab21044
4 changed files with 28 additions and 15 deletions
|
@ -15,18 +15,11 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
export function avatarInitials(name) {
|
||||
let words = name.split(" ");
|
||||
if (words.length === 1) {
|
||||
words = words[0].split("-");
|
||||
}
|
||||
words = words.slice(0, 2);
|
||||
return words.reduce((i, w) => {
|
||||
let firstChar = w.charAt(0);
|
||||
let firstChar = name.charAt(0);
|
||||
if (firstChar === "!" || firstChar === "@" || firstChar === "#") {
|
||||
firstChar = w.charAt(1);
|
||||
firstChar = name.charAt(1);
|
||||
}
|
||||
return i + firstChar.toUpperCase();
|
||||
}, "");
|
||||
return firstChar.toUpperCase();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -45,8 +45,12 @@ export class RoomTileViewModel extends ViewModel {
|
|||
}
|
||||
|
||||
compare(other) {
|
||||
// sort by name for now
|
||||
return this._room.name.localeCompare(other._room.name);
|
||||
// sort alphabetically
|
||||
const nameCmp = this._room.name.localeCompare(other._room.name);
|
||||
if (nameCmp === 0) {
|
||||
return this._room.id.localeCompare(other._room.id);
|
||||
}
|
||||
return nameCmp;
|
||||
}
|
||||
|
||||
get isOpen() {
|
||||
|
|
|
@ -14,6 +14,17 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
export class WrappedError extends Error {
|
||||
constructor(message, cause) {
|
||||
super(`${message}: ${cause.message}`);
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
get name() {
|
||||
return "WrappedError";
|
||||
}
|
||||
}
|
||||
|
||||
export class HomeServerError extends Error {
|
||||
constructor(method, url, body, status) {
|
||||
super(`${body ? body.error : status} on ${method} ${url}`);
|
||||
|
|
|
@ -21,6 +21,7 @@ import {GapWriter} from "./timeline/persistence/GapWriter.js";
|
|||
import {Timeline} from "./timeline/Timeline.js";
|
||||
import {FragmentIdComparer} from "./timeline/FragmentIdComparer.js";
|
||||
import {SendQueue} from "./sending/SendQueue.js";
|
||||
import {WrappedError} from "../error.js"
|
||||
|
||||
export class Room extends EventEmitter {
|
||||
constructor({roomId, storage, hsApi, emitCollectionChange, sendScheduler, pendingEvents, user}) {
|
||||
|
@ -67,8 +68,12 @@ export class Room extends EventEmitter {
|
|||
}
|
||||
|
||||
load(summary, txn) {
|
||||
try {
|
||||
this._summary.load(summary);
|
||||
return this._syncWriter.load(txn);
|
||||
} catch (err) {
|
||||
throw new WrappedError(`Could not load room ${this._roomId}`, err);
|
||||
}
|
||||
}
|
||||
|
||||
sendEvent(eventType, content) {
|
||||
|
|
Loading…
Reference in a new issue