Compare commits
3 Commits
bca4440867
...
39abee7f73
Author | SHA1 | Date | |
---|---|---|---|
39abee7f73 | |||
b770619111 | |||
1c44857da4 |
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"type": "tildefriends-app",
|
||||
"emoji": "🦀",
|
||||
"previous": "&Hd6CuhhnZIf13PdFJYZBUYLYZO84WdaKvWXLC29M7Ac=.sha256"
|
||||
"previous": "&C4r2tB/tzPjPSrS3NRiebaNOP94G4FX80yIg7YN9sBQ=.sha256"
|
||||
}
|
||||
|
@@ -625,7 +625,7 @@ class TfComposeElement extends LitElement {
|
||||
<div class="w3-half">
|
||||
<span
|
||||
class="w3-input w3-theme-d1 w3-border"
|
||||
style="resize: vertical; width: 100%; overflow: hidden; white-space: pre-wrap"
|
||||
style="resize: vertical; width: 100%; white-space: pre-wrap"
|
||||
placeholder="Write a post here."
|
||||
id="edit"
|
||||
@input=${this.input}
|
||||
|
@@ -537,7 +537,7 @@ class TfMessageElement extends LitElement {
|
||||
</style>
|
||||
<div
|
||||
class="w3-card-4 ${this.class_background()} w3-border-theme w3-margin-top"
|
||||
style="overflow: auto; overflow-wrap: anywhere; display: block; max-width: 100%"
|
||||
style="overflow-wrap: anywhere; display: block; max-width: 100%"
|
||||
>
|
||||
${inner}
|
||||
</div>
|
||||
|
@@ -411,7 +411,7 @@ class TfTabNewsElement extends LitElement {
|
||||
return cache(html`
|
||||
${this.render_sidebar()}
|
||||
<div
|
||||
style="margin-left: 2in; padding: 0px; top: 0; max-height: 100%; overflow: auto; contain: layout"
|
||||
style="margin-left: 2in; padding: 0px; top: 0; height: 100vh; max-height: 100%; overflow: auto; contain: layout"
|
||||
id="main"
|
||||
class="w3-main"
|
||||
>
|
||||
|
17
core/core.js
17
core/core.js
@@ -199,23 +199,6 @@ async function getProcessBlob(blobId, key, options) {
|
||||
let imports = {
|
||||
core: {
|
||||
broadcast: broadcast.bind(process),
|
||||
register: function (eventName, handler) {
|
||||
if (!process.eventHandlers[eventName]) {
|
||||
process.eventHandlers[eventName] = [];
|
||||
}
|
||||
process.eventHandlers[eventName].push(handler);
|
||||
},
|
||||
unregister: function (eventName, handler) {
|
||||
if (process.eventHandlers[eventName]) {
|
||||
let index = process.eventHandlers[eventName].indexOf(handler);
|
||||
if (index != -1) {
|
||||
process.eventHandlers[eventName].splice(index, 1);
|
||||
}
|
||||
if (process.eventHandlers[eventName].length == 0) {
|
||||
delete process.eventHandlers[eventName];
|
||||
}
|
||||
}
|
||||
},
|
||||
user: getUser(process, process),
|
||||
users: async function () {
|
||||
try {
|
||||
|
66
src/api.js.c
66
src/api.js.c
@@ -147,12 +147,78 @@ static JSValue _tf_api_core_apps(JSContext* context, JSValueConst this_val, int
|
||||
return result;
|
||||
}
|
||||
|
||||
static JSValue _tf_api_core_register(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv, int magic, JSValue* data)
|
||||
{
|
||||
JSValue event_name = argv[0];
|
||||
JSValue handler = argv[1];
|
||||
JSValue process = data[0];
|
||||
JSValue event_handlers = JS_GetPropertyStr(context, process, "eventHandlers");
|
||||
JSAtom atom = JS_ValueToAtom(context, event_name);
|
||||
JSValue array = JS_GetProperty(context, event_handlers, atom);
|
||||
if (!JS_IsArray(context, array))
|
||||
{
|
||||
JS_FreeValue(context, array);
|
||||
array = JS_NewArray(context);
|
||||
JS_SetProperty(context, event_handlers, atom, JS_DupValue(context, array));
|
||||
}
|
||||
JS_SetPropertyUint32(context, array, tf_util_get_length(context, array), JS_DupValue(context, handler));
|
||||
JS_FreeValue(context, array);
|
||||
JS_FreeAtom(context, atom);
|
||||
JS_FreeValue(context, event_handlers);
|
||||
return JS_UNDEFINED;
|
||||
}
|
||||
|
||||
static JSValue _tf_api_core_unregister(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv, int magic, JSValue* data)
|
||||
{
|
||||
JSValue event_name = argv[0];
|
||||
JSValue handler = argv[1];
|
||||
JSValue process = data[0];
|
||||
JSValue event_handlers = JS_GetPropertyStr(context, process, "eventHandlers");
|
||||
JSAtom atom = JS_ValueToAtom(context, event_name);
|
||||
JSValue array = JS_GetProperty(context, event_handlers, atom);
|
||||
|
||||
if (JS_IsArray(context, array))
|
||||
{
|
||||
JSValue index_of = JS_GetPropertyStr(context, array, "indexOf");
|
||||
|
||||
JSValue index = JS_Call(context, index_of, array, 1, &handler);
|
||||
int int_index = -1;
|
||||
JS_ToInt32(context, &int_index, index);
|
||||
if (int_index != -1)
|
||||
{
|
||||
JSValue splice = JS_GetPropertyStr(context, array, "splice");
|
||||
JSValue splice_args[] =
|
||||
{
|
||||
index,
|
||||
JS_NewInt32(context, 1),
|
||||
};
|
||||
JSValue result = JS_Call(context, splice, array, 2, splice_args);
|
||||
JS_FreeValue(context, result);
|
||||
JS_FreeValue(context, splice);
|
||||
}
|
||||
JS_FreeValue(context, index);
|
||||
JS_FreeValue(context, index_of);
|
||||
|
||||
if (tf_util_get_length(context, array) == 0)
|
||||
{
|
||||
JS_DeleteProperty(context, event_handlers, atom, 0);
|
||||
}
|
||||
}
|
||||
|
||||
JS_FreeValue(context, array);
|
||||
JS_FreeAtom(context, atom);
|
||||
JS_FreeValue(context, event_handlers);
|
||||
return JS_UNDEFINED;
|
||||
}
|
||||
|
||||
static JSValue _tf_api_register_imports(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv)
|
||||
{
|
||||
JSValue imports = argv[0];
|
||||
JSValue process = argv[1];
|
||||
JSValue core = JS_GetPropertyStr(context, imports, "core");
|
||||
JS_SetPropertyStr(context, core, "apps", JS_NewCFunctionData(context, _tf_api_core_apps, 1, 0, 1, &process));
|
||||
JS_SetPropertyStr(context, core, "register", JS_NewCFunctionData(context, _tf_api_core_register, 2, 0, 1, &process));
|
||||
JS_SetPropertyStr(context, core, "unregister", JS_NewCFunctionData(context, _tf_api_core_unregister, 2, 0, 1, &process));
|
||||
JS_FreeValue(context, core);
|
||||
return JS_UNDEFINED;
|
||||
}
|
||||
|
Reference in New Issue
Block a user