Skip to content

Commit fbe8af5

Browse files
committed
chore: update listen & add ellipsis
1 parent edaf53f commit fbe8af5

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/util.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,14 @@ export class Note extends GObject.Object {
223223
GObject.BindingFlags.SYNC_CREATE,
224224
(_, content) => {
225225
if (!content) return [false, ""];
226-
return [true, content.substring(0, 24)]
226+
227+
const title = content.split("\n")[0];
228+
return [true, title.length > 20 ? title.slice(0, 20) + "..." : title];
227229
},
228230
null
229231
);
230232

231-
this.connect("notify::title", () => {
232-
this.emit('title-changed');
233-
});
233+
234234
}
235235

236236
static generate() {
@@ -307,9 +307,6 @@ export class Note extends GObject.Object {
307307
// deno-fmt-ignore
308308
open: GObject.ParamSpec.boolean("open", "Open", "Whether the note was open when the application was closed", GObject.ParamFlags.READWRITE, false),
309309
},
310-
Signals: {
311-
'title-changed': {},
312-
},
313310
}, this);
314311
}
315312
}

src/window.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export class Window extends Adw.ApplicationWindow {
100100

101101
this.update_title();
102102

103-
this.note.connect("title-changed", () => {
103+
this.note.connect("notify::title", () => {
104104
this.update_title();
105105
});
106106

@@ -158,8 +158,8 @@ export class Window extends Adw.ApplicationWindow {
158158
}
159159

160160
update_title() {
161-
if (this.note.title === "") {
162-
this.set_title(_("Untitled Note"));
161+
if (!this.note.title) {
162+
this.set_title("Untitled Note");
163163
return;
164164
}
165165
this.set_title(this.note.title);

0 commit comments

Comments
 (0)