@@ -43,14 +43,20 @@ interface Account {
43
43
name : string ;
44
44
availability : Availability ;
45
45
} ;
46
+
47
+ team : {
48
+ name : string ;
49
+ accent : string ;
50
+ } ;
46
51
}
47
52
48
53
/**************************************************************************
49
54
* CONSTANTS
50
55
* ************************************************************************* */
51
56
52
57
const LOCAL_STATES = {
53
- informationLoaded : false
58
+ informationLoaded : false ,
59
+ teamLoaded : false
54
60
} ;
55
61
56
62
const INFORMATION_AVAILABILITY_DEFAULT = Availability . Available ;
@@ -78,6 +84,11 @@ const $account = defineStore("account", {
78
84
jid : "" ,
79
85
name : "" ,
80
86
availability : INFORMATION_AVAILABILITY_DEFAULT
87
+ } ,
88
+
89
+ team : {
90
+ name : "" ,
91
+ accent : ""
81
92
}
82
93
} ;
83
94
} ,
@@ -114,6 +125,18 @@ const $account = defineStore("account", {
114
125
return ( ) : Availability => {
115
126
return this . information . availability ;
116
127
} ;
128
+ } ,
129
+
130
+ getTeamName : function ( ) {
131
+ return ( ) : string => {
132
+ return this . team . name ;
133
+ } ;
134
+ } ,
135
+
136
+ getTeamAccent : function ( ) {
137
+ return ( ) : string => {
138
+ return this . team . accent ;
139
+ } ;
117
140
}
118
141
} ,
119
142
@@ -188,6 +211,10 @@ const $account = defineStore("account", {
188
211
state . information . jid = "" ;
189
212
state . information . name = "" ;
190
213
state . information . availability = INFORMATION_AVAILABILITY_DEFAULT ;
214
+
215
+ // Clear team
216
+ state . team . name = "" ;
217
+ state . team . accent = "" ;
191
218
} ) ;
192
219
} ,
193
220
@@ -235,6 +262,35 @@ const $account = defineStore("account", {
235
262
}
236
263
} ,
237
264
265
+ async loadTeam ( reload = false ) : Promise < void > {
266
+ // Load team? (or reload)
267
+ if ( LOCAL_STATES . teamLoaded === false || reload === true ) {
268
+ // Load team information
269
+ // TODO: load, remove those fixtures!
270
+ const teamInfo = await Promise . resolve ( {
271
+ domain : "prose.org.local" ,
272
+ name : "Prose Dev" ,
273
+ accent : "#1f1e25" ,
274
+ avatar : undefined
275
+ } ) ;
276
+
277
+ if ( teamInfo ) {
278
+ // Update stored team information
279
+ this . setTeamName ( teamInfo . name ) ;
280
+ this . setTeamAccent ( teamInfo . accent ) ;
281
+
282
+ // Update team avatar
283
+ // Notice: this is a cross-store operation, for convenience.
284
+ if ( teamInfo . avatar !== undefined ) {
285
+ Store . $avatar . refresh ( teamInfo . domain , teamInfo . avatar ) ;
286
+ }
287
+ }
288
+
289
+ // Mark as loaded
290
+ LOCAL_STATES . teamLoaded = true ;
291
+ }
292
+ } ,
293
+
238
294
setCredentialsPassword ( password : string ) : void {
239
295
this . $patch ( ( ) => {
240
296
this . credentials . password = password ;
@@ -257,6 +313,18 @@ const $account = defineStore("account", {
257
313
this . $patch ( ( ) => {
258
314
this . information . availability = availability ;
259
315
} ) ;
316
+ } ,
317
+
318
+ setTeamName ( name : string ) : void {
319
+ this . $patch ( ( ) => {
320
+ this . team . name = name ;
321
+ } ) ;
322
+ } ,
323
+
324
+ setTeamAccent ( accent : string ) : void {
325
+ this . $patch ( ( ) => {
326
+ this . team . accent = accent ;
327
+ } ) ;
260
328
}
261
329
}
262
330
} ) ;
0 commit comments