From 8a82e11306d8a1aae2aaca8070da288d387fc6d8 Mon Sep 17 00:00:00 2001
From: ansuz <ansuz@transitiontech.ca>
Date: Thu, 30 Jun 2016 15:53:13 +0200
Subject: [PATCH] make sure title is defined for home page usage

---
 customize.dist/index.html     |  2 +-
 www/common/cryptpad-common.js | 13 ++++++-------
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/customize.dist/index.html b/customize.dist/index.html
index 3bfe9d97e..ad63f264e 100644
--- a/customize.dist/index.html
+++ b/customize.dist/index.html
@@ -162,7 +162,7 @@
                 };
 
                 var truncateTitle = function (title, len) {
-                    if (title.length > len) {
+                    if (typeof(title) === 'string' && title.length > len) {
                         return title.slice(0, len) + '…';
                     }
                     return title;
diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js
index d0a860a10..71845fed3 100644
--- a/www/common/cryptpad-common.js
+++ b/www/common/cryptpad-common.js
@@ -43,17 +43,16 @@ define([
                 return {
                     href: pad[0],
                     atime: pad[1],
-                    title: pad[2],
+                    title: pad[2] || '',
                     ctime: pad[1],
                 };
             } else if (typeof(pad) === 'object') {
                 if (!pad.ctime) { pad.ctime = pad.atime; }
-                /*
-                if (pad.date) {
-                    pad.atime = pad.date;
-                    delete pad.date;
-                    pad.date = undefined;
-                }*/
+                if (!pad.title) {
+                    pad.href.replace(/#(.*)$/, function (x, hash) {
+                        pad.title = hash.slice(0,8);
+                    });
+                }
                 return pad;
             } else {
                 console.error("[Cryptpad.migrateRecentPads] pad had unexpected value");