Refactor code

This commit is contained in:
RMidhunSuresh 2021-12-20 13:08:44 +05:30
parent 9eeeea47d9
commit 78c79b148a
2 changed files with 8 additions and 4 deletions

View file

@ -18,7 +18,7 @@ import {BaseEntry} from "./BaseEntry";
import {REDACTION_TYPE} from "../../common.js"; import {REDACTION_TYPE} from "../../common.js";
import {createAnnotation, ANNOTATION_RELATION_TYPE, getRelationFromContent} from "../relations.js"; import {createAnnotation, ANNOTATION_RELATION_TYPE, getRelationFromContent} from "../relations.js";
import {PendingAnnotation} from "../PendingAnnotation.js"; import {PendingAnnotation} from "../PendingAnnotation.js";
import {createReplyContent} from "./reply.js" import {createReplyContent, THREADING_REL_TYPE} from "./reply.js"
/** Deals mainly with local echo for relations and redactions, /** Deals mainly with local echo for relations and redactions,
* so it is shared between PendingEventEntry and EventEntry */ * so it is shared between PendingEventEntry and EventEntry */
@ -36,7 +36,7 @@ export class BaseEventEntry extends BaseEntry {
} }
get isThread() { get isThread() {
return this.relation?.["rel_type"] === "io.element.thread"; return this.relation?.["rel_type"] === THREADING_REL_TYPE;
} }
get isRedacting() { get isRedacting() {

View file

@ -14,6 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import {getRelatedEventId} from "../relations.js";
export const THREADING_REL_TYPE = "io.element.thread";
function htmlEscape(string) { function htmlEscape(string) {
return string.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"); return string.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
} }
@ -81,8 +85,8 @@ function createThreadContent(entry, msgtype, body) {
msgtype, msgtype,
body, body,
"m.relates_to": { "m.relates_to": {
"rel_type": "m.thread", "rel_type": THREADING_REL_TYPE,
"event_id": entry.id "event_id": getRelatedEventId(entry)
} }
}; };
} }