Skip to content

Commit 7cc7a4c

Browse files
authored
Bug Fixes (#309)
2 parents d792572 + 0971028 commit 7cc7a4c

File tree

12 files changed

+180
-135
lines changed

12 files changed

+180
-135
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,11 @@ jobs:
243243
submodules: recursive
244244

245245
- name: Install dependencies
246+
# https://docs.flutter.dev/platform-integration/linux/building#prepare-linux-apps-for-distribution
247+
# https://pub.dev/packages/flutter_secure_storage#configure-linux-version
246248
run: |
247249
sudo apt-get update -y
248-
sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev mpv libmpv-dev dpkg-dev p7zip-full p7zip-rar
250+
sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev mpv libmpv-dev dpkg-dev p7zip-full p7zip-rar libsecret-1-dev libjsoncpp-dev
249251
250252
- name: Install Flutter
251253
uses: subosito/flutter-action@v2.8.0
@@ -381,7 +383,7 @@ jobs:
381383
uses: subosito/flutter-action@v2.8.0
382384
with:
383385
channel: "stable"
384-
flutter-version: 3.24.0
386+
flutter-version: 3.27.0
385387
cache: false
386388

387389
- name: Initiate Flutter

lib/providers/layouts_provider.dart

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ class LayoutsProvider extends UnityProvider {
6767
double? get layoutManagerHeight => _layoutManagerHeight;
6868
set layoutManagerHeight(double? value) {
6969
_layoutManagerHeight = value;
70-
notifyListeners();
7170
save();
7271
}
7372

@@ -89,7 +88,8 @@ class LayoutsProvider extends UnityProvider {
8988
}
9089

9190
@override
92-
Future<void> save({bool notifyListeners = true}) async {
91+
Future<void> save({bool notifyListeners = false}) async {
92+
this.notifyListeners();
9393
await write({
9494
kStorageDesktopLayouts:
9595
jsonEncode(layouts.map((layout) => layout.toMap()).toList()),
@@ -161,20 +161,20 @@ class LayoutsProvider extends UnityProvider {
161161
var previousDevice = layout.devices.firstOrNull;
162162
if (previousDevice != null) {
163163
layout.devices.clear();
164-
await _releaseDevice(device);
164+
await maybeReleaseDevice(device);
165165
}
166166
}
167167

168168
UnityPlayers.players[device.uuid] ??= UnityPlayers.forDevice(device);
169169
layout.devices.add(device);
170170
debugPrint('Added $device');
171171

172-
notifyListeners();
173172
await save();
174173
}
175174
}
176175

177-
Future<void> _releaseDevice(Device device) async {
176+
/// Releases the device if it's not used in any layout.
177+
Future<void> maybeReleaseDevice(Device device) async {
178178
if (!UnityPlayers.players.containsKey(device.uuid)) return;
179179
if (!layouts
180180
.any((layout) => layout.devices.any((d) => d.uuid == device.uuid))) {
@@ -188,9 +188,8 @@ class LayoutsProvider extends UnityProvider {
188188
debugPrint('Removed $device');
189189

190190
currentLayout.devices.remove(device);
191-
_releaseDevice(device);
191+
maybeReleaseDevice(device);
192192
}
193-
notifyListeners();
194193
await save();
195194
}
196195

@@ -206,10 +205,9 @@ class LayoutsProvider extends UnityProvider {
206205
}
207206

208207
for (final device in devices) {
209-
_releaseDevice(device);
208+
maybeReleaseDevice(device);
210209
}
211210

212-
notifyListeners();
213211
await save();
214212
}
215213

@@ -221,10 +219,9 @@ class LayoutsProvider extends UnityProvider {
221219
(d1) => devices.any((d2) => d1.uri == d2.uri),
222220
);
223221
for (final device in devices) {
224-
_releaseDevice(device);
222+
maybeReleaseDevice(device);
225223
}
226224

227-
notifyListeners();
228225
await save();
229226
}
230227

@@ -233,7 +230,6 @@ class LayoutsProvider extends UnityProvider {
233230
if (isLayoutLocked(currentLayout)) return;
234231

235232
currentLayout.devices.insert(end, currentLayout.devices.removeAt(initial));
236-
notifyListeners();
237233
await save();
238234
}
239235

@@ -244,7 +240,6 @@ class LayoutsProvider extends UnityProvider {
244240
} else {
245241
debugPrint('$layout already exists');
246242
}
247-
notifyListeners();
248243
await save();
249244
return layouts.indexOf(layout);
250245
}
@@ -258,10 +253,9 @@ class LayoutsProvider extends UnityProvider {
258253
layouts.remove(layout);
259254

260255
for (final device in layout.devices) {
261-
_releaseDevice(device);
256+
maybeReleaseDevice(device);
262257
}
263258
}
264-
notifyListeners();
265259
await save();
266260
}
267261

@@ -273,15 +267,14 @@ class LayoutsProvider extends UnityProvider {
273267
..insert(layoutIndex, newLayout);
274268
for (final device
275269
in oldLayout.devices.where((d) => !newLayout.devices.contains(d))) {
276-
_releaseDevice(device);
270+
maybeReleaseDevice(device);
277271
}
278272

279273
debugPrint('Replaced $oldLayout at $layoutIndex with $newLayout');
280274
} else {
281275
debugPrint('Layout $oldLayout not found');
282276
}
283277

284-
notifyListeners();
285278
await save();
286279
}
287280

@@ -291,7 +284,6 @@ class LayoutsProvider extends UnityProvider {
291284
UnityPlayers.players[device.uuid] ??= UnityPlayers.forDevice(device);
292285
}
293286

294-
notifyListeners();
295287
await save();
296288
}
297289

