From abc27295ab5abd3cdf49e505990ecc58b8d472f6 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 16 Mar 2020 14:49:59 +0100 Subject: [PATCH] Fix XXX in kanban --- www/common/common-ui-elements.js | 2 +- www/kanban/inner.js | 17 +++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index c3dff9ac6..c720af2c9 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -2823,7 +2823,7 @@ define([ } return arr; }; - var getFirstEmojiOrCharacter = function (str) { + var getFirstEmojiOrCharacter = UIElements.getFirstCharacter = function (str) { if (!str || !str.trim()) { return '?'; } var emojis = emojiStringToArray(str); return isEmoji(emojis[0])? emojis[0]: str[0]; diff --git a/www/kanban/inner.js b/www/kanban/inner.js index ab7b98066..310219e75 100644 --- a/www/kanban/inner.js +++ b/www/kanban/inner.js @@ -56,12 +56,6 @@ define([ var onCursorUpdate = Util.mkEvent(); var remoteCursors = {}; - -// XXX -// Conflicts -// use cursor channel to tell others what you are editing -// add outline + warning inside the modal? - var setValueAndCursor = function (input, val, _cursor) { if (!input) { return; } var $input = $(input); @@ -102,9 +96,7 @@ define([ } html += cursor.name + ''; - // XXX breaks on "😶" - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt#Getting_whole_characters - var l = (cursor.name || Messages.anonymous).slice(0,1).toUpperCase(); + var l = UIElements.getFirstCharacter(cursor.name || Messages.anonymous); var text = ''; if (cursor.color) { @@ -735,6 +727,9 @@ define([ onCursorUpdate.fire({}); if (!$input.val()) { return; } var id = Util.createRandomInteger(); + while (kanban.getItemJSON(id)) { + id = Util.createRandomInteger(); + } var item = { "id": id, "title": $input.val(), @@ -788,8 +783,10 @@ define([ var boardExists = function (b) { return b.id === "board" + counter; }; while (kanban.options.boards.some(boardExists)) { counter++; } */ - // XXX confirm that it doesn't collide with an existing id? unlikely but possible var id = Util.createRandomInteger(); + while (kanban.getBoardJSON(id)) { + id = Util.createRandomInteger(); + } kanban.addBoard({ "id": id,