Skip to content

Commit

Permalink
fix: restored 선택지는 fallback 사용
Browse files Browse the repository at this point in the history
  • Loading branch information
potados99 committed Feb 24, 2022
1 parent 6001f3a commit aaf4dfb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Cafeteria 서비스를 운영하면서 수정이 잦았던 부분들에 대한

## 업데이트 로그

### 2022.2.25 v1.7.17
### 2022.2.25 v1.7.18
- QR 스캐너 화면에서 선택한 식당이 사라졌을 때 대응.

### 2022.2.17 v1.7.16
Expand Down
8 changes: 5 additions & 3 deletions src/features/checkin/mixins/CafeteriaSelectionMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ export default Vue.extend({
async fetchCafeteria() {
const allCafeteria = await Cafeteria.find();
const cafeteriaSupportingBooking = allCafeteria.filter(c => c.supportBooking);
const fallback = cafeteriaSupportingBooking[0];

const savedIdString = localStorage.getItem('qr-scanner-selected-cafeteria');
const savedId = savedIdString ? Number.parseInt(savedIdString) : undefined;
const selected = savedId ? cafeteriaSupportingBooking.find(c => c.id === savedId) : cafeteriaSupportingBooking[0];
const selected = savedId ? cafeteriaSupportingBooking.find(c => c.id === savedId) : fallback;
const restored = selected ?? fallback;

if (selected) {
localStorage.setItem('qr-scanner-selected-cafeteria', selected.id.toString());
if (restored) {
localStorage.setItem('qr-scanner-selected-cafeteria', restored.id.toString());
}

this.allCafeteria = cafeteriaSupportingBooking;
Expand Down

0 comments on commit aaf4dfb

Please sign in to comment.