Warning: session_start(): open(/var/lib/php/sessions/sess_8tur5isdc0hfoujqinpitc8dmh, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
sclass SimpleSnippetSearch extends DynModule {
S query;
L result;
transient Q q;
transient int maxInputLength = 120;
transient WaitForStableValue waitForStableValue = new(1.0);
transient volatile bool calculating;
transient JTable table;
transient ReliableSingleThread rst;
transient SimpleLiveValue lvQuery = stringLiveValue();
JComponent visualize() {
ret jLiveValueSection(lvQuery, dataToTable_uneditable(result, table = sexyTable()));
}
void unvisualize2() { table = null; }
void start {
lvQuery.set(query);
q = startQ();
ownTimer(doEvery(1000, r update));
}
void update {
lock programLock();
S s = dm_getInterestingString();
if (nempty(s) && l(s) <= maxInputLength) waitForStableValue.set(s);
fS q = waitForStableValue!;
if (nempty(q) && neq(q, query) && allowedToSearch())
this.q.add(r { calc(q) });
}
void calc(S q) {
if (eq(query, q)) ret;
query = q; result = null;
lvQuery.set(q);
calculating = true;
try {
L l = tbSearch(q);
result = map(l, func(Snippet s) -> SS {
litorderedmap("ID + Title" := snippetWithTitle(s), "Type" := snippetTypeName(s.type))
});
JTable t = table;
if (t != null)
dataToTable_uneditable(result, t);
} finally {
calculating = false;
}
}
bool allowedToSearch() { true; }
}