Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chat threads #531

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
f57eb86
Had to drop node to 16 for tests to work. See https://github.com/node…
timbl Feb 21, 2023
99d93f1
tests work only node 16. starting thread stuff
timbl Feb 22, 2023
a3df52b
Ass new icon for Reply
timbl Feb 24, 2023
ef62741
Thread display is basically working
timbl Feb 28, 2023
24320e3
Make new messages on thread etc
timbl Feb 28, 2023
372f872
async
timbl Mar 2, 2023
d577e51
lint issues
bourgeoa Mar 9, 2023
78404ed
merge main
bourgeoa Mar 9, 2023
a27cf0c
update messageTools.test.ts
bourgeoa Mar 9, 2023
86be5ab
skip test : complains if you have multiple bookmark docs
bourgeoa Mar 9, 2023
029ae1f
update package-lock.json
bourgeoa Mar 9, 2023
047d5bd
working on sentiments
timbl Mar 9, 2023
8415fae
hand merged
timbl Mar 9, 2023
7fe156e
limit srollback on thread
timbl Mar 9, 2023
ca09f65
initially load thread at the right place in timeline
timbl Mar 13, 2023
ff562b6
remove jss in acl
timea-solid Mar 20, 2023
90e6fe9
remove jss in header and footer, move stlys of acl in main style.js
timea-solid Mar 20, 2023
3369248
cleaned buttons from jss
timea-solid Mar 20, 2023
ed5d859
improved styles
timea-solid Mar 20, 2023
d980bb0
working on removing jss
timea-solid Mar 26, 2023
9daf358
fixing some more styles
timea-solid Mar 27, 2023
76bcd5f
updated snapshots accordingly
timea-solid Mar 27, 2023
53b74ba
avoid bing caught in loops
timbl Apr 4, 2023
8e5e7ac
added transform and test options to jest config
SharonStrats Apr 8, 2023
068520e
fixed lint errors
SharonStrats Apr 8, 2023
f9e2277
Merge branch 'main' into chat-threads
SharonStrats Apr 8, 2023
2dcc5e4
fixed broken styles
timea-solid Apr 9, 2023
36cc321
Update src/chat/bookmarks.js
bourgeoa Apr 10, 2023
d81bf22
Merge branch 'style' into chat-threads
timea-solid Apr 11, 2023
99dd2a8
Update src/chat/infinite.js
timea-solid Apr 11, 2023
eb85c49
Update src/chat/bookmarks.js
timea-solid Apr 11, 2023
ce90c57
Update src/chat/bookmarks.js
timea-solid Apr 11, 2023
f3028bd
Update src/chat/messageTools.js
timea-solid Apr 11, 2023
95bf305
Update src/chat/chatLogic.js
timea-solid Apr 11, 2023
e1d1a02
Update src/chat/messageTools.js
timea-solid Apr 11, 2023
c79215f
Update src/chat/thread.js
timea-solid Apr 11, 2023
ac08160
timbl code
timbl Apr 12, 2023
265a274
merged with sharon debug()
timbl Apr 12, 2023
efb1491
unblock initial load
timbl Apr 14, 2023
c6bf02e
merge main
bourgeoa Apr 16, 2023
f4da6dd
return message
bourgeoa May 29, 2023
5ccea2e
typing error
bourgeoa May 29, 2023
62cefbe
comment out ignore isReplaced(message)
bourgeoa May 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/chat/chatLogic.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,39 +113,57 @@ export class ChatChannel {

// ////////// Utility functions

// Have to not loop forever if fed loops
export async function allVersions (message) {
const versions = [message]
const done = {}
done[message.ur] = true
let m = message
while (true) { // earlier?
const prev = store.any(null, ns.dct('isReplacedBy'), m, m.doc())
if (!prev) break
if (!prev || done[prev.uri]) break
await store.fetcher.load(prev)
versions.unshift(prev)
done[prev.uri] = true
m = prev
}
m = message
while (true) { // later?
const next = store.any(m, ns.dct('isReplacedBy'), null, m.doc())
if (!next) break
if (!next || done[next.uri]) break
versions.push(next)
done[next.uri] = true
m = next
}
return versions
}

export async function originalVersion (message) {
let msg = message
const done = {}
// done[message.ur] = true
while (msg) {
if (done[msg.uri]) {
console.error('originalVersion: verion loop' + message)
return message
}
done[msg.uri] = true
message = msg
await store.fetcher.load(message)
msg = store.any(null, ns.dct('isReplacedBy'), message, message.doc()) // @@@ may need to load doc
msg = store.any(null, ns.dct('isReplacedBy'), message, message.doc())
}
return message
}

export async function mostRecentVersion (message) {
let msg = message
const done = {}
while (msg) {
if (done[msg.uri]) {
console.error('mostRecentVersion: verion loop' + message)
return message
}
done[msg.uri] = true
message = msg
await store.fetcher.load(message)
msg = store.any(message, ns.dct('isReplacedBy'), null, message.doc())
Expand Down
13 changes: 9 additions & 4 deletions src/chat/infinite.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as ns from '../ns'
import * as widgets from '../widgets'
// import * as pad from '../pad'
// import { DateFolder } from './dateFolder'
import { ChatChannel, isDeleted, mostRecentVersion } from './chatLogic'
import { ChatChannel, isDeleted, isReplaced, mostRecentVersion } from './chatLogic'
import { renderMessageEditor, renderMessageRow } from './message'

// const UI = { authn, icons, ns, media, pad, $rdf, store, style, utils, widgets }
Expand Down Expand Up @@ -141,11 +141,14 @@ export async function infiniteMessageArea (dom, wasStore, chatChannel, options)

// Called once per original message displayed
async function addMessage (message, messageTable) {
const latest = await mostRecentVersion(message)
// const latest = await mostRecentVersion(message)
// const content = store.any(latest, ns.sioc('content'))
if (isDeleted(latest) && !options.showDeletedMessages) {
if (isDeleted(message) && !options.showDeletedMessages) {
return // ignore deleted messaged -- @@ could also leave a placeholder
}
if (isReplaced(message)) { //
return // this is old version
}
let thread = store.any(null, ns.sioc('has_member'), message, message.doc())
const id = store.any(message, ns.sioc('id'), null, message.doc())
if (id && !thread) {
Expand Down Expand Up @@ -602,7 +605,9 @@ export async function infiniteMessageArea (dom, wasStore, chatChannel, options)

async function loadInitialContent () {
function yank () {
selectedMessageTable.selectedElement.scrollIntoView({ block: 'center' })
if (selectedMessageTable && selectedMessageTable.selectedElement) {
selectedMessageTable.selectedElement.scrollIntoView({ block: 'center' })
}
}

// During initial load ONLY keep scroll to selected thing or bottom
Expand Down
4 changes: 4 additions & 0 deletions src/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export function recordSharedPreferences (subject, context) {
return new Promise(function (resolve, reject) {
const sharedPreferences = kb.any(subject, ns.ui('sharedPreferences'))
if (!sharedPreferences) {
if (!kb.updater.editable(subject.doc())) {
console.log(` Cant make shared preferences, may not change ${subject.doc}`)
Copy link
Contributor

@TallTed TallTed Apr 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log(` Cant make shared preferences, may not change ${subject.doc}`)
console.log(` Cannot make shared preferences; may not change ${subject.doc}`)

resolve(context)
}
const sp = $rdf.sym(subject.doc().uri + '#SharedPreferences')
const ins = [
$rdf.st(subject, ns.ui('sharedPreferences'), sp, subject.doc())
Expand Down