Skip to content

Commit

Permalink
fix heisenbug about the init of recent tweets list
Browse files Browse the repository at this point in the history
  • Loading branch information
jchris committed Sep 2, 2010
1 parent aa70aad commit ae45c48
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 14 deletions.
File renamed without changes.
File renamed without changes.
@@ -1,11 +1,12 @@
function(r) {
var v = r.value, user = v.user,
app = $$(this).app,
linkup = app.require("vendor/couchapp/lib/linkup");
app = $$(this).app;
var linkup = app.require("vendor/couchapp/lib/linkup");

return {
image_url : user.profile_image_url,
name : user.screen_name,
nickname : user.name,
message : linkup.encode(v.text, "#/user/")
};
};
};
19 changes: 8 additions & 11 deletions vendor/couchapp/_attachments/jquery.evently.js
Expand Up @@ -22,7 +22,7 @@ function $$(node) {
}
};
$.forIn = forIn;
function funViaString(fun) {
function funViaString(fun, hint) {
if (fun && fun.match && fun.match(/^function/)) {
eval("var f = "+fun);
if (typeof f == "function") {
Expand All @@ -31,7 +31,8 @@ function $$(node) {
return f.apply(this, arguments);
} catch(e) {
// IF YOU SEE AN ERROR HERE IT HAPPENED WHEN WE TRIED TO RUN YOUR FUNCTION
$.log({"message": "Error in evently function.", "error": e, "src" : fun});
$.log({"message": "Error in evently function.", "error": e,
"src" : fun, "hint":hint});
throw(e);
}
};
Expand All @@ -42,7 +43,7 @@ function $$(node) {

function runIfFun(me, fun, args) {
// if the field is a function, call it, bound to the widget
var f = funViaString(fun);
var f = funViaString(fun, me);
if (typeof f == "function") {
return f.apply(me, args);
} else {
Expand Down Expand Up @@ -109,9 +110,6 @@ function $$(node) {

if (app && events._changes) {
$("body").bind("evently-changes-"+app.db.name, function() {
// we want to unbind this function when the element is deleted.
// maybe jquery 1.4.2 has this covered?
// $.log('changes', elem);
elem.trigger("_changes");
});
followChanges(app);
Expand All @@ -125,7 +123,7 @@ function $$(node) {
if (h.path) {
elem.pathbinder(name, h.path);
}
var f = funViaString(h);
var f = funViaString(h, name);
if (typeof f == "function") {
elem.bind(name, {args:args}, f);
} else if (typeof f == "string") {
Expand All @@ -141,7 +139,7 @@ function $$(node) {
} else {
// an object is using the evently / mustache template system
if (h.fun) {
elem.bind(name, {args:args}, funViaString(h.fun));
elem.bind(name, {args:args}, funViaString(h.fun, name));
}
// templates, selectors, etc are intepreted
// when our named event is triggered.
Expand All @@ -166,7 +164,7 @@ function $$(node) {
// if there's a query object we run the query,
// and then call the data function with the response.
if (h.before && (!qrun || !arun)) {
funViaString(h.before).apply(me, args);
funViaString(h.before, me).apply(me, args);
}
if (h.async && !arun) {
runAsync(me, h, args)
Expand Down Expand Up @@ -200,7 +198,6 @@ function $$(node) {
}
if (h.after) {
runIfFun(me, h.after, args);
// funViaString(h.after).apply(me, args);
}
}
};
Expand All @@ -215,7 +212,7 @@ function $$(node) {

function runAsync(me, h, args) {
// the callback is the first argument
funViaString(h.async).apply(me, [function() {
funViaString(h.async, me).apply(me, [function() {
renderElement(me, h,
$.argsToArray(arguments).concat($.argsToArray(args)), false, true);
}].concat($.argsToArray(args)));
Expand Down

0 comments on commit ae45c48

Please sign in to comment.