0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-25 08:12:37 +01:00

client: Update; Add m.room.name timeline display handler; Various.

This commit is contained in:
Jason Volk 2017-11-06 12:19:37 -08:00
parent d7136bb393
commit 688ff545d6
6 changed files with 151 additions and 35 deletions

View file

@ -2614,6 +2614,8 @@ div.main > form.search label
.ircd .room div.members .menu .item
{
padding-left: 0px;
padding-right: 0px;
}
.ircd .room div.members .menu .item .name

View file

@ -71,7 +71,8 @@ mc.ready = async function(event)
catch(error)
{
console.error("IRCd Charybdis Client: Main exited (error): " + error + " " + error.stack);
mc.unhandled(error);
//mc.unhandled(error);
mc.abort(error);
}
finally
{

View file

@ -161,6 +161,8 @@ mc.io.request.constructor = function(ctx = {})
// Insert request into active table. The request can be aborted hereafter.
mc.io.requests.insert(this);
this.started = mc.now();
// This should be done here for now
this.xhr.open(this.ctx.method, this.ctx.url);
@ -390,6 +392,7 @@ mc.io.request.on.readystatechange = function(event)
{
let state = this.xhr.readyState;
let handler = mc.io.request.on.readystatechange[state];
this.event = event;
// The promise is resolved for the user before the lib's handlers are called.
// This is because the DONE handler has to fulfill all outstanding promises for
@ -499,40 +502,56 @@ mc.io.request.success = function(event)
mc.io.request.error = function(event)
{
let xhr = this.xhr;
let response = xhr.response;
let error =
let error = new mc.error(
{
name:
xhr.statusText == "error"? "Network Request Error":
empty(xhr.statusText)? "abort":
xhr.statusText,
status:
xhr.status != 0? xhr.status : "client side",
m:
xhr.responseType == "json"? xhr.response : undefined,
message:
!empty(this.reason)?
this.reason:
response && xhr.responseType == "text"?
response:
"There may be a network connectivity problem.",
this.response && this.xhr.responseType == "text"?
this.xhr.responseText:
this.started + this.ctx.timeout <= mc.now()?
"timeout":
maybe(() => this.event.detail)?
this.event.detail:
undefined,
name:
this.xhr.statusText == "error"?
"Network Request Error":
this.xhr.statusText == "abort"?
"Network Request Canceled":
!empty(this.xhr.statusText)?
this.xhr.statusText:
this.started + this.ctx.timeout <= mc.now()?
"timeout":
!empty(this.reason)?
this.reason:
!window.navigator.onLine?
"disconnected":
this.started + 10 > mc.now()?
"killed":
"timeout",
status:
this.xhr.status != 0? this.xhr.status : "Client",
m:
this.xhr.responseType == "json"? this.xhr.response : undefined,
request_stack:
this.stack,
event:
this.event,
element:
this.ctx.element,
};
});
if(!empty(error.m))
delete error.message;
//if(!empty(error.m))
// delete error.message;
let data = undefined;
error = new mc.error(error);
mc.io.request.continuation.call(this, error, data);
};

View file

@ -101,6 +101,15 @@ mc.main.init = async function()
*/
mc.main.fini = async function()
{
console.log("Synchronizing WebStorage..."); try
{
mc.storage.sync();
}
catch(error)
{
console.error("Error synchronizing WebStorage: " + error);
}
console.log("Stopping remaining tasks..."); try
{
await mc.main.interrupt();
@ -132,7 +141,7 @@ mc.main.fini = async function()
mc.main.on_logout();
}
console.log("Synchronizing WebStorage..."); try
console.log("Resynchronizing WebStorage..."); try
{
mc.storage.sync();
}
@ -140,6 +149,15 @@ mc.main.fini = async function()
{
console.error("Error synchronizing WebStorage: " + error);
}
console.log("Final angular repaint..."); try
{
mc.ng.apply();
}
catch(error)
{
console.error("Error repainting: " + error);
}
};
/**
@ -172,13 +190,39 @@ mc.main.fault = async function(error)
switch(error.status)
{
case "Client Side":
if(error.name == "abort")
case "Client":
if(error.name == "disconnected")
{
console.warn("client disconnected");
mc.unhandled(error);
return false;
}
if(error.name == "killed")
{
console.error("client fatal");
mc.unhandled(error);
return false;
}
if(error.name == "timeout")
{
console.warn("client timeout");
mc.ng.root().error = undefined;
mc.ng.mc().error = undefined;
return true;
}
console.warn("client unhandled " + error);
mc.unhandled(error);
return false;
default:
console.error("fault unhandled");
throw error;
}
return false;
};
/**

View file

@ -46,18 +46,22 @@ mc.sync = async function(opts = {})
});
let request = mc.m.sync.get(opts);
let data = await request.response;
opts.query.since = maybe(() => data.next_batch);
if(mc.opts.sync_debug)
debug.object(data, mc.opts.sync_debug);
for(let key in data)
{
let handler = mc.sync[key];
if(handler !== undefined)
handler(data[key]);
let data = await request.response;
opts.query.since = maybe(() => data.next_batch);
if(mc.opts.sync_debug)
debug.object(data, mc.opts.sync_debug);
for(let key in data)
{
let handler = mc.sync[key];
if(handler !== undefined)
handler(data[key]);
}
}
return true;
};
mc.sync["rooms"] = function(rooms)

View file

@ -2248,6 +2248,42 @@ type="text/ng-template"
</div>
</script>
<script
id="ircd_room_event__name"
type="text/ng-template"
>
<div
class="changed"
>
<h3
ng-if="room.name"
>
Changed the room name
</h3>
<h3
ng-if="!room.name"
>
Named the room
</h3>
</div>
<div
class="name row nowrap grow center"
>
<h2
class="name full-center"
ng-if="room.name"
>
from {{ room.name }} to {{ event.content.name }}
</h2>
<h2
class="name full-center"
ng-if="!room.name"
>
{{ event.content.name }}
</h2>
</div>
</script>
<script
id="ircd_room_event_unhandled"
type="text/ng-template"
@ -2496,6 +2532,16 @@ type="text/ng-template"
>
</div>
</div>
<div
class="state name"
ng-switch-when="m.room.name"
>
<div
ng-include="'ircd_room_event__name'"
>
</div>
</div>
<div
class="default unhandled"