Skip to content

Commit

Permalink
Move the kanban board event handling logic to the in-order delivery c…
Browse files Browse the repository at this point in the history
…allback
  • Loading branch information
jannickheisch committed Dec 10, 2023
1 parent fa68496 commit ec0765a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
49 changes: 44 additions & 5 deletions android/tinySSB/app/src/main/assets/web/tremola.js
Original file line number Diff line number Diff line change
Expand Up @@ -988,11 +988,33 @@ function b2f_local_peer(type, identifier, displayname, status) {
* @param {number} e.hdr.tst Timestamp at which the message was created. (Number of milliseconds elapsed since midnight at the beginning of January 1970 00:00 UTC)
* @param {string} e.hdr.ref The message ID of this log entry.
* @param {string} e.hdr.fid The public key of the author encoded in base64.
* @param {[]} e.public The payload of the message
* @param {[]} e.public The payload of the message. The first entry is a String that represents the application to which the message belongs. All additional entries are application-specific parameters.
*
*/

function b2f_new_in_order_event(e) {

console.log("b2f inorder event")

if (!(e.header.fid in tremola.contacts)) {
var a = id2b32(e.header.fid);
tremola.contacts[e.header.fid] = {
"alias": a, "initial": a.substring(0, 1).toUpperCase(),
"color": colors[Math.floor(colors.length * Math.random())],
"iam": "", "forgotten": false
}
load_contact_list()
}

switch (e.public[0]) {
case "KAN":
console.log("New kanban event")
kanban_new_event(e)
break
default:
return
}
persist();
must_redraw = true;
}

/**
Expand All @@ -1007,6 +1029,25 @@ function b2f_new_in_order_event(e) {
*
*/
function b2f_new_incomplete_event(e) {

if (!(e.header.fid in tremola.contacts)) {
var a = id2b32(e.header.fid);
tremola.contacts[e.header.fid] = {
"alias": a, "initial": a.substring(0, 1).toUpperCase(),
"color": colors[Math.floor(colors.length * Math.random())],
"iam": "", "forgotten": false
}
load_contact_list()
}

switch (e.public[0]) {
default:
return
}
persist();
must_redraw = true;


}

/**
Expand All @@ -1018,7 +1059,7 @@ function b2f_new_incomplete_event(e) {
* @param {number} e.hdr.tst Timestamp at which the message was created. (Number of milliseconds elapsed since midnight at the beginning of January 1970 00:00 UTC)
* @param {string} e.hdr.ref The message ID of this log entry.
* @param {string} e.hdr.fid The public key of the author encoded in base64.
* @param {[]} e.public The payload of the message
* @param {[]} e.public The payload of the message. The first entry is a String that represents the application to which the message belongs. All additional entries are application-specific parameters.
*
*/
function b2f_new_event(e) { // incoming SSB log event: we get map with three entries
Expand Down Expand Up @@ -1083,8 +1124,6 @@ function b2f_new_event(e) { // incoming SSB log event: we get map with three ent
// if (curr_scenario == "chats") // the updated conversation could bubble up
load_chat_list();
} else if (e.public[0] == "KAN") { // Kanban board event
console.log("New kanban event")
kanban_new_event(e)
} else if (e.public[0] == "IAM") {
var contact = tremola.contacts[e.header.fid]
var old_iam = contact.iam
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ class WebAppInterface(val act: MainActivity, val webView: WebView) {
// in-order api
val replica = act.tinyRepo.fid2replica(fid)

if (frontend_frontier.getInt(fid.toHex(), 0) == seq && replica != null) {
if (frontend_frontier.getInt(fid.toHex(), 1) == seq && replica != null) {
for (i in seq .. replica.state.max_seq ) {
val content = replica.read(i)
val message_id= replica.get_mid(seq)
Expand Down

0 comments on commit ec0765a

Please sign in to comment.