Skip to content

Commit 9ffd34a

Browse files
feat: commit accent color to views
1 parent 4fdaca1 commit 9ffd34a

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed

src/assemblies/inbox/InboxMessaging.vue

+20
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,9 @@ export default {
294294
this.onStoreSettingsMessagesAny
295295
],
296296

297+
// [$account]
298+
"team:accent": [Store.$account, this.onStoreAccountTeamAccent],
299+
297300
// [$inbox]
298301
"messages:reload": [Store.$inbox, this.onStoreMessagesReload],
299302
"message:restored": [Store.$inbox, this.onStoreMessageRestored],
@@ -629,6 +632,13 @@ export default {
629632
}
630633
},
631634

635+
setupAccent(runtime: MessagingRuntime): void {
636+
// Apply style accent color (or none)
637+
runtime.MessagingContext.setStyleAccent(
638+
this.account.team.accent.background || null
639+
);
640+
},
641+
632642
setupBehavior(runtime: MessagingRuntime): void {
633643
let options = this.settings.messages;
634644

@@ -1255,6 +1265,7 @@ export default {
12551265
this.setupDocument(frameRuntime);
12561266
this.setupContext(frameRuntime);
12571267
this.setupTheme(frameRuntime);
1268+
this.setupAccent(frameRuntime);
12581269
this.setupBehavior(frameRuntime);
12591270
this.setupEvents(frameRuntime);
12601271
this.setupStore(frameRuntime);
@@ -1604,6 +1615,15 @@ export default {
16041615
}
16051616
},
16061617

1618+
onStoreAccountTeamAccent(): void {
1619+
const frameRuntime = this.frame();
1620+
1621+
if (frameRuntime !== null) {
1622+
// Re-setup accent
1623+
this.setupAccent(frameRuntime);
1624+
}
1625+
},
1626+
16071627
onStoreMessagesReload(event: EventMessagesGeneric): void {
16081628
if (this.room?.id === event.roomId) {
16091629
// Synchronize messages eagerly?

src/store/tables/account.ts

+26-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// NPM
1212
import { defineStore } from "pinia";
13+
import mitt from "mitt";
1314
import { Availability, JID } from "@prose-im/prose-sdk-js";
1415

1516
// PROJECT: STORES
@@ -66,6 +67,12 @@ const LOCAL_STATES = {
6667

6768
const INFORMATION_AVAILABILITY_DEFAULT = Availability.Available;
6869

70+
/**************************************************************************
71+
* INSTANCES
72+
* ************************************************************************* */
73+
74+
const EventBus = mitt();
75+
6976
/**************************************************************************
7077
* TABLE
7178
* ************************************************************************* */
@@ -150,6 +157,11 @@ const $account = defineStore("account", {
150157
},
151158

152159
actions: {
160+
events(): ReturnType<typeof mitt> {
161+
// Return event bus
162+
return EventBus;
163+
},
164+
153165
async login(
154166
rawJID: string,
155167
password: string,
@@ -337,9 +349,20 @@ const $account = defineStore("account", {
337349
},
338350

339351
setTeamAccent(accent: AccountTeamAccent): void {
340-
this.$patch(() => {
341-
this.team.accent = accent;
342-
});
352+
// Any change in accent colors?
353+
if (
354+
accent.background !== this.team.accent.background ||
355+
accent.text !== this.team.accent.text
356+
) {
357+
// Update value
358+
this.$patch(() => {
359+
this.team.accent.background = accent.background;
360+
this.team.accent.text = accent.text;
361+
});
362+
363+
// Broadcast value change
364+
EventBus.emit("team:accent", accent);
365+
}
343366
}
344367
}
345368
});

0 commit comments

Comments
 (0)