Skip to content

Commit ff5f91b

Browse files
fix(activity): detect Android device at runtime for view selection
VUE_APP_ON_ANDROID is set at build time and only covers the embedded Android webui. When a desktop browser views an Android device's data, the default views always show desktop views (Top Window Titles etc.) instead of the Android summary view. Fix by replacing the mapState('views') with an explicit computed that checks bucketsStore.available(host).android at runtime. If the host has Android buckets but no window buckets, return androidViews regardless of build env.
1 parent 0a43547 commit ff5f91b

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/stores/views.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const desktopViews: View[] = [
5454
},
5555
];
5656

57-
const androidViews = [
57+
export const androidViews: View[] = [
5858
{
5959
id: 'summary',
6060
name: 'Summary',

src/views/activity/Activity.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ import 'vue-awesome/icons/ellipsis-v';
229229
import { useSettingsStore } from '~/stores/settings';
230230
import { useCategoryStore } from '~/stores/categories';
231231
import { useActivityStore, QueryOptions } from '~/stores/activity';
232-
import { useViewsStore } from '~/stores/views';
232+
import { useViewsStore, androidViews } from '~/stores/views';
233+
import { useBucketsStore } from '~/stores/buckets';
233234
234235
export default {
235236
name: 'Activity',
@@ -254,6 +255,7 @@ export default {
254255
data: function () {
255256
return {
256257
activityStore: useActivityStore(),
258+
bucketsStore: useBucketsStore(),
257259
categoryStore: useCategoryStore(),
258260
viewsStore: useViewsStore(),
259261
settingsStore: useSettingsStore(),
@@ -275,7 +277,17 @@ export default {
275277
};
276278
},
277279
computed: {
278-
...mapState(useViewsStore, ['views']),
280+
views(): import('~/stores/views').View[] {
281+
// Use Android views when the current host is an Android device.
282+
// VUE_APP_ON_ANDROID is a build-time flag that only applies when the webui
283+
// is embedded in the Android app itself. When browsing Android device data
284+
// from a desktop browser we need a runtime check instead.
285+
const available = this.bucketsStore.available(this.host);
286+
if (available.android && !available.window) {
287+
return androidViews;
288+
}
289+
return this.viewsStore.views;
290+
},
279291
...mapState(useSettingsStore, ['devmode']),
280292
...mapState(useSettingsStore, ['always_active_pattern']),
281293

0 commit comments

Comments
 (0)