Skip to content

Commit bfb44db

Browse files
committed
refresh on card/collection/tag changes
1 parent 9a65d39 commit bfb44db

6 files changed

Lines changed: 24 additions & 40 deletions

File tree

src/sources/bookmark.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export class BookmarkSource implements DataSource {
194194
}));
195195
}
196196

197-
renderFilterUI(container: HTMLElement, activeFilters: Map<string, SourceFilter>, onChange: () => void, plugin: AtmospherePlugin): void {
197+
renderFilterUI(container: HTMLElement, activeFilters: Map<string, SourceFilter>, onChange: () => void, onDataChange: () => void, plugin: AtmospherePlugin): void {
198198
const section = container.createEl("div", { cls: "atmosphere-filter-section" });
199199

200200
const titleRow = section.createEl("div", { cls: "atmosphere-filter-title-row" });
@@ -203,7 +203,7 @@ export class BookmarkSource implements DataSource {
203203
const createBtn = titleRow.createEl("button", { cls: "atmosphere-filter-create-btn" });
204204
setIcon(createBtn, "plus");
205205
createBtn.addEventListener("click", () => {
206-
new CreateTagModal(plugin, onChange).open();
206+
new CreateTagModal(plugin, onDataChange).open();
207207
});
208208

209209
const chips = section.createEl("div", { cls: "atmosphere-filter-chips" });

src/sources/margin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ export class MarginSource implements DataSource {
238238
return filters;
239239
}
240240

241-
renderFilterUI(container: HTMLElement, activeFilters: Map<string, SourceFilter>, onChange: () => void, plugin: AtmospherePlugin): void {
241+
renderFilterUI(container: HTMLElement, activeFilters: Map<string, SourceFilter>, onChange: () => void, onDataChange: () => void, plugin: AtmospherePlugin): void {
242242
const collectionsSection = container.createEl("div", { cls: "atmosphere-filter-section" });
243243

244244
const collectionsTitleRow = collectionsSection.createEl("div", { cls: "atmosphere-filter-title-row" });
@@ -247,7 +247,7 @@ export class MarginSource implements DataSource {
247247
const createCollectionBtn = collectionsTitleRow.createEl("button", { cls: "atmosphere-filter-create-btn" });
248248
setIcon(createCollectionBtn, "plus");
249249
createCollectionBtn.addEventListener("click", () => {
250-
new CreateMarginCollectionModal(plugin, onChange).open();
250+
new CreateMarginCollectionModal(plugin, onDataChange).open();
251251
});
252252

253253
const collectionsChips = collectionsSection.createEl("div", { cls: "atmosphere-filter-chips" });

src/sources/semble.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ export class SembleSource implements DataSource {
215215
}));
216216
}
217217

218-
renderFilterUI(container: HTMLElement, activeFilters: Map<string, SourceFilter>, onChange: () => void, plugin: AtmospherePlugin): void {
218+
renderFilterUI(container: HTMLElement, activeFilters: Map<string, SourceFilter>, onChange: () => void, onDataChange: () => void, plugin: AtmospherePlugin): void {
219219
const section = container.createEl("div", { cls: "atmosphere-filter-section" });
220220

221221
const titleRow = section.createEl("div", { cls: "atmosphere-filter-title-row" });
@@ -224,7 +224,7 @@ export class SembleSource implements DataSource {
224224
const createBtn = titleRow.createEl("button", { cls: "atmosphere-filter-create-btn" });
225225
setIcon(createBtn, "plus");
226226
createBtn.addEventListener("click", () => {
227-
new CreateCollectionModal(plugin, onChange).open();
227+
new CreateCollectionModal(plugin, onDataChange).open();
228228
});
229229

230230
const chips = section.createEl("div", { cls: "atmosphere-filter-chips" });
@@ -238,8 +238,6 @@ export class SembleSource implements DataSource {
238238
onChange();
239239
});
240240

241-
// Get collections synchronously - note: this is a limitation
242-
// In a real app, we'd want to cache these or handle async properly
243241
void this.getAvailableFilters().then(collections => {
244242
for (const collection of collections) {
245243
const chip = chips.createEl("button", {

src/sources/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ export interface DataSource {
2323
readonly name: "semble" | "bookmark" | "margin";
2424
fetchItems(filters: SourceFilter[], plugin: AtmospherePlugin): Promise<ATBookmarkItem[]>;
2525
getAvailableFilters(): Promise<SourceFilter[]>;
26-
renderFilterUI(container: HTMLElement, activeFilters: Map<string, SourceFilter>, onChange: () => void, plugin: AtmospherePlugin): void;
26+
renderFilterUI(container: HTMLElement, activeFilters: Map<string, SourceFilter>, onChange: () => void, onDataChange: () => void, plugin: AtmospherePlugin): void;
2727
}

src/views/bookmarks.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ export class AtmosphereView extends ItemView {
145145
attr: { "aria-label": "Refresh bookmarks" }
146146
});
147147
setIcon(refreshBtn, "refresh-cw");
148-
refreshBtn.addEventListener("click", async () => {
148+
refreshBtn.addEventListener("click", () => {
149149
refreshBtn.addClass("atmosphere-refresh-btn-spinning");
150-
await this.refresh();
150+
void this.refresh();
151151
refreshBtn.removeClass("atmosphere-refresh-btn-spinning");
152152
});
153153

@@ -158,6 +158,7 @@ export class AtmosphereView extends ItemView {
158158
filtersContainer,
159159
sourceData.filters,
160160
() => void this.render(),
161+
() => void this.refresh(),
161162
this.plugin
162163
);
163164
}
@@ -172,7 +173,7 @@ export class AtmosphereView extends ItemView {
172173
return;
173174
}
174175
new CardDetailModal(this.plugin, item, () => {
175-
void this.render();
176+
void this.refresh();
176177
}).open();
177178
});
178179

@@ -191,7 +192,7 @@ export class AtmosphereView extends ItemView {
191192
editBtn.addEventListener("click", (e) => {
192193
e.stopPropagation();
193194
item.openEditModal(() => {
194-
void this.render();
195+
void this.refresh();
195196
});
196197
});
197198
}

styles.css

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -76,43 +76,28 @@
7676
}
7777

7878
.atmosphere-refresh-btn {
79-
display: flex;
80-
align-items: center;
81-
justify-content: center;
82-
width: 32px;
83-
height: 32px;
84-
padding: 0;
8579
background: transparent;
86-
border: 1px solid var(--background-modifier-border);
87-
border-radius: var(--radius-s);
88-
cursor: pointer;
80+
border: none;
8981
color: var(--text-muted);
90-
transition: all 0.15s ease;
91-
flex-shrink: 0;
82+
cursor: pointer;
83+
padding: 4px;
84+
display: flex;
85+
align-items: center;
86+
opacity: 0.6;
87+
transition: opacity 0.15s ease;
9288
}
9389

9490
.atmosphere-refresh-btn:hover {
95-
background: var(--background-modifier-hover);
96-
color: var(--text-normal);
97-
border-color: var(--background-modifier-border-hover);
98-
}
99-
100-
.atmosphere-refresh-btn svg {
101-
width: 16px;
102-
height: 16px;
91+
opacity: 1;
10392
}
10493

105-
.atmosphere-refresh-btn-spinning svg {
106-
animation: atmosphere-spin 0.8s linear infinite;
94+
.atmosphere-refresh-btn-spinning {
95+
animation: atmosphere-spin 0.6s linear infinite;
10796
}
10897

10998
@keyframes atmosphere-spin {
110-
from {
111-
transform: rotate(0deg);
112-
}
113-
to {
114-
transform: rotate(360deg);
115-
}
99+
from { transform: rotate(0deg); }
100+
to { transform: rotate(360deg); }
116101
}
117102

118103
.atmosphere-filters {

0 commit comments

Comments
 (0)