feat: Allow users to disable marking offline automatically (#6079)
Co-authored-by: Nithin David <1277421+nithindavid@users.noreply.github.com>
This commit is contained in:
co-authored by
Nithin David
parent
82d3398932
commit
aaacf9d4d2
@@ -48,6 +48,14 @@ export const getters = {
|
||||
return currentAccount.availability;
|
||||
},
|
||||
|
||||
getCurrentUserAutoOffline($state, $getters) {
|
||||
const { accounts = [] } = $state.currentUser;
|
||||
const [currentAccount = {}] = accounts.filter(
|
||||
account => account.id === $getters.getCurrentAccountId
|
||||
);
|
||||
return currentAccount.auto_offline;
|
||||
},
|
||||
|
||||
getCurrentAccountId(_, __, rootState) {
|
||||
if (rootState.route.params && rootState.route.params.accountId) {
|
||||
return Number(rootState.route.params.accountId);
|
||||
@@ -174,6 +182,15 @@ export const actions = {
|
||||
}
|
||||
},
|
||||
|
||||
updateAutoOffline: async ({ commit }, { accountId, autoOffline }) => {
|
||||
try {
|
||||
const response = await authAPI.updateAutoOffline(accountId, autoOffline);
|
||||
commit(types.SET_CURRENT_USER, response.data);
|
||||
} catch (error) {
|
||||
// Ignore error
|
||||
}
|
||||
},
|
||||
|
||||
setCurrentUserAvailability({ commit, state: $state }, data) {
|
||||
if (data[$state.currentUser.id]) {
|
||||
commit(types.SET_CURRENT_USER_AVAILABILITY, data[$state.currentUser.id]);
|
||||
|
||||
Reference in New Issue
Block a user