Skip to content

Commit

Permalink
Remove commented-out code
Browse files Browse the repository at this point in the history
  • Loading branch information
enigma0Z committed Dec 10, 2024
1 parent f9b41d1 commit 8f2ff18
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 50 deletions.
21 changes: 6 additions & 15 deletions models/ServerModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ export default class ServerModel {
}

/**
* Development note -- this was originally wrapped in mobx task(), which provides some state tracking on asynchronous operations.
* This has been re-implemented with an async call
* Development note -- this was originally wrapped in mobx task(), which
* provides some state tracking on asynchronous operations. This has been
* re-implemented with a direct async call, but if the .pending property is
* actively needed, a fetch hook will need to be written around this to track
* the status of the request.
*/
fetchInfo = async () => {
return fetchServerInfo(this)
Expand All @@ -51,16 +54,4 @@ export default class ServerModel {
this.online = false;
});
}
}

// decorate(ServerModel, {
// id: observable,
// url: observable,
// online: [
// ignore,
// observable
// ],
// info: observable,
// name: computed,
// parseUrlString: computed
// });
}
2 changes: 1 addition & 1 deletion screens/SettingsScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ const SettingsScreen = observer(() => {
sections={getSections()}
extraData={{
activeServer: rootStore.settingStore.activeServer,
isFetching: serverStore.fetchInfo.pending // TODO: .pending is a hang-over from mobx. If the data is not used, it doesn't matter, but if it needs to be used, a hook needs to be written around this missing property
isFetching: serverStore.fetchInfo.pending
}}
renderItem={({ item }) => <Text>{JSON.stringify(item)}</Text>}
renderSectionHeader={({ section: { data, title, hideHeader } }) => {
Expand Down
36 changes: 2 additions & 34 deletions stores/ServerStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,41 +49,9 @@ export const useServerStore = create<State & Actions>()((set, get) => ({
set({ servers })
},
reset: () => set({servers: []}),
fetchInfo: async () => { // Mobx provided a `.pending` member on the return type of this. May be we need to do something else with its promise
fetchInfo: async () => {
await Promise.all(
get().servers.map(server => server.fetchInfo())
)
}
}))

// export default class ServerStore {
// servers = []

// addServer(server) {
// this.servers.push(new ServerModel(uuidv4(), server.url));
// }

// removeServer(index) {
// this.servers.splice(index, 1);
// }

// reset() {
// this.servers = [];
// }

// fetchInfo = task(async () => {
// await Promise.all(
// this.servers.map(server => server.fetchInfo())
// );
// })
// }

// decorate(ServerStore, {
// servers: [
// format(DESERIALIZER),
// observable
// ],
// addServer: action,
// removeServer: action,
// reset: action
// });
}))

0 comments on commit 8f2ff18

Please sign in to comment.