@@ -316,7 +308,6 @@ class LayoutsProvider extends UnityProvider {
316308
}
317309

318310
layouts.insert(newIndex, layouts.removeAt(oldIndex));
319-
notifyListeners();
320311
await save();
321312
}
322313

@@ -350,7 +341,6 @@ class LayoutsProvider extends UnityProvider {
350341
UnityPlayers.reloadDevice(device);
351342
}
352343

353-
notifyListeners();
354344
save();
355345

356346
return device;
@@ -359,15 +349,13 @@ class LayoutsProvider extends UnityProvider {
359349
Future<void> collapseServer(Server server) async {
360350
if (!collapsedServers.contains(server.id)) {
361351
collapsedServers.add(server.id);
362-
notifyListeners();
363352
await save();
364353
}
365354
}
366355

367356
Future<void> expandServer(Server server) async {
368357
if (collapsedServers.contains(server.id)) {
369358
collapsedServers.remove(server.id);
370-
notifyListeners();
371359
await save();
372360
}
373361
}
@@ -377,16 +365,14 @@ class LayoutsProvider extends UnityProvider {
377365
Future<void> lockLayout(Layout layout) async {
378366
if (!lockedLayouts.contains(layout)) {
379367
lockedLayouts.add(layout);
380-
notifyListeners();
381-
await save();
368+
await save(notifyListeners: false);
382369
}
383370
}
384371

385372
Future<void> unlockLayout(Layout layout) async {
386373
if (lockedLayouts.contains(layout)) {
387374
lockedLayouts.remove(layout);
388-
notifyListeners();
389-
await save();
375+
await save(notifyListeners: false);
390376
}
391377
}
392378

@@ -400,11 +386,14 @@ class LayoutsProvider extends UnityProvider {
400386

401387
bool isLayoutLocked(Layout layout) => lockedLayouts.contains(layout);
402388

389+
/// Sets the volume for all layouts.
403390
void setVolume(double volume) {
404391
for (final layout in layouts) {
405392
layout.setVolume(volume);
406393
}
394+
save();
407395
}
408396

397+
/// Mutes all layouts.
409398
void mute() => setVolume(0);
410399
}

lib/screens/events_timeline/desktop/timeline.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,13 @@ class Timeline extends ChangeNotifier {
359359
DateTime get currentDate => date.add(currentPosition);
360360

361361
void seekTo(Duration position) {
362-
currentPosition = position;
362+
if (position < Duration.zero) {
363+
currentPosition = Duration.zero;
364+
} else if (position > endPosition) {
365+
currentPosition = endPosition;
366+
} else {
367+
currentPosition = position;
368+
}
363369
notifyListeners();
364370

365371
forEachEvent((tile, event) async {
@@ -375,8 +381,6 @@ class Timeline extends ChangeNotifier {
375381
});
376382
}
377383

378-
// TODO(bdlukaa): Only make it possible to seek between bounds.
379-
// Currently, is is possible to seek before and after the day.
380384
/// Seeks forward by [duration]
381385
void seekForward([Duration duration = const Duration(seconds: 15)]) =>
382386
seekTo(currentPosition + duration);

lib/screens/events_timeline/desktop/timeline_card.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,10 @@ class _TimelineCardState extends State<TimelineCard> {
251251
'/events',
252252
arguments: {
253253
'event': currentEvent.event,
254-
'videoPlayer': widget.tile.videoController,
254+
// Do not pass the video controller to the fullscreen
255+
// view because we don't want to desync the video
256+
// from the Timeline. https://github.com/bluecherrydvr/unity/issues/306
257+
// 'videoPlayer': widget.tile.videoController,
255258
},
256259
);
257260

lib/screens/layouts/desktop/layout_view.dart

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,7 @@ class _LayoutViewState extends State<LayoutView> {
357357
childAspectRatio: kHorizontalAspectRatio,
358358
reorderable: widget.onReorder != null,
359359
onReorder: widget.onReorder ?? (a, b) {},
360-
padding:
361-
settings.isImmersiveMode ? EdgeInsets.zero : kGridPadding,
360+
padding: EdgeInsets.zero,
362361
children: devices.map((device) {
363362
return DesktopDeviceTile(device: device);
364363
}).toList(),
@@ -410,16 +409,17 @@ class _LayoutViewState extends State<LayoutView> {
410409
SizedBox(
411410
height: 24.0,
412411
child: Slider(
413-
value: widget.layout.devices
414-
.map((device) => device.volume)
415-
.findMaxDuplicatedElementInList()
416-
.toDouble(),
412+
value: volume,
417413
divisions: 100,
418414
label: '${(volume * 100).round()}%',
419415
onChanged: (value) async {
420-
widget.layout.setVolume(volume);
416+
await widget.layout.setVolume(value);
421417
if (mounted) setState(() {});
422418
},
419+
onChangeEnd: (value) async {
420+
await widget.layout.setVolume(value);
421+
view.save();
422+
},
423423
),
424424
),
425425
SquaredIconButton(
@@ -507,7 +507,9 @@ class _LayoutViewState extends State<LayoutView> {
507507
),
508508
),
509509
if (devices.isNotEmpty)
510-
Expanded(child: Center(child: child))
510+
Expanded(
511+
child: SizedBox.fromSize(size: Size.infinite, child: child),
512+
)
511513
else
512514
Expanded(
513515
child: Center(child: Text('Add a camera')),

0 commit comments

Comments
 (0)