Files
raucao 2cb54813b9 Add weekly and daily wallpaper rotation
Rotate through photos from enabled feeds with a persisted shuffle-bag queue. Weekly changes at local Monday midnight and daily at local midnight; Off keeps the selected photo. Legacy configs migrate to the weekly default, and Rotation now sits above Feeds in the Photos settings.
2026-11-08 22:25:59 +04:00

89 lines
2.6 KiB
Plaintext

import Component from '@glimmer/component';
import { action } from '@ember/object';
import { service } from '@ember/service';
import PhotoFeed from './photo-feed.gjs';
import RotationSettings from './rotation-settings.gjs';
import { nextRotationStart } from '../../../../utils/rotation';
// The Photos settings section: enable feeds and pick the current wallpaper.
// Creator attribution intentionally lives on the dashboard, next to Settings.
export default class SettingsPhotosSection extends Component {
@service photos;
get feeds() {
return this.photos.feeds;
}
get nextChangeLabel() {
if (!this.photos.isRotating) {
return null;
}
const date = new Date(nextRotationStart(Date.now(), this.photos.rotation));
return new Intl.DateTimeFormat(undefined, {
weekday: 'short',
month: 'short',
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
}).format(date);
}
@action
async toggleFeed(feedId, event) {
await this.photos.setFeedEnabled(feedId, event.target.checked);
}
<template>
<div class="min-h-0 flex-1 overflow-y-auto px-6 py-6">
<div class="flex items-center gap-3">
<p class="max-w-prose text-sm text-gray-500">
Choose the wallpapers shown on your dashboard, and if or when they
change.
</p>
{{#if this.photos.refreshing}}
<span class="text-xs text-gray-400">Refreshing...</span>
{{/if}}
</div>
{{#if this.photos.error}}
<p class="mt-4 rounded-md bg-red-50 px-3 py-2 text-sm text-red-700">
{{this.photos.error}}
</p>
{{/if}}
<RotationSettings />
<div class="mt-8 border-t border-gray-200 pt-6">
<h4 class="text-sm font-semibold text-gray-900" data-test-feeds-header>
Feeds
</h4>
{{#if this.feeds.length}}
<div class="mt-4 space-y-4">
{{#each this.feeds as |feed|}}
<PhotoFeed @feed={{feed}} @onToggle={{this.toggleFeed}} />
{{/each}}
</div>
{{else if this.photos.refreshing}}
<p class="mt-4 text-sm text-gray-400">Loading photo feeds...</p>
{{else}}
<p
class="mt-4 rounded-xl bg-gray-50 p-6 text-center text-sm text-gray-500"
>
No photo feeds loaded yet.
</p>
{{/if}}
</div>
{{#if this.photos.isRotating}}
<p class="mt-6 text-xs text-gray-400" data-test-rotation-next>
Selecting a photo keeps it until the next change. Next change:
{{this.nextChangeLabel}}.
</p>
{{/if}}
</div>
</template>
}