drafts: Catch and log error caused by drafts with undefined topics.

This is a bandaid fix to an error that came out of #22094.
The error was fixed in #23238 but some drafts still have
undefined topics which is raising this error.

More details on CZO: https://chat.zulip.org/#narrow/stream/9-issues/topic/live.20update.20issue.20with.20drafts/near/1457913
This commit is contained in:
evykassirer
2022-11-01 17:10:11 -07:00
committed by Tim Abbott
parent 1fadb7cbd9
commit 919f08d80f
2 changed files with 56 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
import _ from "lodash";
import * as blueslip from "./blueslip";
import {$t} from "./i18n";
// From MDN: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/random
@@ -39,6 +40,10 @@ export function lower_bound(array, value, less) {
}
export const lower_same = function lower_same(a, b) {
if (a === undefined || b === undefined) {
blueslip.error(`Cannot compare strings; at least one value is undefined: ${a}, ${b}`);
return false;
}
return a.toLowerCase() === b.toLowerCase();
};