Skip to content

Commit 86807ff

Browse files
authored
More community events improvements (#212)
* Better event notifications Add support for loading tournament logos * Add More info link Better link parsing * Remove log * Because there's room, show the first 4 items * Make logos 50% bigger * Allocate more screen real-estate
1 parent a5f8a57 commit 86807ff

3 files changed

Lines changed: 86 additions & 54 deletions

File tree

rlbot_gui/gui/js/community-events-vue.js

Lines changed: 76 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
11
export default {
22
name: 'community-events',
33
template: /*html*/`
4-
<b-modal title="Community Events" id="community-events" size="lg" centered ok-only>
5-
<div v-if="events.length == 0">
6-
<p>There are no community events at this time.</p>
7-
</div>
8-
<div v-else v-for="event in events">
9-
<h3>{{ event.name }}</h3>
10-
<p v-if="event.timeUntilMs > 0" class="mb-1">
11-
<b-icon icon="calendar-plus"/> Starts in <b>{{ event.timeUntil }}</b> ({{ event.time }})
12-
</p>
13-
<p v-else class="mb-1">
14-
<b-icon icon="alarm"/> Started <b>{{ event.timeUntil }}</b> ago, but you can still join!
15-
</p>
16-
<p>
17-
<b-icon icon="geo"/> <a :href="event.location" target="_blank">{{ event.location }}</a>
18-
</p>
19-
</div>
20-
</b-modal>
4+
<b-modal title="Community Events" id="community-events" size="xl" centered ok-only>
5+
<div v-if="events.length == 0">
6+
<p>There are no community events at this time.</p>
7+
</div>
8+
<div v-else v-for="event in events">
9+
<div class="d-flex align-items-center">
10+
<img v-if="event.logo" :src="event.logo" class="mr-3" style="max-width: 100%; max-height: 150px;"/>
11+
<div>
12+
<h3>{{ event.name }}</h3>
13+
<p v-if="event.timeUntilMs > 0" class="mb-1">
14+
<b-icon icon="calendar-plus"/> Starts in <b>{{ event.timeUntil }}</b> ({{ event.time }})
15+
</p>
16+
<p v-else class="mb-1">
17+
<b-icon icon="alarm"/> Started <b>{{ event.timeUntil }}</b> ago, but you can still join!
18+
</p>
19+
<p>
20+
<b-icon icon="geo"/> <a :href="event.location" target="_blank">{{ event.location }}</a>
21+
</p>
22+
<p v-if="event.moreInfo">
23+
<b-icon icon="info-circle"/> <a :href="event.moreInfo" target="_blank">More info</a>
24+
</p>
25+
</div>
26+
</div>
27+
</div>
28+
</b-modal>
2129
`,
2230
data() {
2331
return {
@@ -32,41 +40,42 @@ export default {
3240
const start = event.start.dateTime;
3341
let new_date = new Date(start);
3442

35-
try {
36-
const recurrence = event.recurrence[0].split(";");
37-
const rec_type = recurrence[0].split("=")[1];
38-
const interval = recurrence[2].split("=")[1];
39-
const end_date_type = recurrence[2].split("=")[0];
40-
const end_date_raw = recurrence[2].split("=")[1];
41-
let end_date = new Date(new_date);
42-
if (end_date_type == "COUNT") {
43-
if (rec_type == "WEEKLY") {
44-
end_date.setDate(new_date.getDate() + 7 * interval * end_date_raw);
45-
} else if (rec_type == "MONTHLY") {
46-
end_date.setDate(new_date.getDate() + 4 * interval * end_date_raw);
47-
}
48-
} else {
49-
end_date.setDate(end_date_raw);
50-
}
51-
if (rec_type == "WEEKLY") {
52-
while (new_date <= end_date) {
53-
if (new_date > today) {
54-
break;
43+
if (event.recurrence) {
44+
try {
45+
const recurrence = event.recurrence[0].split(";");
46+
const rec_type = recurrence[0].split("=")[1];
47+
const interval = recurrence[2].split("=")[1];
48+
const end_date_type = recurrence[2].split("=")[0];
49+
const end_date_raw = recurrence[2].split("=")[1];
50+
let end_date = new Date(new_date);
51+
if (end_date_type == "COUNT") {
52+
if (rec_type == "WEEKLY") {
53+
end_date.setDate(new_date.getDate() + 7 * interval * end_date_raw);
54+
} else if (rec_type == "MONTHLY") {
55+
end_date.setDate(new_date.getDate() + 4 * interval * end_date_raw);
5556
}
56-
new_date.setDate(new_date.getDate() + 7);
57+
} else {
58+
end_date.setDate(end_date_raw);
5759
}
58-
} else if (rec_type == "MONTHLY") {
59-
while (new_date <= end_date) {
60-
if (new_date > today) {
61-
break;
60+
if (rec_type == "WEEKLY") {
61+
while (new_date <= end_date) {
62+
if (new_date > today) {
63+
break;
64+
}
65+
new_date.setDate(new_date.getDate() + 7);
66+
}
67+
} else if (rec_type == "MONTHLY") {
68+
while (new_date <= end_date) {
69+
if (new_date > today) {
70+
break;
71+
}
72+
new_date.setDate(new_date.getDate() + 4);
6273
}
63-
new_date.setDate(new_date.getDate() + 4);
6474
}
75+
} catch (e) {
76+
console.error("Error checking recurrence:" + e);
6577
}
6678
}
67-
catch (e) {
68-
console.error("Error checking recurrence:" + e);
69-
}
7079

7180
const time_untils = new_date.getTime() - today.getTime();
7281
return [names, new_date, time_untils];
@@ -128,12 +137,31 @@ export default {
128137
// convert this to something human readable, like "in 2 days"
129138
const format = this.formatFromNow(Math.abs(time_until_ms));
130139

140+
let logo =
141+
event.description && event.description.includes("logo:")
142+
? event.description
143+
.split("logo:")[1]
144+
.replace("\n", "")
145+
.split("href=\"")[1]
146+
.split("\"")[0]
147+
: null;
148+
149+
let description = event.description
150+
? event.description
151+
.split("logo:")[0]
152+
.replace("\n", "")
153+
.split("href=\"")[1]
154+
.split("\"")[0]
155+
: null;
156+
131157
this.events.push({
132158
name: names,
133159
location: event.location,
134160
time: new_date.toLocaleString(),
135161
timeUntil: format,
136162
timeUntilMs: time_until_ms,
163+
moreInfo: description,
164+
logo: logo,
137165
});
138166
}
139167

@@ -142,8 +170,8 @@ export default {
142170
return new Date(a.timeUntilMs) - new Date(b.timeUntilMs);
143171
});
144172

145-
// only show the first 3
146-
this.events = this.events.slice(0, 3);
173+
// only show the first 4
174+
this.events = this.events.slice(0, 4);
147175
});
148176
});
149177
},

rlbot_gui/gui/js/main-vue.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,15 @@ export default {
3131
3232
<b-button @click="$bvModal.show('community-events')" variant="dark" class="ml-2">
3333
Events
34-
<b-badge v-if="$refs.communityEvents?.events.length" variant="primary">
35-
{{ $refs.communityEvents.events.length }}
36-
</b-badge>
37-
<b-badge v-if="$refs.communityEvents?.eventsNow" variant="danger">
38-
{{ $refs.communityEvents.eventsNow }} live!
34+
<b-badge v-if="$refs.communityEvents?.events.length > 0" variant="danger">
35+
<span v-if="$refs.communityEvents?.eventsNow">
36+
<b-icon icon="alarm"/>
37+
{{ $refs.communityEvents.eventsNow }}
38+
</span>
39+
<span v-if="$refs.communityEvents?.eventsFuture">
40+
<b-icon icon="calendar-plus"/>
41+
{{ $refs.communityEvents.eventsFuture }}
42+
</span>
3943
</b-badge>
4044
</b-button>
4145

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import setuptools
22

3-
__version__ = '0.0.151'
3+
__version__ = '0.0.152'
44

55
with open("README.md", "r") as readme_file:
66
long_description = readme_file.read()

0 commit comments

Comments
 (0)